mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 22:20:14 +01:00
glsl: fix shader storage block member rules when adding program resources
Commit f24e5e did not take into account arrays of named shader storage blocks. Fixes 20 dEQP-GLES31.functional.ssbo.* tests: dEQP-GLES31.functional.ssbo.layout.single_struct_array.per_block_buffer.shared_instance_array dEQP-GLES31.functional.ssbo.layout.single_struct_array.per_block_buffer.packed_instance_array dEQP-GLES31.functional.ssbo.layout.single_struct_array.per_block_buffer.std140_instance_array dEQP-GLES31.functional.ssbo.layout.single_struct_array.per_block_buffer.std430_instance_array dEQP-GLES31.functional.ssbo.layout.single_struct_array.single_buffer.shared_instance_array dEQP-GLES31.functional.ssbo.layout.single_struct_array.single_buffer.packed_instance_array dEQP-GLES31.functional.ssbo.layout.single_struct_array.single_buffer.std140_instance_array dEQP-GLES31.functional.ssbo.layout.single_struct_array.single_buffer.std430_instance_array dEQP-GLES31.functional.ssbo.layout.single_nested_struct_array.per_block_buffer.shared_instance_array dEQP-GLES31.functional.ssbo.layout.single_nested_struct_array.per_block_buffer.packed_instance_array dEQP-GLES31.functional.ssbo.layout.single_nested_struct_array.per_block_buffer.std140_instance_array dEQP-GLES31.functional.ssbo.layout.single_nested_struct_array.per_block_buffer.std430_instance_array dEQP-GLES31.functional.ssbo.layout.single_nested_struct_array.single_buffer.shared_instance_array dEQP-GLES31.functional.ssbo.layout.single_nested_struct_array.single_buffer.packed_instance_array dEQP-GLES31.functional.ssbo.layout.single_nested_struct_array.single_buffer.std140_instance_array dEQP-GLES31.functional.ssbo.layout.single_nested_struct_array.single_buffer.std430_instance_array dEQP-GLES31.functional.ssbo.layout.random.all_per_block_buffers.2 dEQP-GLES31.functional.ssbo.layout.random.all_per_block_buffers.29 dEQP-GLES31.functional.ssbo.layout.random.all_per_block_buffers.33 dEQP-GLES31.functional.ssbo.layout.random.all_shared_buffer.3 V2: - Rename some variables (Timothy) Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
This commit is contained in:
parent
582ecb3b91
commit
f408a13dd3
1 changed files with 27 additions and 6 deletions
|
|
@ -3137,7 +3137,8 @@ should_add_buffer_variable(struct gl_shader_program *shProg,
|
||||||
GLenum type, const char *name)
|
GLenum type, const char *name)
|
||||||
{
|
{
|
||||||
bool found_interface = false;
|
bool found_interface = false;
|
||||||
const char *block_name = NULL;
|
unsigned block_name_len = 0;
|
||||||
|
const char *block_name_dot = strchr(name, '.');
|
||||||
|
|
||||||
/* These rules only apply to buffer variables. So we return
|
/* These rules only apply to buffer variables. So we return
|
||||||
* true for the rest of types.
|
* true for the rest of types.
|
||||||
|
|
@ -3146,8 +3147,28 @@ should_add_buffer_variable(struct gl_shader_program *shProg,
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (unsigned i = 0; i < shProg->NumBufferInterfaceBlocks; i++) {
|
for (unsigned i = 0; i < shProg->NumBufferInterfaceBlocks; i++) {
|
||||||
block_name = shProg->BufferInterfaceBlocks[i].Name;
|
const char *block_name = shProg->BufferInterfaceBlocks[i].Name;
|
||||||
if (strncmp(block_name, name, strlen(block_name)) == 0) {
|
block_name_len = strlen(block_name);
|
||||||
|
|
||||||
|
const char *block_square_bracket = strchr(block_name, '[');
|
||||||
|
if (block_square_bracket) {
|
||||||
|
/* The block is part of an array of named interfaces,
|
||||||
|
* for the name comparison we ignore the "[x]" part.
|
||||||
|
*/
|
||||||
|
block_name_len -= strlen(block_square_bracket);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block_name_dot) {
|
||||||
|
/* Check if the variable name starts with the interface
|
||||||
|
* name. The interface name (if present) should have the
|
||||||
|
* length than the interface block name we are comparing to.
|
||||||
|
*/
|
||||||
|
unsigned len = strlen(name) - strlen(block_name_dot);
|
||||||
|
if (len != block_name_len)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strncmp(block_name, name, block_name_len) == 0) {
|
||||||
found_interface = true;
|
found_interface = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -3157,7 +3178,7 @@ should_add_buffer_variable(struct gl_shader_program *shProg,
|
||||||
* including the dot that follows it.
|
* including the dot that follows it.
|
||||||
*/
|
*/
|
||||||
if (found_interface)
|
if (found_interface)
|
||||||
name = name + strlen(block_name) + 1;
|
name = name + block_name_len + 1;
|
||||||
|
|
||||||
/* From: ARB_program_interface_query extension:
|
/* From: ARB_program_interface_query extension:
|
||||||
*
|
*
|
||||||
|
|
@ -3166,14 +3187,14 @@ should_add_buffer_variable(struct gl_shader_program *shProg,
|
||||||
* of its type. For arrays of aggregate types, the enumeration rules are
|
* of its type. For arrays of aggregate types, the enumeration rules are
|
||||||
* applied recursively for the single enumerated array element.
|
* applied recursively for the single enumerated array element.
|
||||||
*/
|
*/
|
||||||
const char *first_dot = strchr(name, '.');
|
const char *struct_first_dot = strchr(name, '.');
|
||||||
const char *first_square_bracket = strchr(name, '[');
|
const char *first_square_bracket = strchr(name, '[');
|
||||||
|
|
||||||
/* The buffer variable is on top level and it is not an array */
|
/* The buffer variable is on top level and it is not an array */
|
||||||
if (!first_square_bracket) {
|
if (!first_square_bracket) {
|
||||||
return true;
|
return true;
|
||||||
/* The shader storage block member is a struct, then generate the entry */
|
/* The shader storage block member is a struct, then generate the entry */
|
||||||
} else if (first_dot && first_dot < first_square_bracket) {
|
} else if (struct_first_dot && struct_first_dot < first_square_bracket) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
/* Shader storage block member is an array, only generate an entry for the
|
/* Shader storage block member is an array, only generate an entry for the
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue