pan/mdg: eliminate references to ins->texture.op
authorItalo Nicola <italonicola@collabora.com>
Wed, 29 Jul 2020 19:10:25 +0000 (19:10 +0000)
committerMarge Bot <eric+marge@anholt.net>
Thu, 30 Jul 2020 22:55:36 +0000 (22:55 +0000)
This commit makes the `ins->op` the correct field to use with texture
instructions.

Signed-off-by: Italo Nicola <italonicola@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5933>

src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_derivatives.c
src/panfrost/midgard/midgard_emit.c
src/panfrost/midgard/midgard_helper_invocations.c
src/panfrost/midgard/midgard_opt_dce.c
src/panfrost/midgard/midgard_ra.c
src/panfrost/midgard/midgard_schedule.c

index 6623fc9ea137f424c2bcd696bae8fdad694760b0..261d3c29df9f3818de9b8e5625b24711a3a5abfe 100644 (file)
@@ -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,
index 5c01ebaf64a0cd0746923350742c69e739e165f2..ca31f0a37ce58e0318187972e130b8f150e78847 100644 (file)
@@ -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 */
 
index 99a26c8618bde2753d2792e2fcde9bb8e5052b39..a675aa5b31c8f0a5bcd7b69d1fe6ac2a5fa77506 100644 (file)
@@ -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;
         }
 
index 6dfb9c099735c386a15921de80af505c953a94db..407de6676b90c127d20c8ddfd9a87db2cd9831a2 100644 (file)
@@ -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)
index 7dec286b5f92284ab933242b06ce8bff7482367f..0ae31f014bfc96ce42e968d6d022bac968556eab 100644 (file)
@@ -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;
index 38d280075a58389c2e6a164396cdea83851f159d..d212a003f0df8ee116d4133c54164fa8c4766f2c 100644 (file)
@@ -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 */
index 65e2c2087eabae55d1fb9e2e3479c3332180a486..cee0271718f0d791955ac32cac9dbec943687850 100644 (file)
@@ -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 }