ttn: Fix number of components for IF/UIF
authorConnor Abbott <cwabbott0@gmail.com>
Thu, 1 Oct 2020 09:02:41 +0000 (11:02 +0200)
committerConnor Abbott <cwabbott0@gmail.com>
Thu, 1 Oct 2020 13:47:07 +0000 (15:47 +0200)
NIR if statements only take one component, but TGSI registers are vec4.
We're supposed to compare the x component, per
https://docs.mesa3d.org/gallium/tgsi.html#opcode-IF.

Fixes: f103bded ("ttn: Use nir control flow insertion helpers")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Tested-by: Leo Liu <leo.liu@amd.com>
Closes: #3585
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6956>

src/gallium/auxiliary/nir/tgsi_to_nir.c

index 4f9705f..37b21fc 100644 (file)
@@ -2122,11 +2122,11 @@ ttn_emit_instruction(struct ttn_compile *c)
       break;
 
    case TGSI_OPCODE_IF:
-      nir_push_if(b, nir_fneu(b, src[0], nir_imm_float(b, 0.0)));
+      nir_push_if(b, nir_fneu(b, nir_channel(b, src[0], 0), nir_imm_float(b, 0.0)));
       break;
 
    case TGSI_OPCODE_UIF:
-      nir_push_if(b, nir_ine(b, src[0], nir_imm_int(b, 0)));
+      nir_push_if(b, nir_ine(b, nir_channel(b, src[0], 0), nir_imm_int(b, 0)));
       break;
 
    case TGSI_OPCODE_ELSE: