#include "main/hash_table.h"
#include "program.h"
-class ubo_visitor : public uniform_field_visitor {
+namespace {
+
+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;
private:
virtual void visit_field(const glsl_type *type, const char *name,
bool row_major)
+ {
+ (void) type;
+ (void) name;
+ (void) row_major;
+ assert(!"Should not get here.");
+ }
+
+ virtual void visit_field(const glsl_type *type, const char *name,
+ bool row_major, const glsl_type *record_type)
{
assert(this->index < this->num_variables);
v->IndexName = v->Name;
}
- unsigned alignment = type->std140_base_alignment(v->RowMajor);
+ const unsigned alignment = record_type
+ ? record_type->std140_base_alignment(v->RowMajor)
+ : type->std140_base_alignment(v->RowMajor);
unsigned size = type->std140_size(v->RowMajor);
this->offset = glsl_align(this->offset, alignment);
virtual void visit_field(const glsl_struct_field *field)
{
+ /* FINISHME: When support for doubles (dvec4, etc.) is added to the
+ * FINISHME: compiler, this may be incorrect for a structure in a UBO
+ * FINISHME: like struct s { struct { float f } s1; dvec4 v; };.
+ */
this->offset = glsl_align(this->offset,
field->type->std140_base_alignment(false));
}
};
-class count_block_size : public uniform_field_visitor {
+class count_block_size : public program_resource_visitor {
public:
count_block_size() : num_active_uniforms(0)
{
}
};
+} /* anonymous namespace */
+
struct block {
const glsl_type *type;
bool has_instance_name;
};
-int
+unsigned
link_uniform_blocks(void *mem_ctx,
struct gl_shader_program *prog,
struct gl_shader **shader_list,