<div dir="ltr"><div class="gmail_quote"><div class="gmail_attr">The first and last hunks look like they shouldn't be there. Other than that:</div><div class="gmail_attr"><br></div><div class="gmail_attr">Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>></div><div class="gmail_attr"><br></div><div class="gmail_attr">Marek<br></div><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">On Fri, May 31, 2019 at 11:53 AM Rhys Perry <<a href="mailto:pendingchaos02@gmail.com">pendingchaos02@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Otherwise LLVM can sink them and their texture coordinate calculations<br>
into divergent branches.<br>
<br>
v2: simplify the conditions on which the intrinsic is marked as convergent<br>
v3: only mark as convergent in FS and CS with derivative groups<br>
<br>
Cc: <<a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop.org</a>><br>
Signed-off-by: Rhys Perry <<a href="mailto:pendingchaos02@gmail.com" target="_blank">pendingchaos02@gmail.com</a>><br>
---<br>
src/amd/common/ac_nir_to_llvm.c | 18 ++++++++++++++++++<br>
1 file changed, 18 insertions(+)<br>
<br>
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c<br>
index 265e3b636c4..9e9fade7227 100644<br>
--- a/src/amd/common/ac_nir_to_llvm.c<br>
+++ b/src/amd/common/ac_nir_to_llvm.c<br>
@@ -38,6 +38,7 @@ struct ac_nir_context {<br>
struct ac_shader_abi *abi;<br>
<br>
gl_shader_stage stage;<br>
+ shader_info *info;<br>
<br>
LLVMValueRef *ssa_defs;<br>
<br>
@@ -1394,6 +1395,22 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx,<br>
}<br>
<br>
args->attributes = AC_FUNC_ATTR_READNONE;<br>
+ bool cs_derivs = ctx->stage == MESA_SHADER_COMPUTE &&<br>
+ ctx->info->cs.derivative_group != DERIVATIVE_GROUP_NONE;<br>
+ if (ctx->stage == MESA_SHADER_FRAGMENT || cs_derivs) {<br>
+ /* Prevent texture instructions with implicit derivatives from being<br>
+ * sinked into branches. */<br>
+ switch (instr->op) {<br>
+ case nir_texop_tex:<br>
+ case nir_texop_txb:<br>
+ case nir_texop_lod:<br>
+ args->attributes |= AC_FUNC_ATTR_CONVERGENT;<br>
+ break;<br>
+ default:<br>
+ break;<br>
+ }<br>
+ }<br>
+<br>
return ac_build_image_opcode(&ctx->ac, args);<br>
}<br>
<br>
@@ -4350,6 +4367,7 @@ void ac_nir_translate(struct ac_llvm_context *ac, struct ac_shader_abi *abi,<br>
ctx.abi = abi;<br>
<br>
ctx.stage = nir->info.stage;<br>
+ <a href="http://ctx.info" rel="noreferrer" target="_blank">ctx.info</a> = &nir->info;<br>
<br>
ctx.main_function = LLVMGetBasicBlockParent(LLVMGetInsertBlock(<a href="http://ctx.ac" target="_blank">ctx.ac</a>.builder));<br>
<br>
-- <br>
2.21.0<br>
<br>
</blockquote></div></div>