diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2019-02-05 19:08:04 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-05-08 16:40:18 -0700 |
commit | 06ca5c0a64c1ab9866b066f2c90f14d08b2810f9 (patch) | |
tree | 26e4d29c27576f13f4b9aba42645ae0f067c10f4 | |
parent | 1a3478dc56a23f545bde85add944cf3a22a1d665 (diff) |
glsl: Allow gl_nir_lower_samplers*() without a gl_shader_program
I would like to be able to run gl_nir_lower_samplers() to turn texture
and sampler variable dereferences into indexes and offsets, even for
ARB programs, and built-in shaders. This would make sampler handling
more consistent across the various types of shaders.
For GLSL programs, the gl_nir_lower_samplers_as_deref() pass looks up
the variable bindings in the shader program's uniform storage. But
ARB programs and built-in shaders don't have a gl_shader_program, and
uniform storage doesn't exist. In this case, we simply skip that
lookup, and trust var->data.binding to be set correctly by whoever
created the shader.
Reviewed-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit d34e434989ec8e8ca780421f6909cfd796573520)
-rw-r--r-- | src/compiler/glsl/gl_nir_lower_samplers_as_deref.c | 14 |
1 files changed, 11 insertions, 3 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 a33486b702f..5d0430c0add 100644 --- a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c +++ b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c @@ -147,10 +147,18 @@ lower_deref(nir_builder *b, struct lower_samplers_as_deref_state *state, remove_struct_derefs_prep(path.path, &name, &location, &type); - assert(location < state->shader_program->data->NumUniformStorage && - state->shader_program->data->UniformStorage[location].opaque[stage].active); + if (state->shader_program) { + /* For GLSL programs, look up the bindings in the uniform storage. */ + assert(location < state->shader_program->data->NumUniformStorage && + state->shader_program->data->UniformStorage[location].opaque[stage].active); - binding = state->shader_program->data->UniformStorage[location].opaque[stage].index; + binding = state->shader_program->data->UniformStorage[location].opaque[stage].index; + } else { + /* For ARB programs or built-in shaders, assume that whoever created + * the shader set the bindings correctly already. + */ + binding = var->data.binding; + } if (var->type == type) { /* Fast path: We did not encounter any struct derefs. */ |