From: Antia Puentes <apuen...@igalia.com> Binding comparison is used to determine the block the uniform is part of. To do the binding comparison we need the information in UniformBlocks[] and ShaderStorageBlocks[] to be available, so we have to call gl_nir_link_uniform_blocks() before linking the uniforms. --- src/compiler/glsl/gl_nir_link_uniforms.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index d266091ba80..77def1a623f 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -454,11 +454,31 @@ nir_link_uniform(struct gl_context *ctx, else uniform->offset = 0; + int buffer_block_index = -1; + /* If the uniform is inside a uniform block determine its block index by + * comparing the bindings, we can not use names. + */ + if (nir_variable_is_in_block(state->current_var)) { + struct gl_uniform_block *blocks = nir_variable_is_in_ssbo(state->current_var) ? + prog->data->ShaderStorageBlocks : prog->data->UniformBlocks; + + int num_blocks = nir_variable_is_in_ssbo(state->current_var) ? + prog->data->NumShaderStorageBlocks : prog->data->NumUniformBlocks; + + for (unsigned i = 0; i < num_blocks; i++) { + if (state->current_var->data.binding == blocks[i].Binding) { + buffer_block_index = i; + } + } + assert(buffer_block_index >= 0); + } + + uniform->block_index = buffer_block_index; + /* @FIXME: the initialization of the following will be done as we * implement support for their specific features, like SSBO, atomics, * etc. */ - uniform->block_index = -1; uniform->builtin = false; uniform->atomic_buffer_index = -1; uniform->top_level_array_size = 0; -- 2.14.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev