Bug 1918529 - fix some subpixel misalignment issues with gfx.webrender.svg-filter...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / glsl / misc / shaders-with-uniform-structs.html
blob8713bd0cbe45fe1cd9c02e57c2f0328e30feb77c
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>WebGL GLSL Conformance Tests</title>
12 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
13 <link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
14 <script src="../../../js/js-test-pre.js"></script>
15 <script src="../../../js/webgl-test-utils.js"></script>
16 <script src="../../../js/glsl-conformance-test.js"></script>
17 </head>
18 <body>
19 <div id="description"></div>
20 <div id="console"></div>
21 <script id="vertexShaderStructSequence" type="text/something-not-javascript">
22 // Structures must have the same name, sequence of type names, and
23 // type definitions, and field names to be considered the same type.
24 // GLSL 1.017 4.2.4
25 precision mediump float;
26 struct info {
27 vec4 pos;
28 vec4 color;
31 uniform info uni;
32 void main()
34 gl_Position = uni.pos;
36 </script>
37 <script id="fragmentShaderStructSequence" type="text/something-not-javascript">
38 // Structures must have the same name, sequence of type names, and
39 // type definitions, and field names to be considered the same type.
40 // GLSL 1.017 4.2.4
41 precision mediump float;
42 struct info {
43 vec4 color;
44 vec4 pos;
47 uniform info uni;
48 void main()
50 gl_FragColor = uni.color;
52 </script>
53 <script id="vertexShaderStructName" type="text/something-not-javascript">
54 // Structures must have the same name, sequence of type names, and
55 // type definitions, and field names to be considered the same type.
56 // GLSL 1.017 4.2.4
57 precision mediump float;
58 struct info {
59 vec4 pos;
60 vec4 color;
63 uniform info uni;
64 void main()
66 gl_Position = uni.pos;
68 </script>
69 <script id="fragmentShaderStructNameFailure" type="text/something-not-javascript">
70 // Structures must have the same name, sequence of type names, and
71 // type definitions, and field names to be considered the same type.
72 // GLSL 1.017 4.2.4
73 precision mediump float;
74 struct info1 {
75 vec4 pos;
76 vec4 color;
79 uniform info1 uni;
80 void main()
82 gl_FragColor = uni.color;
84 </script>
85 <script id="fragmentShaderStructNameSuccess" type="text/something-not-javascript">
86 // Structures must have the same name, sequence of type names, and
87 // type definitions, and field names to be considered the same type.
88 // GLSL 1.017 4.2.4
89 precision mediump float;
91 // Add a struct before info to make sure the struct info here is assigned
92 // a different internal unique ID from the struct info in vertex shader.
93 struct extra {
94 vec4 p;
97 struct info {
98 vec4 pos;
99 vec4 color;
102 uniform info uni;
103 void main()
105 extra my;
106 my.p = uni.color;
107 gl_FragColor = my.p;
109 </script>
110 <script id="vertexShaderStructFieldName" type="text/something-not-javascript">
111 // Structures must have the same name, sequence of type names, and
112 // type definitions, and field names to be considered the same type.
113 // GLSL 1.017 4.2.4
114 precision mediump float;
115 struct info {
116 vec4 pos;
117 vec4 color;
120 uniform info uni;
121 void main()
123 gl_Position = uni.pos;
125 </script>
126 <script id="fragmentShaderStructFieldName" type="text/something-not-javascript">
127 // Structures must have the same name, sequence of type names, and
128 // type definitions, and field names to be considered the same type.
129 // GLSL 1.017 4.2.4
130 precision mediump float;
131 struct info {
132 vec4 pos1;
133 vec4 color;
136 uniform info uni;
137 void main()
139 gl_FragColor = uni.color;
141 </script>
142 <script id="vertexShaderStructFieldType" type="text/something-not-javascript">
143 // Structures must have the same name, sequence of type names, and
144 // type definitions, and field names to be considered the same type.
145 // GLSL 1.017 4.2.4
146 precision mediump float;
147 struct info {
148 vec4 pos;
149 vec4 color;
152 uniform info uni;
153 void main()
155 gl_Position = uni.pos;
157 </script>
158 <script id="fragmentShaderStructFieldType" type="text/something-not-javascript">
159 // Structures must have the same name, sequence of type names, and
160 // type definitions, and field names to be considered the same type.
161 // GLSL 1.017 4.2.4
162 precision mediump float;
163 struct info {
164 vec3 pos;
165 vec4 color;
168 uniform info uni;
169 void main()
171 gl_FragColor = uni.color;
173 </script>
174 <script id="vertexShaderStructFieldPrecision" type="text/something-not-javascript">
175 // Structures must have the same name, sequence of type names, and
176 // type definitions, and field names to be considered the same type.
177 // GLSL 1.017 4.2.4
178 struct info {
179 mediump vec4 pos;
180 highp vec4 color;
183 uniform info uni;
184 void main()
186 gl_Position = uni.pos;
188 </script>
189 <script id="fragmentShaderStructFieldPrecision" type="text/something-not-javascript">
190 // Structures must have the same name, sequence of type names, and
191 // type definitions, and field names to be considered the same type.
192 // GLSL 1.017 4.2.4
193 precision mediump float;
194 struct info {
195 vec4 pos;
196 vec4 color;
199 uniform info uni;
200 void main()
202 gl_FragColor = uni.color;
204 </script>
205 <script id="vertexShaderUnnamedStruct" type="text/something-not-javascript">
206 // ANGLE regression on Windows, crbug.com/401296
207 uniform struct {
208 float f;
209 vec4 v;
210 } u_struct;
212 void main()
214 gl_Position = u_struct.f * u_struct.v;
216 </script>
217 <script id="fragmentShaderSimple" type="text/something-not-javascript">
218 void main()
220 gl_FragColor = vec4(1.0);
222 </script>
223 <script>
224 "use strict";
225 var wtu = WebGLTestUtils;
227 var tests = [];
228 tests.push({
229 vShaderSource: wtu.getScript("vertexShaderStructName"),
230 vShaderSuccess: true,
231 fShaderSource: wtu.getScript("fragmentShaderStructNameSuccess"),
232 fShaderSuccess: true,
233 linkSuccess: true,
234 passMsg: "Structures with the same defination must be considered the same type.",
236 tests.push({
237 vShaderSource: wtu.getScript("vertexShaderStructName"),
238 vShaderSuccess: true,
239 fShaderSource: wtu.getScript("fragmentShaderStructNameFailure"),
240 fShaderSuccess: true,
241 linkSuccess: false,
242 passMsg: "Structures must have the same name to be considered the same type.",
244 tests.push({
245 vShaderSource: wtu.getScript("vertexShaderStructSequence"),
246 vShaderSuccess: true,
247 fShaderSource: wtu.getScript("fragmentShaderStructSequence"),
248 fShaderSuccess: true,
249 linkSuccess: false,
250 passMsg: "Structures must have the same sequence of type names to be considered the same type.",
252 tests.push({
253 vShaderSource: wtu.getScript("vertexShaderStructFieldName"),
254 vShaderSuccess: true,
255 fShaderSource: wtu.getScript("fragmentShaderStructFieldName"),
256 fShaderSuccess: true,
257 linkSuccess: false,
258 passMsg: "Structures must have the same field names to be considered the same type.",
260 tests.push({
261 vShaderSource: wtu.getScript("vertexShaderStructFieldType"),
262 vShaderSuccess: true,
263 fShaderSource: wtu.getScript("fragmentShaderStructFieldType"),
264 fShaderSuccess: true,
265 linkSuccess: false,
266 passMsg: "Structures must have the same type definitions to be considered the same type.",
268 tests.push({
269 vShaderSource: wtu.getScript("vertexShaderStructFieldPrecision"),
270 vShaderSuccess: true,
271 fShaderSource: wtu.getScript("fragmentShaderStructFieldPrecision"),
272 fShaderSuccess: true,
273 linkSuccess: false,
274 passMsg: "Structures must have the same type definitions (including precision) to be considered the same type.",
276 tests.push({
277 vShaderSource: wtu.getScript("vertexShaderUnnamedStruct"),
278 vShaderSuccess: true,
279 fShaderSource: wtu.getScript("fragmentShaderSimple"),
280 fShaderSuccess: true,
281 linkSuccess: true,
282 passMsg: "Shaders with uniforms of unnamed struct type should compile and link successfully.",
285 GLSLConformanceTester.runTests(tests);
286 var successfullyParsed = true;
287 </script>
288 </body>
289 </html>