summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2019-01-10 11:10:13 -0800
committerKenneth Graunke <[email protected]>2019-01-11 07:54:32 -0800
commitae683ed3bce6ae7d22fcc8e5ef844b1e0f26b93b (patch)
tree7c52c9dbdb430cab6e76da3eee5848bc0f3acfea /src/compiler
parente12b0b5c6d0e957388b3f902d064e800decfa603 (diff)
nir: Allow a non-existent sampler deref in nir_lower_samplers_as_deref
GL_ARB_gl_spirv does not provide a sampler deref for e.g. texelFetch(), so we can't assume that both are present and identical. Simply lower each if it is present. Fixes regressions in GL_ARB_gl_spirv tests since I switched everyone to using this pass. Thanks to Alejandro Piñeiro for catching these. Fixes: f003859f97c nir: Make gl_nir_lower_samplers use gl_nir_lower_samplers_as_deref Reviewed-by: Jason Ekstrand <[email protected]> Tested-by: Alejandro Piñeiro <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/gl_nir_lower_samplers_as_deref.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
index 96c751a1284..719968a6671 100644
--- a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
+++ b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
@@ -196,28 +196,30 @@ lower_sampler(nir_tex_instr *instr, struct lower_samplers_as_deref_state *state,
int sampler_idx =
nir_tex_instr_src_index(instr, nir_tex_src_sampler_deref);
- if (texture_idx < 0)
- return false;
+ b->cursor = nir_before_instr(&instr->instr);
- assert(texture_idx >= 0 && sampler_idx >= 0);
- assert(instr->src[texture_idx].src.is_ssa);
- assert(instr->src[sampler_idx].src.is_ssa);
- assert(instr->src[texture_idx].src.ssa == instr->src[sampler_idx].src.ssa);
+ if (texture_idx >= 0) {
+ assert(instr->src[texture_idx].src.is_ssa);
- b->cursor = nir_before_instr(&instr->instr);
+ nir_deref_instr *texture_deref =
+ lower_deref(b, state, nir_src_as_deref(instr->src[texture_idx].src));
+ /* only lower non-bindless: */
+ if (texture_deref) {
+ nir_instr_rewrite_src(&instr->instr, &instr->src[texture_idx].src,
+ nir_src_for_ssa(&texture_deref->dest.ssa));
+ }
+ }
- nir_deref_instr *texture_deref =
- lower_deref(b, state, nir_src_as_deref(instr->src[texture_idx].src));
- /* don't lower bindless: */
- if (!texture_deref)
- return false;
- nir_instr_rewrite_src(&instr->instr, &instr->src[texture_idx].src,
- nir_src_for_ssa(&texture_deref->dest.ssa));
-
- nir_deref_instr *sampler_deref =
- lower_deref(b, state, nir_src_as_deref(instr->src[sampler_idx].src));
- nir_instr_rewrite_src(&instr->instr, &instr->src[sampler_idx].src,
- nir_src_for_ssa(&sampler_deref->dest.ssa));
+ if (sampler_idx >= 0) {
+ assert(instr->src[sampler_idx].src.is_ssa);
+ nir_deref_instr *sampler_deref =
+ lower_deref(b, state, nir_src_as_deref(instr->src[sampler_idx].src));
+ /* only lower non-bindless: */
+ if (sampler_deref) {
+ nir_instr_rewrite_src(&instr->instr, &instr->src[sampler_idx].src,
+ nir_src_for_ssa(&sampler_deref->dest.ssa));
+ }
+ }
return true;
}