aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/link_uniforms.cpp
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-04-02 13:54:06 +1100
committerTimothy Arceri <[email protected]>2016-04-02 17:10:56 +1100
commit0fbd073dc284f952ea7df691941a65ddc89b7554 (patch)
tree81861dfddfa834221dc8e3f57bb7c08839dc5de2 /src/compiler/glsl/link_uniforms.cpp
parent1265e1c4e17dec5c9931fda8b6d44a4006ed1a4c (diff)
glsl: store ubo or ssbo index in block index
Previously we store the buffer block index i.e the index of a combined ubo/ssbo list. Fixes several dEQP-GLES31.functional tests: - program_interface_query.uniform.block_index.block_array - program_interface_query.uniform.block_index.named_block - program_interface_query.uniform.block_index.unnamed_block - program_interface_query.uniform.random.10 - program_interface_query.uniform.random.15 - program_interface_query.uniform.random.22 - program_interface_query.uniform.random.24 - program_interface_query.uniform.random.26 - program_interface_query.uniform.random.28 - program_interface_query.uniform.random.3 - program_interface_query.uniform.random.31 - program_interface_query.uniform.random.38 - program_interface_query.uniform.random.5 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94116 Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/glsl/link_uniforms.cpp')
-rw-r--r--src/compiler/glsl/link_uniforms.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp
index 0a230cad034..43ff52522ee 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -460,30 +460,33 @@ public:
field_counter = 0;
this->record_next_sampler = new string_to_uint_map;
- ubo_block_index = -1;
+ buffer_block_index = -1;
if (var->is_in_buffer_block()) {
+ struct gl_uniform_block **blks = var->is_in_shader_storage_block() ?
+ prog->ShaderStorageBlocks : prog->UniformBlocks;
+ unsigned num_blks = var->is_in_shader_storage_block() ?
+ prog->NumShaderStorageBlocks : prog->NumUniformBlocks;
+
if (var->is_interface_instance() && var->type->is_array()) {
unsigned l = strlen(var->get_interface_type()->name);
- for (unsigned i = 0; i < prog->NumBufferInterfaceBlocks; i++) {
- if (strncmp(var->get_interface_type()->name,
- prog->BufferInterfaceBlocks[i].Name,
- l) == 0
- && prog->BufferInterfaceBlocks[i].Name[l] == '[') {
- ubo_block_index = i;
+ for (unsigned i = 0; i < num_blks; i++) {
+ if (strncmp(var->get_interface_type()->name, blks[i]->Name, l)
+ == 0 && blks[i]->Name[l] == '[') {
+ buffer_block_index = i;
break;
}
}
} else {
- for (unsigned i = 0; i < prog->NumBufferInterfaceBlocks; i++) {
- if (strcmp(var->get_interface_type()->name,
- prog->BufferInterfaceBlocks[i].Name) == 0) {
- ubo_block_index = i;
+ for (unsigned i = 0; i < num_blks; i++) {
+ if (strcmp(var->get_interface_type()->name, blks[i]->Name) ==
+ 0) {
+ buffer_block_index = i;
break;
}
}
}
- assert(ubo_block_index != -1);
+ assert(buffer_block_index != -1);
/* Uniform blocks that were specified with an instance name must be
* handled a little bit differently. The name of the variable is the
@@ -497,7 +500,7 @@ public:
var->get_interface_type()->name);
} else {
const struct gl_uniform_block *const block =
- &prog->BufferInterfaceBlocks[ubo_block_index];
+ blks[buffer_block_index];
assert(var->data.location != -1);
@@ -519,7 +522,7 @@ public:
delete this->record_next_sampler;
}
- int ubo_block_index;
+ int buffer_block_index;
int ubo_byte_offset;
gl_shader_stage shader_type;
@@ -659,7 +662,7 @@ private:
virtual void enter_record(const glsl_type *type, const char *,
bool row_major, const unsigned packing) {
assert(type->is_record());
- if (this->ubo_block_index == -1)
+ if (this->buffer_block_index == -1)
return;
if (packing == GLSL_INTERFACE_PACKING_STD430)
this->ubo_byte_offset = glsl_align(
@@ -672,7 +675,7 @@ private:
virtual void leave_record(const glsl_type *type, const char *,
bool row_major, const unsigned packing) {
assert(type->is_record());
- if (this->ubo_block_index == -1)
+ if (this->buffer_block_index == -1)
return;
if (packing == GLSL_INTERFACE_PACKING_STD430)
this->ubo_byte_offset = glsl_align(
@@ -719,7 +722,7 @@ private:
/* For array of arrays or struct arrays the base location may have
* already been set so don't set it again.
*/
- if (ubo_block_index == -1 && current_var->data.location == -1) {
+ if (buffer_block_index == -1 && current_var->data.location == -1) {
current_var->data.location = id;
}
@@ -766,8 +769,8 @@ private:
this->uniforms[id].is_shader_storage =
current_var->is_in_shader_storage_block();
- if (this->ubo_block_index != -1) {
- this->uniforms[id].block_index = this->ubo_block_index;
+ if (this->buffer_block_index != -1) {
+ this->uniforms[id].block_index = this->buffer_block_index;
unsigned alignment = type->std140_base_alignment(row_major);
if (packing == GLSL_INTERFACE_PACKING_STD430)