Mesa (master): glsl: Round struct size up to at least 16 bytes

Ian Romanick idr at kemper.freedesktop.org
Fri Sep 26 14:58:15 UTC 2014


Module: Mesa
Branch: master
Commit: bf404346f6d0abc37991286adebac05b872b6e8e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf404346f6d0abc37991286adebac05b872b6e8e

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Wed Sep 10 10:54:55 2014 -0700

glsl: Round struct size up to at least 16 bytes

Per rule #9, the size of the structure is vec4 aligned.  The MAX2 in the
loop ensures that sizes >= 16 bytes are vec4 aligned.  The new MAX2
after the loop ensures that sizes < 16 bytes are vec4 aligned.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82932
Cc: mesa-stable at lists.freedesktop.org

---

 src/glsl/glsl_types.cpp |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 435b866..c11d864 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -979,7 +979,7 @@ glsl_type::std140_size(bool row_major) const
          if (field_type->is_record() && (i + 1 < this->length))
             size = glsl_align(size, 16);
       }
-      size = glsl_align(size, max_align);
+      size = glsl_align(size, MAX2(max_align, 16));
       return size;
    }
 




More information about the mesa-commit mailing list