r600/sfn: clean up TF emission in TCS
authorGert Wollny <gert.wollny@collabora.com>
Thu, 8 Dec 2022 09:13:39 +0000 (10:13 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 9 Dec 2022 08:26:31 +0000 (08:26 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20205>

src/gallium/drivers/r600/sfn/sfn_nir_lower_tess_io.cpp
src/gallium/drivers/r600/sfn/sfn_shader_tess.cpp

index 886b64c..0e1a6ee 100644 (file)
@@ -588,23 +588,28 @@ r600_append_tcs_TF_emission(nir_shader *shader, enum pipe_prim_type prim_type)
    if (prim_type == PIPE_PRIM_LINES)
       std::swap(chanx, chany);
 
-   auto v0 = nir_vec4(b,
-                      out_addr0,
-                      nir_channel(b, &tf_outer->dest.ssa, chanx),
-                      nir_iadd(b, out_addr0, nir_imm_int(b, 4)),
-                      nir_channel(b, &tf_outer->dest.ssa, chany));
+   int inner_base = 12;
+
+   tf_out.push_back(nir_vec2(b,
+                             out_addr0,
+                             nir_channel(b, &tf_outer->dest.ssa, chanx)));
+
+   tf_out.push_back(nir_vec2(b, nir_iadd(b, out_addr0, nir_imm_int(b, 4)),
+                             nir_channel(b, &tf_outer->dest.ssa, chany)));
+
 
-   tf_out.push_back(v0);
    if (outer_comps > 2) {
-      auto v1 = (outer_comps > 3) ? nir_vec4(b,
-                                             nir_iadd(b, out_addr0, nir_imm_int(b, 8)),
-                                             nir_channel(b, &tf_outer->dest.ssa, 2),
-                                             nir_iadd(b, out_addr0, nir_imm_int(b, 12)),
-                                             nir_channel(b, &tf_outer->dest.ssa, 3))
-                                  : nir_vec2(b,
-                                             nir_iadd(b, out_addr0, nir_imm_int(b, 8)),
-                                             nir_channel(b, &tf_outer->dest.ssa, 2));
-      tf_out.push_back(v1);
+      tf_out.push_back(nir_vec2(b,
+                                nir_iadd(b, out_addr0, nir_imm_int(b, 8)),
+                                nir_channel(b, &tf_outer->dest.ssa, 2)));
+   }
+
+   if (outer_comps > 3) {
+      tf_out.push_back(nir_vec2(b,
+                                nir_iadd(b, out_addr0, nir_imm_int(b, 12)),
+                                nir_channel(b, &tf_outer->dest.ssa, 3)));
+      inner_base = 16;
+
    }
 
    if (inner_comps) {
@@ -617,15 +622,17 @@ r600_append_tcs_TF_emission(nir_shader *shader, enum pipe_prim_type prim_type)
          &tf_inner->instr, &tf_inner->dest, tf_inner->num_components, 32, NULL);
       nir_builder_instr_insert(b, &tf_inner->instr);
 
-      auto v2 = (inner_comps > 1) ? nir_vec4(b,
-                                             nir_iadd(b, out_addr0, nir_imm_int(b, 16)),
-                                             nir_channel(b, &tf_inner->dest.ssa, 0),
-                                             nir_iadd(b, out_addr0, nir_imm_int(b, 20)),
-                                             nir_channel(b, &tf_inner->dest.ssa, 1))
-                                  : nir_vec2(b,
-                                             nir_iadd(b, out_addr0, nir_imm_int(b, 12)),
-                                             nir_channel(b, &tf_inner->dest.ssa, 0));
-      tf_out.push_back(v2);
+      tf_out.push_back(nir_vec2(b,
+                                nir_iadd(b, out_addr0, nir_imm_int(b, inner_base)),
+                                nir_channel(b, &tf_inner->dest.ssa, 0)));
+
+
+      if (inner_comps > 1) {
+         tf_out.push_back(nir_vec2(b,
+                                   nir_iadd(b, out_addr0, nir_imm_int(b, inner_base + 4)),
+                                   nir_channel(b, &tf_inner->dest.ssa, 1)));
+
+      }
    }
 
    for (auto tf : tf_out)
index ccc0797..bb4ab86 100644 (file)
@@ -114,27 +114,7 @@ TCSShader::process_stage_intrinsic(nir_intrinsic_instr *instr)
 bool
 TCSShader::store_tess_factor(nir_intrinsic_instr *instr)
 {
-   bool two_parts = nir_src_num_components(instr->src[0]) == 4;
-
-   auto value0 = value_factory().temp_vec4(pin_group, {0, 1, 7, 7});
-   emit_instruction(new AluInstr(
-      op1_mov, value0[0], value_factory().src(instr->src[0], 0), AluInstr::write));
-   emit_instruction(new AluInstr(op1_mov,
-                                 value0[1],
-                                 value_factory().src(instr->src[0], 1),
-                                 two_parts ? AluInstr::write : AluInstr::last_write));
-
-   if (two_parts) {
-      auto value1 = value_factory().temp_vec4(pin_group, {2, 3, 7, 7});
-      emit_instruction(new AluInstr(
-         op1_mov, value1[0], value_factory().src(instr->src[0], 2), AluInstr::write));
-      emit_instruction(new AluInstr(op1_mov,
-                                    value1[1],
-                                    value_factory().src(instr->src[0], 3),
-                                    AluInstr::last_write));
-      emit_instruction(new WriteTFInstr(value1));
-   }
-
+   auto value0 = value_factory().src_vec4(instr->src[0], pin_group, {0, 1, 7, 7});
    emit_instruction(new WriteTFInstr(value0));
    return true;
 }