aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/link_uniforms.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-08-13 10:11:17 +0200
committermarha <marha@users.sourceforge.net>2012-08-13 10:11:17 +0200
commitf5a4fa87e844b3ea2658a2355a4c4ac3393a65a1 (patch)
tree921a5a742930124e7bd7e9a7e73f6029bd74338d /mesalib/src/glsl/link_uniforms.cpp
parentec4051f308e8e84146e0ecc39b6d228e500e9636 (diff)
parent9ddf44af81782451cee798e06749ce3067a14a41 (diff)
downloadvcxsrv-f5a4fa87e844b3ea2658a2355a4c4ac3393a65a1.tar.gz
vcxsrv-f5a4fa87e844b3ea2658a2355a4c4ac3393a65a1.tar.bz2
vcxsrv-f5a4fa87e844b3ea2658a2355a4c4ac3393a65a1.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/glsl/link_uniforms.cpp')
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index 7c3d74b82..27694b3f3 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -224,14 +224,24 @@ public:
}
void set_and_process(struct gl_shader_program *prog,
+ struct gl_shader *shader,
ir_variable *var)
{
ubo_var = NULL;
if (var->uniform_block != -1) {
struct gl_uniform_block *block =
- &prog->UniformBlocks[var->uniform_block];
+ &shader->UniformBlocks[var->uniform_block];
+
+ ubo_block_index = -1;
+ for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+ if (!strcmp(prog->UniformBlocks[i].Name,
+ shader->UniformBlocks[var->uniform_block].Name)) {
+ ubo_block_index = i;
+ break;
+ }
+ }
+ assert(ubo_block_index != -1);
- ubo_block_index = var->uniform_block;
ubo_var_index = var->location;
ubo_var = &block->Uniforms[var->location];
ubo_byte_offset = ubo_var->Offset;
@@ -490,7 +500,19 @@ link_assign_uniform_block_offsets(struct gl_shader *shader)
ubo_var->Offset = offset;
offset += size;
}
- block->UniformBufferSize = offset;
+
+ /* From the GL_ARB_uniform_buffer_object spec:
+ *
+ * "For uniform blocks laid out according to [std140] rules,
+ * the minimum buffer object size returned by the
+ * UNIFORM_BLOCK_DATA_SIZE query is derived by taking the
+ * offset of the last basic machine unit consumed by the
+ * last uniform of the uniform block (including any
+ * end-of-array or end-of-structure padding), adding one,
+ * and rounding up to the next multiple of the base
+ * alignment required for a vec4."
+ */
+ block->UniformBufferSize = align(offset, 16);
}
}
@@ -598,7 +620,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
if (strncmp("gl_", var->name, 3) == 0)
continue;
- parcel.set_and_process(prog, var);
+ parcel.set_and_process(prog, prog->_LinkedShaders[i], var);
}
prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used;