glsl: Round struct size up to at least 16 bytes
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 10 Sep 2014 17:54:55 +0000 (10:54 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 26 Sep 2014 14:59:50 +0000 (07:59 -0700)
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@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82932
Cc: mesa-stable@lists.freedesktop.org
src/glsl/glsl_types.cpp

index 435b86673306e580af767155f1fd6fa0ab5142ef..c11d86482be4843e9a015042e9ae0266e95b1acd 100644 (file)
@@ -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;
    }