diff options
author | Marek Olšák <[email protected]> | 2019-04-08 17:20:13 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-04-25 18:57:38 -0400 |
commit | c5f65bfe6c9b82925d65ba677664cfc063a9b96c (patch) | |
tree | ce9d413e77031dba55385abe03ad20f68b1ff75a | |
parent | a6ab27dcabb959d2a793e6217816f04292fcf339 (diff) |
glsl: fix shader_storage_blocks_write_access for SSBO block arrays (v2)
This fixes KHR-GL45.compute_shader.resources-max on radeonsi.
Fixes: 4e1e8f684bf "glsl: remember which SSBOs are not read-only and pass it to gallium"
v2: use is_interface_array, protect again assertion failures in u_bit_consecutive
Reviewed-by: Dave Airlie <[email protected]>
-rw-r--r-- | src/compiler/glsl/link_uniforms.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp index ef124111991..aa96227a7e1 100644 --- a/src/compiler/glsl/link_uniforms.cpp +++ b/src/compiler/glsl/link_uniforms.cpp @@ -522,8 +522,10 @@ public: prog->data->ShaderStorageBlocks : prog->data->UniformBlocks; unsigned num_blks = var->is_in_shader_storage_block() ? prog->data->NumShaderStorageBlocks : prog->data->NumUniformBlocks; + bool is_interface_array = + var->is_interface_instance() && var->type->is_array(); - if (var->is_interface_instance() && var->type->is_array()) { + if (is_interface_array) { unsigned l = strlen(var->get_interface_type()->name); for (unsigned i = 0; i < num_blks; i++) { @@ -544,8 +546,22 @@ public: assert(buffer_block_index != -1); if (var->is_in_shader_storage_block() && - !var->data.memory_read_only) - shader_storage_blocks_write_access |= 1 << buffer_block_index; + !var->data.memory_read_only) { + unsigned array_size = is_interface_array ? + var->type->array_size() : 1; + + STATIC_ASSERT(MAX_SHADER_STORAGE_BUFFERS <= 32); + + /* Shaders that use too many SSBOs will fail to compile, which + * we don't care about. + * + * This is true for shaders that do not use too many SSBOs: + */ + if (buffer_block_index + array_size <= 32) { + shader_storage_blocks_write_access |= + u_bit_consecutive(buffer_block_index, array_size); + } + } /* Uniform blocks that were specified with an instance name must be * handled a little bit differently. The name of the variable is the |