glsl: correctly find block index when linking glsl with nir linker
The existing code for spirv expects all vars to have explicit bindings set which is not true for glsl. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
This commit is contained in:
committed by
Marge Bot
parent
10b816d27e
commit
a02d8e040f
@@ -768,10 +768,36 @@ nir_link_uniform(struct gl_context *ctx,
|
||||
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;
|
||||
break;
|
||||
if (!prog->data->spirv) {
|
||||
bool is_interface_array =
|
||||
glsl_without_array(state->current_var->type) == state->current_var->interface_type &&
|
||||
glsl_type_is_array(state->current_var->type);
|
||||
|
||||
const char *ifc_name =
|
||||
glsl_get_type_name(state->current_var->interface_type);
|
||||
if (is_interface_array) {
|
||||
unsigned l = strlen(ifc_name);
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
if (strncmp(ifc_name, blocks[i].Name, l) == 0 &&
|
||||
blocks[i].Name[l] == '[') {
|
||||
buffer_block_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
if (strcmp(ifc_name, blocks[i].Name) == 0) {
|
||||
buffer_block_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
if (state->current_var->data.binding == blocks[i].Binding) {
|
||||
buffer_block_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(buffer_block_index >= 0);
|
||||
|
||||
Reference in New Issue
Block a user