summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <[email protected]>2019-04-05 16:04:40 -0700
committerCaio Marcelo de Oliveira Filho <[email protected]>2019-04-08 19:29:33 -0700
commitfcbc5ccaae6e606e68199c838e23545b4283b788 (patch)
treec6c1bec5617ba394c190d74184c6593be5ce5cfc /src/compiler
parentd08a74d2bf12721f450098cfac300b4f5bcc5dfc (diff)
nir: Don't set LOD=0 for compute shader that has derivative group
When using NV_compute_shader_derivatives to set a derivative group, a compute shader supports texture with implicit LOD calculation, so don't set an explicit LOD. Note if the extension is used but the derivative group is not specified, it will default to LOD=0 as before. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_lower_tex.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index eee1b3105d5..54db7b761cb 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -1111,14 +1111,18 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
continue;
}
+ bool shader_supports_implicit_lod =
+ b->shader->info.stage == MESA_SHADER_FRAGMENT ||
+ (b->shader->info.stage == MESA_SHADER_COMPUTE &&
+ b->shader->info.cs.derivative_group != DERIVATIVE_GROUP_NONE);
+
/* TXF, TXS and TXL require a LOD but not everything we implement using those
* three opcodes provides one. Provide a default LOD of 0.
*/
if ((nir_tex_instr_src_index(tex, nir_tex_src_lod) == -1) &&
(tex->op == nir_texop_txf || tex->op == nir_texop_txs ||
tex->op == nir_texop_txl || tex->op == nir_texop_query_levels ||
- (tex->op == nir_texop_tex &&
- b->shader->info.stage != MESA_SHADER_FRAGMENT))) {
+ (tex->op == nir_texop_tex && !shader_supports_implicit_lod))) {
b->cursor = nir_before_instr(&tex->instr);
nir_tex_instr_add_src(tex, nir_tex_src_lod, nir_src_for_ssa(nir_imm_int(b, 0)));
progress = true;