+ void set_and_process(struct gl_shader_program *prog,
+ ir_variable *var)
+ {
+ ubo_block_index = -1;
+ if (var->is_in_uniform_block()) {
+ if (var->is_interface_instance() && var->type->is_array()) {
+ unsigned l = strlen(var->interface_type->name);
+
+ for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+ if (strncmp(var->interface_type->name,
+ prog->UniformBlocks[i].Name,
+ l) == 0
+ && prog->UniformBlocks[i].Name[l] == '[') {
+ ubo_block_index = i;
+ break;
+ }
+ }
+ } else {
+ for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+ if (strcmp(var->interface_type->name,
+ prog->UniformBlocks[i].Name) == 0) {
+ ubo_block_index = i;
+ break;
+ }
+ }
+ }
+ assert(ubo_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
+ * name used to reference the uniform block instead of being the name
+ * of a variable within the block. Therefore, searching for the name
+ * within the block will fail.
+ */
+ if (var->is_interface_instance()) {
+ ubo_byte_offset = 0;
+ ubo_row_major = false;
+ } else {
+ const struct gl_uniform_block *const block =
+ &prog->UniformBlocks[ubo_block_index];
+
+ assert(var->location != -1);
+
+ const struct gl_uniform_buffer_variable *const ubo_var =
+ &block->Uniforms[var->location];
+
+ ubo_row_major = ubo_var->RowMajor;
+ ubo_byte_offset = ubo_var->Offset;
+ }
+
+ if (var->is_interface_instance())
+ process(var->interface_type, var->interface_type->name);
+ else
+ process(var);
+ } else
+ process(var);
+ }
+
+ int ubo_block_index;
+ int ubo_byte_offset;
+ bool ubo_row_major;
+