- if (type->is_array()) {
- this->uniforms[id].array_stride =
- glsl_align(type->fields.array->std140_size(row_major), 16);
+ if (this->ubo_block_index != -1) {
+ this->uniforms[id].block_index = this->ubo_block_index;
+
+ unsigned alignment = type->std140_base_alignment(row_major);
+ if (packing == GLSL_INTERFACE_PACKING_STD430)
+ alignment = type->std430_base_alignment(row_major);
+ this->ubo_byte_offset = glsl_align(this->ubo_byte_offset, alignment);
+ this->uniforms[id].offset = this->ubo_byte_offset;
+ if (packing == GLSL_INTERFACE_PACKING_STD430)
+ this->ubo_byte_offset += type->std430_size(row_major);
+ else
+ this->ubo_byte_offset += type->std140_size(row_major);
+
+ if (type->is_array()) {
+ if (packing == GLSL_INTERFACE_PACKING_STD430)
+ this->uniforms[id].array_stride =
+ type->without_array()->std430_array_stride(row_major);
+ else
+ this->uniforms[id].array_stride =
+ glsl_align(type->without_array()->std140_size(row_major),
+ 16);