aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/link_uniforms.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-11-17 16:37:26 +0100
committermarha <marha@users.sourceforge.net>2011-11-17 16:37:26 +0100
commitd41bc08d1ae8c4784c09d8977816c0fadab1ba52 (patch)
tree4dc3081a9af0316eeee02356a44fcc2419e1b15e /mesalib/src/glsl/link_uniforms.cpp
parent156e37d3879b316329e3e05579414031da2647e2 (diff)
downloadvcxsrv-d41bc08d1ae8c4784c09d8977816c0fadab1ba52.tar.gz
vcxsrv-d41bc08d1ae8c4784c09d8977816c0fadab1ba52.tar.bz2
vcxsrv-d41bc08d1ae8c4784c09d8977816c0fadab1ba52.zip
xserver mesa git update 17 nov 2011
Diffstat (limited to 'mesalib/src/glsl/link_uniforms.cpp')
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index b9d5361b0..ca5da3040 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -113,11 +113,18 @@ uniform_field_visitor::recursion(const glsl_type *t, char **name,
class count_uniform_size : public uniform_field_visitor {
public:
count_uniform_size(struct string_to_uint_map *map)
- : num_active_uniforms(0), num_values(0), map(map)
+ : num_active_uniforms(0), num_values(0), num_shader_samplers(0),
+ num_shader_uniforms(0), map(map)
{
/* empty */
}
+ void start_shader()
+ {
+ this->num_shader_samplers = 0;
+ this->num_shader_uniforms = 0;
+ }
+
/**
* Total number of active uniforms counted
*/
@@ -128,12 +135,39 @@ public:
*/
unsigned num_values;
+ /**
+ * Number of samplers used
+ */
+ unsigned num_shader_samplers;
+
+ /**
+ * Number of uniforms used in the current shader
+ */
+ unsigned num_shader_uniforms;
+
private:
virtual void visit_field(const glsl_type *type, const char *name)
{
assert(!type->is_record());
assert(!(type->is_array() && type->fields.array->is_record()));
+ /* Count the number of samplers regardless of whether the uniform is
+ * already in the hash table. The hash table prevents adding the same
+ * uniform for multiple shader targets, but in this case we want to
+ * count it for each shader target.
+ */
+ const unsigned values = values_for_type(type);
+ if (type->contains_sampler()) {
+ this->num_shader_samplers +=
+ type->is_array() ? type->array_size() : 1;
+ } else {
+ /* Accumulate the total number of uniform slots used by this shader.
+ * Note that samplers do not count against this limit because they
+ * don't use any storage on current hardware.
+ */
+ this->num_shader_uniforms += values;
+ }
+
/* If the uniform is already in the map, there's nothing more to do.
*/
unsigned id;
@@ -147,7 +181,7 @@ private:
* uniforms.
*/
this->num_active_uniforms++;
- this->num_values += values_for_type(type);
+ this->num_values += values;
}
struct string_to_uint_map *map;
@@ -267,6 +301,10 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
if (prog->_LinkedShaders[i] == NULL)
continue;
+ /* Reset various per-shader target counts.
+ */
+ uniform_size.start_shader();
+
foreach_list(node, prog->_LinkedShaders[i]->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
@@ -280,6 +318,10 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
uniform_size.process(var);
}
+
+ prog->_LinkedShaders[i]->num_samplers = uniform_size.num_shader_samplers;
+ prog->_LinkedShaders[i]->num_uniform_components =
+ uniform_size.num_shader_uniforms * 4;
}
const unsigned num_user_uniforms = uniform_size.num_active_uniforms;