summaryrefslogtreecommitdiffstats
path: root/src/glsl/link_uniforms.cpp
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-05-01 13:59:31 -0700
committerEric Anholt <[email protected]>2012-07-20 10:43:47 -0700
commita74507dc94f6383f2a81850866fceec108c2ab34 (patch)
tree1b30100adb040ad5c61cdbec324c32811d891f29 /src/glsl/link_uniforms.cpp
parentddc88fbf510ee8ba35b974cc21c595e96d115cc8 (diff)
glsl: Propagate uniform block information into gl_uniform_storage.
Now we can actually return information on uniforms in uniform blocks in the new queries. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/link_uniforms.cpp')
-rw-r--r--src/glsl/link_uniforms.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index ff75b8919e9..4cc97cead80 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -217,6 +217,28 @@ public:
this->shader_shadow_samplers = 0;
}
+ void set_and_process(struct gl_shader_program *prog,
+ ir_variable *var)
+ {
+ ubo_var = NULL;
+ if (var->uniform_block != -1) {
+ struct gl_uniform_block *block =
+ &prog->UniformBlocks[var->uniform_block];
+
+ ubo_block_index = var->uniform_block;
+ ubo_var_index = var->location;
+ ubo_var = &block->Uniforms[var->location];
+ ubo_byte_offset = ubo_var->Offset;
+ }
+
+ process(var);
+ }
+
+ struct gl_uniform_buffer_variable *ubo_var;
+ int ubo_block_index;
+ int ubo_var_index;
+ int ubo_byte_offset;
+
private:
virtual void visit_field(const glsl_type *type, const char *name)
{
@@ -292,6 +314,23 @@ private:
this->uniforms[id].num_driver_storage = 0;
this->uniforms[id].driver_storage = NULL;
this->uniforms[id].storage = this->values;
+ if (this->ubo_var) {
+ this->uniforms[id].block_index = this->ubo_block_index;
+
+ /* FINISHME: Actual std140 offset assignment. */
+ this->uniforms[id].offset = this->ubo_byte_offset;
+ this->ubo_byte_offset += 4 * type->components();
+ this->uniforms[id].array_stride = 0;
+ this->uniforms[id].matrix_stride = 0;
+ this->uniforms[id].row_major = base_type->is_matrix() &&
+ ubo_var->RowMajor;
+ } else {
+ this->uniforms[id].block_index = -1;
+ this->uniforms[id].offset = -1;
+ this->uniforms[id].array_stride = -1;
+ this->uniforms[id].matrix_stride = -1;
+ this->uniforms[id].row_major = false;
+ }
this->values += values_for_type(type);
}
@@ -518,7 +557,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
if (strncmp("gl_", var->name, 3) == 0)
continue;
- parcel.process(var);
+ parcel.set_and_process(prog, var);
}
prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used;