r600/sfn: Make sure all components are usable when lowering TF inputs
authorGert Wollny <gert.wollny@collabora.com>
Wed, 5 Oct 2022 14:48:27 +0000 (16:48 +0200)
committerGert Wollny <gert.wollny@collabora.com>
Fri, 7 Oct 2022 09:33:57 +0000 (11:33 +0200)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18983>

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

index 39cb346..cfcd060 100644 (file)
@@ -412,8 +412,16 @@ r600_lower_tess_io_impl(nir_builder *b, nir_instr *instr, enum pipe_prim_type pr
       nir_ssa_dest_init(&tf->instr, &tf->dest,
                         tf->num_components, 32, NULL);
       nir_builder_instr_insert(b, &tf->instr);
-
-      nir_ssa_def_rewrite_uses(&op->dest.ssa, &tf->dest.ssa);
+      if (ncomps < 4) {
+         auto undef = nir_ssa_undef(b, 1, 32);
+         nir_ssa_def *srcs[4] = {undef, undef, undef, undef};
+         for (unsigned i = 0; i < ncomps; ++i)
+            srcs[i] = nir_channel(b, &tf->dest.ssa, i);
+         auto help = nir_vec(b, srcs, 4);
+         nir_ssa_def_rewrite_uses(&op->dest.ssa, help);
+      } else {
+         nir_ssa_def_rewrite_uses(&op->dest.ssa, &tf->dest.ssa);
+      }
       nir_instr_remove(instr);
       return true;
    }