diff options
author | Eduardo Lima Mitev <[email protected]> | 2017-11-16 00:14:52 +0100 |
---|---|---|
committer | Alejandro PiƱeiro <[email protected]> | 2018-06-21 14:25:05 +0200 |
commit | 2b8765b824cbbdcbbc51033c7ac7a1c3af264244 (patch) | |
tree | 53a5ef1691aa6c6e2eede05c358b3d0c6c0e64db /src/compiler/glsl/gl_nir_lower_samplers.c | |
parent | 652be1563fa6a042d70336431331c75f0f492341 (diff) |
nir/lower_samplers: Limit assert to GLSL shader programs
Vulkan has the concept of separate image and sampler objects in the
SPIR-V code whereas GL conflates them into one. nir_lower_samplers
contains an assert to verify that sampler operand is not being set on
the nir instruction. However when the code comes from spirv_to_nir the
sampler operand is always set. GL_arb_gl_spirv explicitly states that
OpTypeSampler is not supported so it retains the GL behaviour of not
being able to seperate them. Therefore the sampler will always be the
same as the texture. This GL version of the lowering code ignores
instr->sampler and sets instr->sampler_index to the same value as
instr->texture_index. Some other places in the code (such as in
nir_print) assume that once the instruction is lowered then both
instr->texture and instr->sampler will be NULL, so to keep this
behaviour we now set instr->sampler to NULL after ignoring it to fill
in instr->sampler_index.
Signed-off-by: Eduardo Lima <[email protected]>
Signed-off-by: Neil Roberts <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/glsl/gl_nir_lower_samplers.c')
-rw-r--r-- | src/compiler/glsl/gl_nir_lower_samplers.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/glsl/gl_nir_lower_samplers.c b/src/compiler/glsl/gl_nir_lower_samplers.c index a53fabb7e62..c54455f91de 100644 --- a/src/compiler/glsl/gl_nir_lower_samplers.c +++ b/src/compiler/glsl/gl_nir_lower_samplers.c @@ -93,7 +93,7 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr return false; /* In GLSL, we only fill out the texture field. The sampler is inferred */ - assert(instr->sampler == NULL); + assert(instr->sampler == NULL || shader_program->data->spirv); instr->texture_index = 0; unsigned location = instr->texture->var->data.location; @@ -125,6 +125,7 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr instr->sampler_index = instr->texture_index; instr->texture = NULL; + nir_instr_rewrite_deref(&instr->instr, &instr->sampler, NULL); return true; } |