Otherwise LLVM can sink them and their texture coordinate calculations
into divergent branches.

v2: simplify the conditions on which the intrinsic is marked as convergent

Cc: <mesa-sta...@lists.freedesktop.org>
Signed-off-by: Rhys Perry <pendingchao...@gmail.com>
Reviewed-By: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
---
 src/amd/common/ac_nir_to_llvm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 265e3b636c4..b1a191ac24c 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -1394,6 +1394,18 @@ static LLVMValueRef build_tex_intrinsic(struct 
ac_nir_context *ctx,
        }
 
        args->attributes = AC_FUNC_ATTR_READNONE;
+       /* Prevent texture instructions with implicit derivatives from being
+        * sinked into branches. */
+       switch (instr->op) {
+       case nir_texop_tex:
+       case nir_texop_txb:
+       case nir_texop_lod:
+               args->attributes |= AC_FUNC_ATTR_CONVERGENT;
+               break;
+       default:
+               break;
+       }
+
        return ac_build_image_opcode(&ctx->ac, args);
 }
 
-- 
2.21.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to