diff options
author | Rhys Perry <[email protected]> | 2019-05-29 16:07:44 +0100 |
---|---|---|
committer | Rhys Perry <[email protected]> | 2019-06-04 17:30:53 +0100 |
commit | 73dda85512942e67991a5fbc3c9a1714e7624d00 (patch) | |
tree | 109b51d62c904f8b740f364183717d2afd734878 /src/amd | |
parent | d4a2f8b33bead997e5629eb3f15c3632e930022d (diff) |
ac/nir: mark some texture intrinsics as convergent
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
v3: only mark as convergent in FS and CS with derivative groups
Cc: <[email protected]>
Signed-off-by: Rhys Perry <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 833b1e54abc..dd673cf5ea0 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -38,6 +38,7 @@ struct ac_nir_context { struct ac_shader_abi *abi; gl_shader_stage stage; + shader_info *info; LLVMValueRef *ssa_defs; @@ -1394,6 +1395,22 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, } args->attributes = AC_FUNC_ATTR_READNONE; + bool cs_derivs = ctx->stage == MESA_SHADER_COMPUTE && + ctx->info->cs.derivative_group != DERIVATIVE_GROUP_NONE; + if (ctx->stage == MESA_SHADER_FRAGMENT || cs_derivs) { + /* 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); } @@ -4354,6 +4371,7 @@ void ac_nir_translate(struct ac_llvm_context *ac, struct ac_shader_abi *abi, ctx.abi = abi; ctx.stage = nir->info.stage; + ctx.info = &nir->info; ctx.main_function = LLVMGetBasicBlockParent(LLVMGetInsertBlock(ctx.ac.builder)); |