summaryrefslogtreecommitdiff
path: root/src/panfrost/midgard
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@collabora.com>2020-10-08 10:58:53 +0200
committerMarge Bot <eric+marge@anholt.net>2020-10-09 14:16:41 +0000
commita5005c349d0304b81f0aa8fbea35162d3630adec (patch)
treefc019545e5db25c7ea4f0ef84117095f66dd60c6 /src/panfrost/midgard
parentc9739941ba44337625591d643cf558b9a2b961fc (diff)
panfrost: Get rid of the constant patching done on blend shader binaries
When constants are used in the blend equation we simply recompile the shader. 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>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r--src/panfrost/midgard/compiler.h6
-rw-r--r--src/panfrost/midgard/midgard_compile.c10
-rw-r--r--src/panfrost/midgard/midgard_schedule.c27
3 files changed, 4 insertions, 39 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index b5a37037130..5a93eb325bd 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -140,7 +140,6 @@ typedef struct midgard_instruction {
bool has_constants;
midgard_constants constants;
uint16_t inline_constant;
- bool has_blend_constant;
bool has_inline_constant;
bool compact_branch;
@@ -221,7 +220,6 @@ typedef struct midgard_bundle {
int control;
bool has_embedded_constants;
midgard_constants constants;
- bool has_blend_constant;
bool last_writeout;
} midgard_bundle;
@@ -254,8 +252,8 @@ typedef struct compiler_context {
/* Index to precolour to r2 for a dual-source blend colour */
unsigned blend_src1;
- /* Tracking for blend constant patching */
- int blend_constant_offset;
+ /* Blend constants */
+ float blend_constants[4];
/* Number of bytes used for Thread Local Storage */
unsigned tls_size;
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index d2c08471bc4..7f67fb35537 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -1864,12 +1864,9 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
assert(ctx->is_blend);
reg = nir_dest_index(&instr->dest);
- /* Blend constants are embedded directly in the shader and
- * patched in, so we use some magic routing */
-
midgard_instruction ins = v_mov(SSA_FIXED_REGISTER(REGISTER_CONSTANT), reg);
ins.has_constants = true;
- ins.has_blend_constant = true;
+ memcpy(ins.constants.f32, ctx->blend_constants, sizeof(ctx->blend_constants));
emit_mir_instruction(ctx, ins);
break;
}
@@ -2543,9 +2540,6 @@ embedded_to_inline_constant(compiler_context *ctx, midgard_block *block)
if (!ins->has_constants) continue;
if (ins->has_inline_constant) continue;
- /* Blend constants must not be inlined by definition */
- if (ins->has_blend_constant) continue;
-
unsigned max_bitsize = max_bitsize_for_alu(ins);
/* We can inline 32-bit (sometimes) or 16-bit (usually) */
@@ -2963,6 +2957,7 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program,
ctx->stage = nir->info.stage;
ctx->is_blend = inputs->is_blend;
ctx->blend_rt = MIDGARD_COLOR_RT0 + inputs->blend.rt;
+ memcpy(ctx->blend_constants, inputs->blend.constants, sizeof(ctx->blend_constants));
ctx->blend_input = ~0;
ctx->blend_src1 = ~0;
ctx->quirks = midgard_get_quirks(inputs->gpu_id);
@@ -3141,7 +3136,6 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program,
program->work_register_count = ctx->work_registers + 1;
program->uniform_cutoff = ctx->uniform_cutoff;
- program->blend_patch_offset = ctx->blend_constant_offset;
program->tls_size = ctx->tls_size;
if ((midgard_debug & MIDGARD_DBG_SHADERS) && !nir->info.internal) {
diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c
index 63b1d781298..a5b57a3ab72 100644
--- a/src/panfrost/midgard/midgard_schedule.c
+++ b/src/panfrost/midgard/midgard_schedule.c
@@ -328,7 +328,6 @@ struct midgard_predicate {
midgard_constants *constants;
unsigned constant_mask;
- bool blend_constant;
/* Exclude this destination (if not ~0) */
unsigned exclude;
@@ -437,17 +436,6 @@ mir_adjust_constants(midgard_instruction *ins,
struct midgard_predicate *pred,
bool destructive)
{
- /* Blend constants dominate */
- if (ins->has_blend_constant) {
- if (pred->constant_mask)
- return false;
- else if (destructive) {
- pred->blend_constant = true;
- pred->constant_mask = 0xffff;
- return true;
- }
- }
-
/* No constant, nothing to adjust */
if (!ins->has_constants)
return true;
@@ -1296,7 +1284,6 @@ mir_schedule_alu(
mir_update_worklist(worklist, len, instructions, vmul);
mir_update_worklist(worklist, len, instructions, sadd);
- bundle.has_blend_constant = predicate.blend_constant;
bundle.has_embedded_constants = predicate.constant_mask != 0;
unsigned padding = 0;
@@ -1375,7 +1362,6 @@ schedule_block(compiler_context *ctx, midgard_block *block)
util_dynarray_init(&bundles, NULL);
block->quadword_count = 0;
- unsigned blend_offset = 0;
for (;;) {
unsigned tag = mir_choose_bundle(instructions, liveness, worklist, len);
@@ -1391,10 +1377,6 @@ schedule_block(compiler_context *ctx, midgard_block *block)
break;
util_dynarray_append(&bundles, midgard_bundle, bundle);
-
- if (bundle.has_blend_constant)
- blend_offset = block->quadword_count;
-
block->quadword_count += midgard_tag_props[bundle.tag].size;
}
@@ -1406,15 +1388,6 @@ schedule_block(compiler_context *ctx, midgard_block *block)
}
util_dynarray_fini(&bundles);
- /* Blend constant was backwards as well. blend_offset if set is
- * strictly positive, as an offset of zero would imply constants before
- * any instructions which is invalid in Midgard. TODO: blend constants
- * are broken if you spill since then quadword_count becomes invalid
- * XXX */
-
- if (blend_offset)
- ctx->blend_constant_offset = ((ctx->quadword_count + block->quadword_count) - blend_offset - 1) * 0x10;
-
block->scheduled = true;
ctx->quadword_count += block->quadword_count;