[Mesa-stable] [PATCH] ac/nir: mark some texture intrinsics as convergent
Rhys Perry
pendingchaos02 at gmail.com
Thu May 30 16:50:13 UTC 2019
Otherwise LLVM can sink them and their texture coordinate calculations
into divergent branches.
Cc: <mesa-stable at lists.freedesktop.org>
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
---
src/amd/common/ac_nir_to_llvm.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 265e3b636c4..d2dc617de36 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -1316,6 +1316,30 @@ static nir_deref_instr *get_tex_texture_deref(const nir_tex_instr *instr)
return texture_deref_instr;
}
+static bool has_implicit_derivatives(const nir_tex_instr *instr)
+{
+ switch (instr->op) {
+ case nir_texop_txs:
+ case nir_texop_query_levels:
+ case nir_texop_texture_samples:
+ case nir_texop_samples_identical:
+ return false;
+ default:
+ break;
+ }
+ for (unsigned i = 0; i < instr->num_srcs; i++) {
+ switch (instr->src[i].src_type) {
+ case nir_tex_src_lod:
+ case nir_tex_src_ddx:
+ case nir_tex_src_ddy:
+ return false;
+ default:
+ break;
+ }
+ }
+ return true;
+}
+
static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx,
const nir_tex_instr *instr,
struct ac_image_args *args)
@@ -1394,6 +1418,11 @@ 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. */
+ if (has_implicit_derivatives(instr))
+ args->attributes |= AC_FUNC_ATTR_CONVERGENT;
+
return ac_build_image_opcode(&ctx->ac, args);
}
--
2.21.0
More information about the mesa-stable
mailing list