diff options
author | Samuel Iglesias Gonsalvez <[email protected]> | 2015-09-04 17:53:48 +0200 |
---|---|---|
committer | Samuel Iglesias Gonsalvez <[email protected]> | 2015-09-25 08:39:22 +0200 |
commit | 1be180b941ac9e0652a6b2d19713ddccd8a5151f (patch) | |
tree | 90f1dded872d145b2830866321230f174b772e7e /src/glsl/link_uniform_blocks.cpp | |
parent | 8f0167c65b2df73cf2ef094358ba162fe0028d14 (diff) |
glsl: Add std430 support to program_resource_visitor's member functions
They are used to calculate the offset, array stride of uniform/shader
storage buffer variables. Take into account this info to get the right
value for std430.
v2:
- Fix commit log line length and indention. (Jordan)
Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Reviewed-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src/glsl/link_uniform_blocks.cpp')
-rw-r--r-- | src/glsl/link_uniform_blocks.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/glsl/link_uniform_blocks.cpp b/src/glsl/link_uniform_blocks.cpp index c891d030234..8f65f4a3ab7 100644 --- a/src/glsl/link_uniform_blocks.cpp +++ b/src/glsl/link_uniform_blocks.cpp @@ -68,14 +68,18 @@ private: } virtual void enter_record(const glsl_type *type, const char *, - bool row_major) { + bool row_major, const unsigned packing) { assert(type->is_record()); - this->offset = glsl_align( + if (packing == GLSL_INTERFACE_PACKING_STD430) + this->offset = glsl_align( + this->offset, type->std430_base_alignment(row_major)); + else + this->offset = glsl_align( this->offset, type->std140_base_alignment(row_major)); } virtual void leave_record(const glsl_type *type, const char *, - bool row_major) { + bool row_major, const unsigned packing) { assert(type->is_record()); /* If this is the last field of a structure, apply rule #9. The @@ -85,12 +89,17 @@ private: * the member following the sub-structure is rounded up to the next * multiple of the base alignment of the structure." */ - this->offset = glsl_align( + if (packing == GLSL_INTERFACE_PACKING_STD430) + this->offset = glsl_align( + this->offset, type->std430_base_alignment(row_major)); + else + this->offset = glsl_align( this->offset, type->std140_base_alignment(row_major)); } virtual void visit_field(const glsl_type *type, const char *name, bool row_major, const glsl_type *, + const unsigned packing, bool /* last_field */) { assert(this->index < this->num_variables); @@ -122,7 +131,7 @@ private: unsigned alignment = 0; unsigned size = 0; - if (v->Type->interface_packing == GLSL_INTERFACE_PACKING_STD430) { + if (packing == GLSL_INTERFACE_PACKING_STD430) { alignment = type->std430_base_alignment(v->RowMajor); size = type->std430_size(v->RowMajor); } else { |