Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / glsl3 / matrix-row-major-dynamic-indexing.html
blobec6a9bbd1be453fb2b2c0119000eae45c38176e4
1 <!--
2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>Dynamically-indexed row-major matrix test</title>
12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
13 <script src="../../js/js-test-pre.js"></script>
14 <script src="../../js/webgl-test-utils.js"></script>
15 <script src="../../js/glsl-conformance-test.js"></script>
16 </head>
17 <body>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="fshaderIndexRowMajorMatrixArrayInUniformBlock" type="x-shader/x-fragment">#version 300 es
21 precision mediump float;
23 out vec4 my_FragColor;
25 uniform int u_zero;
27 layout(row_major) uniform a {
28 mat4 u_mats[1];
31 void main() {
32 float f = u_mats[u_zero + 0][2][1];
33 my_FragColor = vec4(1.0 - f, f, 0.0, 1.0);
35 </script>
36 <script id="fshaderRowMatrixIndexedByRowMatrixInUniformBlock" type="x-shader/x-fragment">#version 300 es
37 precision mediump float;
39 uniform Stuff {
40 layout(row_major) mat4 u_mat[3];
41 layout(row_major) mat4 u_ndx[3];
42 } stuff;
45 out vec4 my_FragColor;
47 void main() {
48 vec4 row = stuff.u_mat[int(stuff.u_ndx[1][1][3])][2];
49 my_FragColor = row == vec4(9, 10, 11, 12) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1);
51 </script>
52 <script type="application/javascript">
53 "use strict";
54 description("Indexing row-major matrices within a uniform block should work");
56 GLSLConformanceTester.runRenderTests([
58 fShaderId: 'fshaderIndexRowMajorMatrixArrayInUniformBlock',
59 fShaderSuccess: true,
60 linkSuccess: true,
61 passMsg: '',
62 uniformBlocks: [{name: "a", value: new Float32Array([
63 0, 0, 0, 0,
64 0, 0, 1, 0,
65 0, 0, 0, 0,
66 0, 0, 0, 0,
67 ])}],
70 fShaderId: 'fshaderRowMatrixIndexedByRowMatrixInUniformBlock',
71 fShaderSuccess: true,
72 linkSuccess: true,
73 passMsg: '',
74 uniformBlocks: [{name: "Stuff", value: new Float32Array([
75 // mat4 u_mat[3]
76 1, 2, 3, 4,
77 5, 6, 7, 8,
78 9, 10, 11, 12,
79 13, 14, 15, 16,
81 // +-- we should be pulling out this column
82 // |
83 // V
84 1, 5, 9, 13,
85 2, 6, 10, 14,
86 3, 7, 11, 15,
87 4, 8, 12, 16,
89 2, 10, 18, 22,
90 4, 12, 20, 28,
91 6, 14, 22, 30,
92 8, 16, 24, 32,
94 // mat4 u_ndx[3]
95 0, 0, 0, 0,
96 0, 0, 0, 0,
97 0, 0, 0, 0,
98 0, 0, 0, 0,
100 0, 0, 0, 0,
101 0, 0, 0, 2,
102 0, 0, 0, 0,
103 0, 1, 0, 0,
104 // ^
105 // |
106 // +-- we should be reading this value as an index into u_mat
108 0, 0, 0, 0,
109 0, 0, 0, 0,
110 0, 0, 0, 0,
111 0, 0, 0, 0,
112 ])}],
114 ], 2);
115 </script>
116 </body>
117 </html>