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),
+ map(map)
{
/* empty */
}
+ void start_shader()
+ {
+ this->num_shader_samplers = 0;
+ }
+
/**
* Total number of active uniforms counted
*/
*/
unsigned num_values;
+ /**
+ * Number of samplers used
+ */
+ unsigned num_shader_samplers;
+
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.
+ */
+ if (type->contains_sampler()) {
+ this->num_shader_samplers +=
+ type->is_array() ? type->array_size() : 1;
+ }
+
/* If the uniform is already in the map, there's nothing more to do.
*/
unsigned id;
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();
uniform_size.process(var);
}
+
+ prog->_LinkedShaders[i]->num_samplers = uniform_size.num_shader_samplers;
}
const unsigned num_user_uniforms = uniform_size.num_active_uniforms;