nir_to_tgsi: Fix assertion failures handling 64-bit vec3/vec4 ssa undefs.
authorEmma Anholt <emma@anholt.net>
Wed, 30 Mar 2022 22:57:34 +0000 (15:57 -0700)
committerMarge Bot <emma+marge@anholt.net>
Tue, 19 Apr 2022 20:05:41 +0000 (20:05 +0000)
Found in virgl, where a glslparsertest accidentally gets its inputs
lowered to undefs, and 64-bit undefs don't get split by the normal
alu/intrinsic splitter (and would be hard to split because other passes
would see reconstruction of the vec4 from undefs and turn it back into
vec3/vec4 undef).

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16043>

src/gallium/auxiliary/nir/nir_to_tgsi.c

index 50e53e4..5a3f006 100644 (file)
@@ -1160,7 +1160,12 @@ ntt_get_alu_src(struct ntt_compile *c, nir_alu_instr *instr, int i)
    nir_alu_src src = instr->src[i];
    struct ureg_src usrc = ntt_get_src(c, src.src);
 
-   if (nir_src_bit_size(src.src) == 64) {
+   /* Expand double/dvec2 src references to TGSI swizzles using a pair of 32-bit
+    * channels.  We skip this for undefs, as those don't get split to vec2s (but
+    * the specific swizzles from an undef don't matter)
+    */
+   if (nir_src_bit_size(src.src) == 64 &&
+      !(src.src.is_ssa && src.src.ssa->parent_instr->type == nir_instr_type_ssa_undef)) {
       int chan0 = 0, chan1 = 1;
       if (nir_op_infos[instr->op].input_sizes[i] == 0) {
          chan0 = ffs(instr->dest.write_mask) - 1;