summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2014-09-08 19:17:44 -0700
committerIan Romanick <ian.d.romanick@intel.com>2014-09-17 15:17:53 -0400
commitb44c370b6e57b4fb7a25b4018b417202bcf35470 (patch)
treefcf84b0fb05221b23568a8004b6d0474a1e47a6f
parentd859c94fd1d0406c3d109ed209897baccf99b57d (diff)
glsl-1.50: Put a struct after a struct with weird alignment
The trick of this test is putting a structure after a structure that is larger than 16-bytes but not 16-byte aligned. In this case the first structure is 24 bytes. This should have an array stride of 32-bytes. There seems to be some problem in Mesa's glsl_type::std140_size() that causes the total array size to be 48 instead of 64. The correct values are, however, reported via the GL API. NOTE: On Mesa we get the correct locations, but the shader doesn't generate the correct results. The test fails. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83639 Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
-rw-r--r--tests/spec/glsl-1.50/uniform_buffer/struct_base_alignment.shader_test86
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.50/uniform_buffer/struct_base_alignment.shader_test b/tests/spec/glsl-1.50/uniform_buffer/struct_base_alignment.shader_test
new file mode 100644
index 000000000..6ea9302a9
--- /dev/null
+++ b/tests/spec/glsl-1.50/uniform_buffer/struct_base_alignment.shader_test
@@ -0,0 +1,86 @@
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+#extension GL_ARB_shader_bit_encoding: enable
+#extension GL_ARB_gpu_shader5: enable
+
+// To reproduce the Mesa bug, S1 must be larger than 16 bytes and not
+// 16-byte aligned. In addition, the uniform block must have an instance
+// name.
+
+struct S1 {
+ bvec2 bv1;
+ float f1;
+ uvec2 uv1;
+};
+
+struct S2 {
+ mat4x2 m42_1;
+};
+
+struct S3 {
+ S2 s2_1;
+};
+
+layout(std140)
+uniform UB {
+ // base base align padded row- array matrix
+ // align off. off. size major stride stride
+ S1[2] s1_1; // 16 0 0 64 - 32 -
+// [0]
+// bvec2 bv1 8 0 0 8 - - -
+// float f1 4 8 8 4 - - -
+// uvec2 uv1 8 12 16 8 - - -
+// [1]
+// bvec2 bv1 8 32 32 8 - - -
+// float f1 4 40 40 4 - - -
+// uvec2 uv1 8 44 48 8 - - -
+ S3[1] s3_1; // 16 64 64 64 - 64 -
+// [0]
+// S2 s2_1 16 64 64 64 - - -
+// mat4x2 m42_1 16 64 64 64 no - 16
+} ub;
+
+flat out int vertex_pass;
+in vec4 piglit_vertex;
+
+#if defined(GL_ARB_shader_bit_encoding) || defined(GL_ARB_gpu_shader5) || __VERSION__ >= 430
+bool float_match(float u, float f, uint bits) { return floatBitsToUint(u) == bits; }
+#else
+bool float_match(float u, float f, uint bits) { return u == f; }
+#endif
+
+void main()
+{
+ bool pass;
+
+ pass = float_match(ub.s3_1[0].s2_1.m42_1[0].y, 32703.5333028, 0x46ff7f11u);
+
+ vertex_pass = int(pass);
+ gl_Position = piglit_vertex;
+}
+
+[fragment shader]
+out vec4 piglit_fragcolor;
+flat in int vertex_pass;
+
+void main()
+{
+ piglit_fragcolor = bool(vertex_pass) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1);
+}
+
+[test]
+link success
+
+active uniform UB.s3_1[0].s2_1.m42_1 GL_UNIFORM_TYPE GL_FLOAT_MAT4x2
+active uniform UB.s3_1[0].s2_1.m42_1 GL_UNIFORM_SIZE 1
+active uniform UB.s3_1[0].s2_1.m42_1 GL_UNIFORM_OFFSET 64
+active uniform UB.s3_1[0].s2_1.m42_1 GL_UNIFORM_ARRAY_STRIDE 0
+active uniform UB.s3_1[0].s2_1.m42_1 GL_UNIFORM_MATRIX_STRIDE 16
+active uniform UB.s3_1[0].s2_1.m42_1 GL_UNIFORM_IS_ROW_MAJOR 0
+
+uniform mat4x2 UB.s3_1[0].s2_1.m42_1 0x4680c6b6 0x46ff7f11 0x462085c4 0x46cefb3e 0xc6b24e67 0x469e776a 0xc6e2d23a 0xc64833be
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0