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 719968a6671..cd7e8e39fc9 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. */