There's actually nothing uniform-specific in uniform_field_visitor.
It is potentially useful for all kinds of program resources (in
particular, future patches will use it for transform feedback
varyings).
This patch renames it to program_resource_visitor, and clarifies
several comments, to reflect the fact that it is useful for more than
just uniforms.
NOTE: This is a candidate for the 9.1 branch.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
#include "main/hash_table.h"
#include "program.h"
-class ubo_visitor : public uniform_field_visitor {
+class ubo_visitor : public program_resource_visitor {
public:
ubo_visitor(void *mem_ctx, gl_uniform_buffer_variable *variables,
unsigned num_variables)
this->offset = 0;
this->buffer_size = 0;
this->is_array_instance = strchr(name, ']') != NULL;
- this->uniform_field_visitor::process(type, name);
+ this->program_resource_visitor::process(type, name);
}
unsigned index;
}
};
-class count_block_size : public uniform_field_visitor {
+class count_block_size : public program_resource_visitor {
public:
count_block_size() : num_active_uniforms(0)
{
}
void
-uniform_field_visitor::process(const glsl_type *type, const char *name)
+program_resource_visitor::process(const glsl_type *type, const char *name)
{
assert(type->is_record()
|| (type->is_array() && type->fields.array->is_record())
}
void
-uniform_field_visitor::process(ir_variable *var)
+program_resource_visitor::process(ir_variable *var)
{
const glsl_type *t = var->type;
}
void
-uniform_field_visitor::recursion(const glsl_type *t, char **name,
- size_t name_length, bool row_major)
+program_resource_visitor::recursion(const glsl_type *t, char **name,
+ size_t name_length, bool row_major)
{
/* Records need to have each field processed individually.
*
if (t->fields.structure[i].type->is_record())
this->visit_field(&t->fields.structure[i]);
- /* Append '.field' to the current uniform name. */
+ /* Append '.field' to the current variable name. */
if (name_length == 0) {
ralloc_asprintf_rewrite_tail(name, &new_length, "%s", field);
} else {
for (unsigned i = 0; i < t->length; i++) {
size_t new_length = name_length;
- /* Append the subscript to the current uniform name */
+ /* Append the subscript to the current variable name */
ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]", i);
recursion(t->fields.array, name, new_length,
}
void
-uniform_field_visitor::visit_field(const glsl_struct_field *field)
+program_resource_visitor::visit_field(const glsl_struct_field *field)
{
(void) field;
/* empty */
* If the same uniform is added multiple times (i.e., once for each shader
* target), it will only be accounted once.
*/
-class count_uniform_size : public uniform_field_visitor {
+class count_uniform_size : public program_resource_visitor {
public:
count_uniform_size(struct string_to_uint_map *map)
: num_active_uniforms(0), num_values(0), num_shader_samplers(0),
void process(ir_variable *var)
{
if (var->is_interface_instance())
- uniform_field_visitor::process(var->interface_type,
- var->interface_type->name);
+ program_resource_visitor::process(var->interface_type,
+ var->interface_type->name);
else
- uniform_field_visitor::process(var);
+ program_resource_visitor::process(var);
}
/**
* the \c gl_uniform_storage and \c gl_constant_value arrays are "big
* enough."
*/
-class parcel_out_uniform_storage : public uniform_field_visitor {
+class parcel_out_uniform_storage : public program_resource_visitor {
public:
parcel_out_uniform_storage(struct string_to_uint_map *map,
struct gl_uniform_storage *uniforms,
struct gl_uniform_block **blocks_ret);
/**
- * Class for processing all of the leaf fields of an uniform
+ * Class for processing all of the leaf fields of a variable that corresponds
+ * to a program resource.
*
- * Leaves are, roughly speaking, the parts of the uniform that the application
- * could query with \c glGetUniformLocation (or that could be returned by
- * \c glGetActiveUniforms).
+ * The leaf fields are all the parts of the variable that the application
+ * could query using \c glGetProgramResourceIndex (or that could be returned
+ * by \c glGetProgramResourceName).
*
* Classes my derive from this class to implement specific functionality.
* This class only provides the mechanism to iterate over the leaves. Derived
* classes must implement \c ::visit_field and may override \c ::process.
*/
-class uniform_field_visitor {
+class program_resource_visitor {
public:
/**
- * Begin processing a uniform
+ * Begin processing a variable
*
* Classes that overload this function should call \c ::process from the
- * base class to start the recursive processing of the uniform.
+ * base class to start the recursive processing of the variable.
*
- * \param var The uniform variable that is to be processed
+ * \param var The variable that is to be processed
*
- * Calls \c ::visit_field for each leaf of the uniform.
+ * Calls \c ::visit_field for each leaf of the variable.
*
* \warning
- * This entry should only be used with uniform blocks in cases where the
- * row / column ordering of matrices in the block does not matter. For
- * example, enumerating the names of members of the block, but not for
- * determining the offsets of members.
+ * When processing a uniform block, this entry should only be used in cases
+ * where the row / column ordering of matrices in the block does not
+ * matter. For example, enumerating the names of members of the block, but
+ * not for determining the offsets of members.
*/
void process(ir_variable *var);
/**
- * Begin processing a uniform of a structured type.
+ * Begin processing a variable of a structured type.
*
* This flavor of \c process should be used to handle structured types
* (i.e., structures, interfaces, or arrays there of) that need special
* (instead of the instance name) is used for an interface block.
*
* \param type Type that is to be processed, associated with \c name
- * \param name Base name of the structured uniform being processed
+ * \param name Base name of the structured variable being processed
*
* \note
* \c type must be \c GLSL_TYPE_RECORD, \c GLSL_TYPE_INTERFACE, or an array
protected:
/**
- * Method invoked for each leaf of the uniform
+ * Method invoked for each leaf of the variable
*
* \param type Type of the field.
* \param name Fully qualified name of the field.
}
}
-class add_uniform_to_shader : public uniform_field_visitor {
+class add_uniform_to_shader : public program_resource_visitor {
public:
add_uniform_to_shader(struct gl_shader_program *shader_program,
struct gl_program_parameter_list *params)
void process(ir_variable *var)
{
this->idx = -1;
- this->uniform_field_visitor::process(var);
+ this->program_resource_visitor::process(var);
var->location = this->idx;
}