From 92c808cd475c69841eaaf020505208f286ad38cc Mon Sep 17 00:00:00 2001 From: Italo Nicola Date: Wed, 29 Jul 2020 19:10:25 +0000 Subject: [PATCH] pan/mdg: eliminate references to ins->texture.op This commit makes the `ins->op` the correct field to use with texture instructions. Signed-off-by: Italo Nicola Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_compile.c | 5 ++--- src/panfrost/midgard/midgard_derivatives.c | 4 ++-- src/panfrost/midgard/midgard_emit.c | 15 ++++++++++++--- src/panfrost/midgard/midgard_helper_invocations.c | 6 +++--- src/panfrost/midgard/midgard_opt_dce.c | 2 +- src/panfrost/midgard/midgard_ra.c | 2 +- src/panfrost/midgard/midgard_schedule.c | 4 ++-- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 6623fc9ea13..261d3c29df9 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -1600,9 +1600,8 @@ emit_control_barrier(compiler_context *ctx) .type = TAG_TEXTURE_4, .dest = ~0, .src = { ~0, ~0, ~0, ~0 }, + .op = TEXTURE_OP_BARRIER, .texture = { - .op = TEXTURE_OP_BARRIER, - /* TODO: optimize */ .out_of_order = MIDGARD_BARRIER_BUFFER | MIDGARD_BARRIER_SHARED , @@ -2094,8 +2093,8 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr, .dest_type = dest_type, .swizzle = SWIZZLE_IDENTITY_4, .outmod = outmod, + .op = midgard_texop, .texture = { - .op = midgard_texop, .format = midgard_tex_format(instr->sampler_dim), .texture_handle = texture_index, .sampler_handle = sampler_index, diff --git a/src/panfrost/midgard/midgard_derivatives.c b/src/panfrost/midgard/midgard_derivatives.c index 5c01ebaf64a..ca31f0a37ce 100644 --- a/src/panfrost/midgard/midgard_derivatives.c +++ b/src/panfrost/midgard/midgard_derivatives.c @@ -106,8 +106,8 @@ midgard_emit_derivatives(compiler_context *ctx, nir_alu_instr *instr) .src = { ~0, nir_src_index(ctx, &instr->src[0].src), ~0, ~0 }, .swizzle = SWIZZLE_IDENTITY_4, .src_types = { nir_type_float32, nir_type_float32 }, + .op = mir_derivative_op(instr->op), .texture = { - .op = mir_derivative_op(instr->op), .format = MALI_TEX_2D, .in_reg_full = 1, .out_full = 1, @@ -126,7 +126,7 @@ midgard_lower_derivatives(compiler_context *ctx, midgard_block *block) { mir_foreach_instr_in_block_safe(block, ins) { if (ins->type != TAG_TEXTURE_4) continue; - if (!OP_IS_DERIVATIVE(ins->texture.op)) continue; + if (!OP_IS_DERIVATIVE(ins->op)) continue; /* Check if we need to split */ diff --git a/src/panfrost/midgard/midgard_emit.c b/src/panfrost/midgard/midgard_emit.c index 99a26c8618b..a675aa5b31c 100644 --- a/src/panfrost/midgard/midgard_emit.c +++ b/src/panfrost/midgard/midgard_emit.c @@ -487,6 +487,14 @@ mir_lower_roundmode(midgard_instruction *ins) } } +static midgard_texture_word +texture_word_from_instr(midgard_instruction *ins) +{ + midgard_texture_word tex = ins->texture; + tex.op = ins->op; + return tex; +} + static midgard_vector_alu vector_alu_from_instr(midgard_instruction *ins) { @@ -673,7 +681,7 @@ emit_binary_bundle(compiler_context *ctx, ins->texture.next_type = next_tag; /* Nothing else to pack for barriers */ - if (ins->texture.op == TEXTURE_OP_BARRIER) { + if (ins->op == TEXTURE_OP_BARRIER) { ins->texture.cont = ins->texture.last = 1; util_dynarray_append(emission, midgard_texture_word, ins->texture); return; @@ -702,14 +710,15 @@ emit_binary_bundle(compiler_context *ctx, ins->texture.sampler_type = midgard_sampler_type(ins->dest_type); ins->texture.outmod = ins->outmod; - if (mir_op_computes_derivatives(ctx->stage, ins->texture.op)) { + if (mir_op_computes_derivatives(ctx->stage, ins->op)) { ins->texture.cont = !ins->helper_terminate; ins->texture.last = ins->helper_terminate || ins->helper_execute; } else { ins->texture.cont = ins->texture.last = 1; } - util_dynarray_append(emission, midgard_texture_word, ins->texture); + midgard_texture_word texture = texture_word_from_instr(ins); + util_dynarray_append(emission, midgard_texture_word, texture); break; } diff --git a/src/panfrost/midgard/midgard_helper_invocations.c b/src/panfrost/midgard/midgard_helper_invocations.c index 6dfb9c09973..407de6676b9 100644 --- a/src/panfrost/midgard/midgard_helper_invocations.c +++ b/src/panfrost/midgard/midgard_helper_invocations.c @@ -68,7 +68,7 @@ mir_block_uses_helpers(gl_shader_stage stage, midgard_block *block) { mir_foreach_instr_in_block(block, ins) { if (ins->type != TAG_TEXTURE_4) continue; - if (mir_op_computes_derivatives(stage, ins->texture.op)) + if (mir_op_computes_derivatives(stage, ins->op)) return true; } @@ -151,7 +151,7 @@ mir_analyze_helper_terminate(compiler_context *ctx) mir_foreach_instr_in_block_rev(block, ins) { if (ins->type != TAG_TEXTURE_4) continue; - if (!mir_op_computes_derivatives(ctx->stage, ins->texture.op)) continue; + if (!mir_op_computes_derivatives(ctx->stage, ins->op)) continue; ins->helper_terminate = true; break; @@ -197,7 +197,7 @@ mir_analyze_helper_requirements(compiler_context *ctx) mir_foreach_instr_global(ctx, ins) { if (ins->type != TAG_TEXTURE_4) continue; if (ins->dest >= ctx->temp_count) continue; - if (!mir_op_computes_derivatives(ctx->stage, ins->texture.op)) continue; + if (!mir_op_computes_derivatives(ctx->stage, ins->op)) continue; mir_foreach_src(ins, s) { if (ins->src[s] < temp_count) diff --git a/src/panfrost/midgard/midgard_opt_dce.c b/src/panfrost/midgard/midgard_opt_dce.c index 7dec286b5f9..0ae31f014bf 100644 --- a/src/panfrost/midgard/midgard_opt_dce.c +++ b/src/panfrost/midgard/midgard_opt_dce.c @@ -60,7 +60,7 @@ can_dce(midgard_instruction *ins) return false; if (ins->type == TAG_TEXTURE_4) - if (ins->texture.op == TEXTURE_OP_BARRIER) + if (ins->op == TEXTURE_OP_BARRIER) return false; return true; diff --git a/src/panfrost/midgard/midgard_ra.c b/src/panfrost/midgard/midgard_ra.c index 38d280075a5..d212a003f0d 100644 --- a/src/panfrost/midgard/midgard_ra.c +++ b/src/panfrost/midgard/midgard_ra.c @@ -755,7 +755,7 @@ install_registers_instr( } case TAG_TEXTURE_4: { - if (ins->texture.op == TEXTURE_OP_BARRIER) + if (ins->op == TEXTURE_OP_BARRIER) break; /* Grab RA results */ diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index 65e2c2087ea..cee0271718f 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -970,9 +970,9 @@ mir_schedule_texture( mir_update_worklist(worklist, len, instructions, ins); struct midgard_bundle out = { - .tag = ins->texture.op == TEXTURE_OP_BARRIER ? + .tag = ins->op == TEXTURE_OP_BARRIER ? TAG_TEXTURE_4_BARRIER : - (ins->texture.op == TEXTURE_OP_TEXEL_FETCH) || is_vertex ? + (ins->op == TEXTURE_OP_TEXEL_FETCH) || is_vertex ? TAG_TEXTURE_4_VTX : TAG_TEXTURE_4, .instruction_count = 1, .instructions = { ins } -- 2.30.2