mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-25 22:10:38 +02:00
panfrost: Pass compile arguments through a struct
So we can extend it more easily without having to patch all callers. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7066>
This commit is contained in:
parent
78ec5225c2
commit
0a74a04ba5
9 changed files with 63 additions and 30 deletions
|
|
@ -236,14 +236,17 @@ panfrost_shader_compile(struct panfrost_context *ctx,
|
|||
|
||||
/* Call out to Midgard compiler given the above NIR */
|
||||
panfrost_program program = {0};
|
||||
memcpy(program.rt_formats, state->rt_formats, sizeof(program.rt_formats));
|
||||
struct panfrost_compile_inputs inputs = {
|
||||
.gpu_id = dev->gpu_id,
|
||||
.shaderdb = !!(dev->debug & PAN_DBG_PRECOMPILE),
|
||||
};
|
||||
|
||||
if (dev->quirks & IS_BIFROST) {
|
||||
bifrost_compile_shader_nir(s, &program, dev->gpu_id);
|
||||
} else {
|
||||
midgard_compile_shader_nir(s, &program, false, 0, dev->gpu_id,
|
||||
dev->debug & PAN_DBG_PRECOMPILE);
|
||||
}
|
||||
memcpy(inputs.rt_formats, state->rt_formats, sizeof(inputs.rt_formats));
|
||||
|
||||
if (dev->quirks & IS_BIFROST)
|
||||
bifrost_compile_shader_nir(s, &program, &inputs);
|
||||
else
|
||||
midgard_compile_shader_nir(s, &program, &inputs);
|
||||
|
||||
/* Prepare the compiled binary for upload */
|
||||
mali_ptr shader = 0;
|
||||
|
|
|
|||
|
|
@ -213,11 +213,16 @@ panfrost_compile_blend_shader(
|
|||
|
||||
/* Compile the built shader */
|
||||
|
||||
panfrost_program program = {
|
||||
.rt_formats = {format}
|
||||
panfrost_program program;
|
||||
|
||||
struct panfrost_compile_inputs inputs = {
|
||||
.gpu_id = dev->gpu_id,
|
||||
.is_blend = true,
|
||||
.blend.rt = rt,
|
||||
.rt_formats = {format},
|
||||
};
|
||||
|
||||
midgard_compile_shader_nir(shader, &program, true, rt, dev->gpu_id, false);
|
||||
midgard_compile_shader_nir(shader, &program, &inputs);
|
||||
|
||||
/* Allow us to patch later */
|
||||
res.patch_index = program.blend_patch_offset;
|
||||
|
|
|
|||
|
|
@ -1321,14 +1321,15 @@ bi_optimize_nir(nir_shader *nir)
|
|||
}
|
||||
|
||||
void
|
||||
bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program, unsigned product_id)
|
||||
bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program,
|
||||
const struct panfrost_compile_inputs *inputs)
|
||||
{
|
||||
bifrost_debug = debug_get_option_bifrost_debug();
|
||||
|
||||
bi_context *ctx = rzalloc(NULL, bi_context);
|
||||
ctx->nir = nir;
|
||||
ctx->stage = nir->info.stage;
|
||||
ctx->quirks = bifrost_get_quirks(product_id);
|
||||
ctx->quirks = bifrost_get_quirks(inputs->gpu_id);
|
||||
list_inithead(&ctx->blocks);
|
||||
|
||||
/* Lower gl_Position pre-optimisation, but after lowering vars to ssa
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@
|
|||
#include "util/u_dynarray.h"
|
||||
#include "panfrost/util/pan_ir.h"
|
||||
|
||||
void bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program, unsigned product_id);
|
||||
void bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program,
|
||||
const struct panfrost_compile_inputs *inputs);
|
||||
|
||||
static const nir_shader_compiler_options bifrost_nir_options = {
|
||||
.lower_scmp = true,
|
||||
|
|
|
|||
|
|
@ -67,8 +67,11 @@ compile_shader(char **argv, bool vertex_only)
|
|||
NIR_PASS_V(nir[i], gl_nir_lower_buffers, prog);
|
||||
NIR_PASS_V(nir[i], nir_opt_constant_folding);
|
||||
|
||||
unsigned product_id = 0x7212; /* Mali G52 */
|
||||
bifrost_compile_shader_nir(nir[i], &compiled, product_id);
|
||||
struct panfrost_compile_inputs inputs = {
|
||||
.gpu_id = 0x7212, /* Mali G52 */
|
||||
};
|
||||
|
||||
bifrost_compile_shader_nir(nir[i], &compiled, &inputs);
|
||||
|
||||
if (vertex_only)
|
||||
return compiled;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,11 @@ panfrost_build_blit_shader(panfrost_program *program, unsigned gpu_id, gl_frag_r
|
|||
else
|
||||
nir_store_var(b, c_out, nir_channel(b, &tex->dest.ssa, 0), 0xFF);
|
||||
|
||||
midgard_compile_shader_nir(shader, program, false, 0, gpu_id, false);
|
||||
struct panfrost_compile_inputs inputs = {
|
||||
.gpu_id = gpu_id,
|
||||
};
|
||||
|
||||
midgard_compile_shader_nir(shader, program, &inputs);
|
||||
ralloc_free(shader);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2949,7 +2949,8 @@ mir_add_writeout_loops(compiler_context *ctx)
|
|||
}
|
||||
|
||||
int
|
||||
midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_blend, unsigned blend_rt, unsigned gpu_id, bool shaderdb)
|
||||
midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program,
|
||||
const struct panfrost_compile_inputs *inputs)
|
||||
{
|
||||
struct util_dynarray *compiled = &program->compiled;
|
||||
|
||||
|
|
@ -2960,11 +2961,11 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
|
|||
|
||||
ctx->nir = nir;
|
||||
ctx->stage = nir->info.stage;
|
||||
ctx->is_blend = is_blend;
|
||||
ctx->blend_rt = MIDGARD_COLOR_RT0 + blend_rt;
|
||||
ctx->is_blend = inputs->is_blend;
|
||||
ctx->blend_rt = MIDGARD_COLOR_RT0 + inputs->blend.rt;
|
||||
ctx->blend_input = ~0;
|
||||
ctx->blend_src1 = ~0;
|
||||
ctx->quirks = midgard_get_quirks(gpu_id);
|
||||
ctx->quirks = midgard_get_quirks(inputs->gpu_id);
|
||||
|
||||
/* Start off with a safe cutoff, allowing usage of all 16 work
|
||||
* registers. Later, we'll promote uniform reads to uniform registers
|
||||
|
|
@ -2994,9 +2995,9 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
|
|||
NIR_PASS_V(nir, nir_lower_var_copies);
|
||||
NIR_PASS_V(nir, nir_lower_vars_to_ssa);
|
||||
|
||||
unsigned pan_quirks = panfrost_get_quirks(gpu_id);
|
||||
unsigned pan_quirks = panfrost_get_quirks(inputs->gpu_id);
|
||||
NIR_PASS_V(nir, pan_lower_framebuffer,
|
||||
program->rt_formats, is_blend, pan_quirks);
|
||||
inputs->rt_formats, inputs->is_blend, pan_quirks);
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
|
||||
glsl_type_size, 0);
|
||||
|
|
@ -3005,7 +3006,7 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
|
|||
|
||||
/* Optimisation passes */
|
||||
|
||||
optimise_nir(nir, ctx->quirks, is_blend);
|
||||
optimise_nir(nir, ctx->quirks, inputs->is_blend);
|
||||
|
||||
NIR_PASS_V(nir, midgard_nir_reorder_writeout);
|
||||
|
||||
|
|
@ -3029,7 +3030,7 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
|
|||
ctx->func = func;
|
||||
ctx->already_emitted = calloc(BITSET_WORDS(func->impl->ssa_alloc), sizeof(BITSET_WORD));
|
||||
|
||||
if (nir->info.outputs_read && !is_blend) {
|
||||
if (nir->info.outputs_read && !inputs->is_blend) {
|
||||
emit_block_init(ctx);
|
||||
|
||||
struct midgard_instruction wait = v_branch(false, false);
|
||||
|
|
@ -3143,10 +3144,15 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
|
|||
program->blend_patch_offset = ctx->blend_constant_offset;
|
||||
program->tls_size = ctx->tls_size;
|
||||
|
||||
if ((midgard_debug & MIDGARD_DBG_SHADERS) && !nir->info.internal)
|
||||
disassemble_midgard(stdout, program->compiled.data, program->compiled.size, gpu_id, ctx->stage);
|
||||
if ((midgard_debug & MIDGARD_DBG_SHADERS) && !nir->info.internal) {
|
||||
disassemble_midgard(stdout,
|
||||
program->compiled.data,
|
||||
program->compiled.size,
|
||||
inputs->gpu_id, ctx->stage);
|
||||
}
|
||||
|
||||
if ((midgard_debug & MIDGARD_DBG_SHADERDB || shaderdb) && !nir->info.internal) {
|
||||
if ((midgard_debug & MIDGARD_DBG_SHADERDB || inputs->shaderdb) &&
|
||||
!nir->info.internal) {
|
||||
unsigned nr_bundles = 0, nr_ins = 0;
|
||||
|
||||
/* Count instructions and bundles */
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@
|
|||
#include "panfrost/util/pan_ir.h"
|
||||
|
||||
int
|
||||
midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_blend, unsigned blend_rt, unsigned gpu_id, bool shaderdb);
|
||||
midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program,
|
||||
const struct panfrost_compile_inputs *inputs);
|
||||
|
||||
/* NIR options are shared between the standalone compiler and the online
|
||||
* compiler. Defining it here is the simplest, though maybe not the Right
|
||||
|
|
|
|||
|
|
@ -107,10 +107,19 @@ typedef struct {
|
|||
* (register spilling), or zero if no spilling is used */
|
||||
unsigned tls_size;
|
||||
|
||||
/* IN: Render target formats for output load/store lowering */
|
||||
enum pipe_format rt_formats[8];
|
||||
} panfrost_program;
|
||||
|
||||
struct panfrost_compile_inputs {
|
||||
unsigned gpu_id;
|
||||
bool is_blend;
|
||||
struct {
|
||||
unsigned rt;
|
||||
} blend;
|
||||
bool shaderdb;
|
||||
|
||||
enum pipe_format rt_formats[8];
|
||||
};
|
||||
|
||||
typedef struct pan_block {
|
||||
/* Link to next block. Must be first for mir_get_block */
|
||||
struct list_head link;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue