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++) {
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