[Mesa-dev] [PATCH 5/7] glsl: copy explicit offset to uniform storage

Timothy Arceri timothy.arceri at collabora.com
Sun Jan 10 19:13:10 PST 2016


---
 src/glsl/link_uniform_blocks.cpp |  5 +++++
 src/glsl/link_uniforms.cpp       | 13 +++++++++++++
 src/glsl/linker.h                |  2 ++
 3 files changed, 20 insertions(+)

diff --git a/src/glsl/link_uniform_blocks.cpp b/src/glsl/link_uniform_blocks.cpp
index 7d75576..c8fa181 100644
--- a/src/glsl/link_uniform_blocks.cpp
+++ b/src/glsl/link_uniform_blocks.cpp
@@ -97,6 +97,11 @@ private:
             this->offset, type->std140_base_alignment(row_major));
    }
 
+   virtual void set_buffer_offset(unsigned offset)
+   {
+      this->offset = offset;
+   }
+
    virtual void visit_field(const glsl_type *type, const char *name,
                             bool row_major, const glsl_type *,
                             const unsigned packing,
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 47bb771..4f08dba 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -194,6 +194,9 @@ program_resource_visitor::recursion(const glsl_type *t, char **name,
          if (t->fields.structure[i].type->is_record())
             this->visit_field(&t->fields.structure[i]);
 
+         if (t->is_interface() && t->fields.structure[i].offset != -1)
+            this->set_buffer_offset(t->fields.structure[i].offset);
+
          /* Append '.field' to the current variable name. */
          if (name_length == 0) {
             ralloc_asprintf_rewrite_tail(name, &new_length, "%s", field);
@@ -298,6 +301,11 @@ program_resource_visitor::leave_record(const glsl_type *, const char *, bool,
 }
 
 void
+program_resource_visitor::set_buffer_offset(unsigned)
+{
+}
+
+void
 program_resource_visitor::set_record_array_count(unsigned)
 {
 }
@@ -669,6 +677,11 @@ private:
       }
    }
 
+   virtual void set_buffer_offset(unsigned offset)
+   {
+      this->ubo_byte_offset = offset;
+   }
+
    virtual void set_record_array_count(unsigned record_array_count)
    {
       this->record_array_count = record_array_count;
diff --git a/src/glsl/linker.h b/src/glsl/linker.h
index c80be1c..88fc9d2 100644
--- a/src/glsl/linker.h
+++ b/src/glsl/linker.h
@@ -180,6 +180,8 @@ protected:
    virtual void leave_record(const glsl_type *type, const char *name,
                              bool row_major, const unsigned packing);
 
+   virtual void set_buffer_offset(unsigned offset);
+
    virtual void set_record_array_count(unsigned record_array_count);
 
 private:
-- 
2.4.3



More information about the mesa-dev mailing list