From: Timothy Arceri Date: Fri, 8 Jan 2016 10:06:41 +0000 (+1100) Subject: glsl: copy explicit offset to uniform storage X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=96527c3cf29acaa74a0e7b8624f29e514a76e42e;p=mesa.git glsl: copy explicit offset to uniform storage Reviewed-by: Edward O'Callaghan --- diff --git a/src/compiler/glsl/link_uniform_blocks.cpp b/src/compiler/glsl/link_uniform_blocks.cpp index 7d755765852..c8fa181a15d 100644 --- a/src/compiler/glsl/link_uniform_blocks.cpp +++ b/src/compiler/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/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp index deaba94df1c..fb915c9e5f1 100644 --- a/src/compiler/glsl/link_uniforms.cpp +++ b/src/compiler/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); @@ -297,6 +300,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) { @@ -676,6 +684,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/compiler/glsl/linker.h b/src/compiler/glsl/linker.h index a60bb6ed087..4311d1659ec 100644 --- a/src/compiler/glsl/linker.h +++ b/src/compiler/glsl/linker.h @@ -182,6 +182,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: