Existing tests apparently never attempt to read data from row_major
matrices in their UBOs. This catches Mesa bug 104553.
---

At least I hope that statement in the commit message is correct. Using a
tentative Mesa fix for Mesa bug 104553 showed no candidates listed on the
"fixes" HTML summary other than this test and some unstable tests.

If there's a cleaner way to manage the 8 "sub-tests", or some existing test
where this should be included, let me know and I'll send v2. :-)

 .../mat4-row-major-column-major-deref.shader_test  | 108 +++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 
tests/spec/arb_uniform_buffer_object/execution/mat4-row-major-column-major-deref.shader_test

diff --git 
a/tests/spec/arb_uniform_buffer_object/execution/mat4-row-major-column-major-deref.shader_test
 
b/tests/spec/arb_uniform_buffer_object/execution/mat4-row-major-column-major-deref.shader_test
new file mode 100644
index 000000000..9a6f405b2
--- /dev/null
+++ 
b/tests/spec/arb_uniform_buffer_object/execution/mat4-row-major-column-major-deref.shader_test
@@ -0,0 +1,108 @@
+# Reading mat4 components from UBOs should respect row/column_major layouts.
+
+[require]
+GLSL >= 1.30
+GL_ARB_uniform_buffer_object
+
+[vertex shader passthrough]
+
+[fragment shader]
+#extension GL_ARB_uniform_buffer_object: require
+
+out vec4 outcolor;
+
+uniform Block {
+    uint test_variant;
+    layout(row_major) mat4 m_row_major;
+    layout(column_major) mat4 m_col_major;
+};
+
+vec4 extract_by_index(mat4 m) {
+    return vec4(m[0][0], m[3][0], m[0][3], m[1][2]);
+}
+
+vec4 extract_swizzle(mat4 m) {
+    return vec4(m[0].x,  m[3].x,  m[0].w,  m[1].z);
+}
+
+void main()
+{
+    /* These variants should result in the same color */
+    if (test_variant == 0u)
+        outcolor = extract_by_index(m_col_major);
+    else if (test_variant == 1u)
+        outcolor = extract_swizzle(m_col_major);
+    else if (test_variant == 2u)
+        outcolor = extract_by_index(m_row_major);
+    else if (test_variant == 3u)
+        outcolor = extract_swizzle(m_row_major);
+
+
+    /* These variants should result in the same color (col sum) */
+    else if (test_variant == 100u)
+        outcolor = vec4(1, 1, 1, 1) * m_col_major;
+    else if (test_variant == 101u)
+        outcolor = vec4(1, 1, 1, 1) * m_row_major;
+
+
+    /* These variants should result in the same color (row sum) */
+    else if (test_variant == 200u)
+        outcolor = m_col_major * vec4(1, 1, 1, 1);
+    else if (test_variant == 201u)
+        outcolor = m_row_major * vec4(1, 1, 1, 1);
+}
+
+[test]
+# Matrix:
+# 0.01 0.05 0.09 0.13
+# 0.02 0.06 0.10 0.14
+# 0.03 0.07 0.11 0.15
+# 0.04 0.08 0.12 0.16
+
+# shader_runner "uniform" command always expects data in column-major format,
+# but will use the layout specified in the uniform block to upload matrix data
+# to the GPU, so both lines look similar, but result in different buffer
+# contents.
+uniform mat4 m_row_major   0.01 0.02 0.03 0.04   0.05 0.06 0.07 0.08   0.09 
0.10 0.11 0.12   0.13 0.14 0.15 0.16
+uniform mat4 m_col_major   0.01 0.02 0.03 0.04   0.05 0.06 0.07 0.08   0.09 
0.10 0.11 0.12   0.13 0.14 0.15 0.16
+clear color 0.0 0.0 0.0 0.0
+
+clear
+uniform uint test_variant 0
+draw rect -1 -1 2 2
+probe all rgba 0.01 0.13 0.04 0.07
+
+clear
+uniform uint test_variant 1
+draw rect -1 -1 2 2
+probe all rgba 0.01 0.13 0.04 0.07
+
+clear
+uniform uint test_variant 2
+draw rect -1 -1 2 2
+probe all rgba 0.01 0.13 0.04 0.07
+
+clear
+uniform uint test_variant 3
+draw rect -1 -1 2 2
+probe all rgba 0.01 0.13 0.04 0.07
+
+clear
+uniform uint test_variant 100
+draw rect -1 -1 2 2
+probe all rgba 0.1 0.26 0.42 0.58
+
+clear
+uniform uint test_variant 101
+draw rect -1 -1 2 2
+probe all rgba 0.1 0.26 0.42 0.58
+
+clear
+uniform uint test_variant 200
+draw rect -1 -1 2 2
+probe all rgba 0.28 0.32 0.36 0.40
+
+clear
+uniform uint test_variant 201
+draw rect -1 -1 2 2
+probe all rgba 0.28 0.32 0.36 0.40
-- 
2.14.1

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to