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: f003859f97
nir: Make gl_nir_lower_samplers use gl_nir_lower_samplers_as_deref
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Tested-by: Alejandro Piñeiro <apinheiro@igalia.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
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);
|
||||
|
||||
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));
|
||||
/* 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));
|
||||
if (texture_idx >= 0) {
|
||||
assert(instr->src[texture_idx].src.is_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));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user