radeon: use _mesa_get_current_tex_object() in radeonSetTexBuffer2()
[mesa.git] / src / glsl / link_uniform_blocks.cpp
index 74fe1e29f6d86c35a20e2f98fca25a4944fb91f4..72d6c5323a6ebe90a4117bf4e8ac56eaa88d4df6 100644 (file)
@@ -29,7 +29,9 @@
 #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)
@@ -44,7 +46,7 @@ public:
       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;
@@ -58,6 +60,15 @@ public:
 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);
 
@@ -85,7 +96,9 @@ private:
          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);
@@ -107,12 +120,16 @@ private:
 
    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)
    {
@@ -132,12 +149,14 @@ private:
    }
 };
 
+} /* 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,