Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit 63f7d56

Browse files
asimiklitstrassek
authored andcommitted
FROMLIST: glsl: fix a binding points assignment for ssbo/ubo arrays
This is needed to be in agreement with spec requirements: KhronosGroup/OpenGL-API#46 Piers Daniell: "We discussed this in the OpenGL/ES working group meeting and agreed that eliminating unused elements from the interface block array is not desirable. There is no statement in the spec that this takes place and it would be highly implementation dependent if it happens. If the application has an "interface" in the shader they need to match up with the API it would be quite confusing to have the binding point get compacted. So the answer is no, the binding points aren't affected by unused elements in the interface block array." Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109532 Reported-By: Ilia Mirkin <[email protected]> Signed-off-by: Andrii Simiklit <[email protected]> TEST=[CTS 9.0r6} dEQP-GLES31.functional.ssbo.layout.random.all_per_block_buffers#18 (am from https://gitlab.freedesktop.org/mesa/mesa/merge_requests/332) Signed-off-by: Kevin Strasser <[email protected]>
1 parent d2704f7 commit 63f7d56

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/compiler/glsl/link_uniform_block_active_visitor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ process_arrays(void *mem_ctx, ir_dereference_array *ir,
103103
if (*ub_array_ptr == NULL) {
104104
*ub_array_ptr = rzalloc(mem_ctx, struct uniform_block_array_elements);
105105
(*ub_array_ptr)->ir = ir;
106+
(*ub_array_ptr)->original_dim_size = block->type->length;
106107
}
107108

108109
struct uniform_block_array_elements *ub_array = *ub_array_ptr;

src/compiler/glsl/link_uniform_block_active_visitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct uniform_block_array_elements {
3232
unsigned num_array_elements;
3333

3434
ir_dereference_array *ir;
35+
unsigned original_dim_size;
3536

3637
struct uniform_block_array_elements *array;
3738
};

src/compiler/glsl/link_uniform_blocks.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,21 @@ process_block_array(struct uniform_block_array_elements *ub_array, char **name,
244244
for (unsigned j = 0; j < ub_array->num_array_elements; j++) {
245245
size_t new_length = name_length;
246246

247+
unsigned int element_idx = ub_array->array_elements[j];
247248
/* Append the subscript to the current variable name */
248-
ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]",
249-
ub_array->array_elements[j]);
249+
ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]", element_idx);
250250

251251
if (ub_array->array) {
252+
unsigned boffset = (*binding_offset) + (element_idx *
253+
ub_array->original_dim_size);
252254
process_block_array(ub_array->array, name, new_length, blocks,
253255
parcel, variables, b, block_index,
254-
binding_offset, ctx, prog, first_index);
256+
&boffset, ctx, prog, first_index);
255257
} else {
258+
unsigned boffset = (*binding_offset) + element_idx;
256259
process_block_array_leaf(*name, blocks,
257260
parcel, variables, b, block_index,
258-
binding_offset, *block_index - first_index,
261+
&boffset, *block_index - first_index,
259262
ctx, prog);
260263
}
261264
}
@@ -307,7 +310,6 @@ process_block_array_leaf(const char *name,
307310
(unsigned)(ptrdiff_t)(&variables[parcel->index] - blocks[i].Uniforms);
308311

309312
*block_index = *block_index + 1;
310-
*binding_offset = *binding_offset + 1;
311313
}
312314

313315
/* This function resizes the array types of the block so that later we can use

0 commit comments

Comments
 (0)