Mesa (main): nir_to_tgsi: Fix assertion failures handling 64-bit vec3/vec4 ssa undefs.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 19 20:44:23 UTC 2022


Module: Mesa
Branch: main
Commit: 21282879f95d7d042eb86d6a8207451623db1123
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=21282879f95d7d042eb86d6a8207451623db1123

Author: Emma Anholt <emma at anholt.net>
Date:   Wed Mar 30 15:57:34 2022 -0700

nir_to_tgsi: Fix assertion failures handling 64-bit vec3/vec4 ssa undefs.

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 at itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16043>

---

 src/gallium/auxiliary/nir/nir_to_tgsi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c
index 50e53e4a350..5a3f0065e6c 100644
--- a/src/gallium/auxiliary/nir/nir_to_tgsi.c
+++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c
@@ -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;



More information about the mesa-commit mailing list