4 ** Copyright (c) 2014 The Khronos Group Inc.
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
31 <meta charset="utf-8">
32 <title>WebGL GLSL Conformance Tests</title>
33 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
34 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
35 <script src="../../../resources/js-test-pre.js"></script>
36 <script src="../../resources/webgl-test-utils.js"></script>
37 <script src="../../resources/glsl-conformance-test.js"></script>
40 <div id="description"></div>
41 <div id="console"></div>
42 <script id="vertexShaderStructSequence" type="text/something-not-javascript">
43 // Structures must have the same name, sequence of type names, and
44 // type definitions, and field names to be considered the same type.
46 precision mediump float;
55 gl_Position = uni.pos;
58 <script id="fragmentShaderStructSequence" type="text/something-not-javascript">
59 // Structures must have the same name, sequence of type names, and
60 // type definitions, and field names to be considered the same type.
62 precision mediump float;
71 gl_FragColor = uni.color;
74 <script id="vertexShaderStructName" type="text/something-not-javascript">
75 // Structures must have the same name, sequence of type names, and
76 // type definitions, and field names to be considered the same type.
78 precision mediump float;
87 gl_Position = uni.pos;
90 <script id="fragmentShaderStructNameFailure" type="text/something-not-javascript">
91 // Structures must have the same name, sequence of type names, and
92 // type definitions, and field names to be considered the same type.
94 precision mediump float;
103 gl_FragColor = uni.color;
106 <script id="fragmentShaderStructNameSuccess" type="text/something-not-javascript">
107 // Structures must have the same name, sequence of type names, and
108 // type definitions, and field names to be considered the same type.
110 precision mediump float;
112 // Add a struct before info to make sure the struct info here is assigned
113 // a different internal unique ID from the struct info in vertex shader.
131 <script id="vertexShaderStructFieldName" type="text/something-not-javascript">
132 // Structures must have the same name, sequence of type names, and
133 // type definitions, and field names to be considered the same type.
135 precision mediump float;
144 gl_Position = uni.pos;
147 <script id="fragmentShaderStructFieldName" type="text/something-not-javascript">
148 // Structures must have the same name, sequence of type names, and
149 // type definitions, and field names to be considered the same type.
151 precision mediump float;
160 gl_FragColor = uni.color;
163 <script id="vertexShaderStructFieldType" type="text/something-not-javascript">
164 // Structures must have the same name, sequence of type names, and
165 // type definitions, and field names to be considered the same type.
167 precision mediump float;
176 gl_Position = uni.pos;
179 <script id="fragmentShaderStructFieldType" type="text/something-not-javascript">
180 // Structures must have the same name, sequence of type names, and
181 // type definitions, and field names to be considered the same type.
183 precision mediump float;
192 gl_FragColor = uni.color;
195 <script id="vertexShaderStructFieldPrecision" type="text/something-not-javascript">
196 // Structures must have the same name, sequence of type names, and
197 // type definitions, and field names to be considered the same type.
207 gl_Position = uni.pos;
210 <script id="fragmentShaderStructFieldPrecision" type="text/something-not-javascript">
211 // Structures must have the same name, sequence of type names, and
212 // type definitions, and field names to be considered the same type.
214 precision mediump float;
223 gl_FragColor = uni.color;
226 <script id="vertexShaderUnnamedStruct" type="text/something-not-javascript">
227 // ANGLE regression on Windows, crbug.com/401296
235 gl_Position = u_struct.f * u_struct.v;
238 <script id="fragmentShaderSimple" type="text/something-not-javascript">
241 gl_FragColor = vec4(1.0);
246 var wtu = WebGLTestUtils;
250 vShaderSource: wtu.getScript("vertexShaderStructName"),
251 vShaderSuccess: true,
252 fShaderSource: wtu.getScript("fragmentShaderStructNameSuccess"),
253 fShaderSuccess: true,
255 passMsg: "Structures with the same defination must be considered the same type.",
258 vShaderSource: wtu.getScript("vertexShaderStructName"),
259 vShaderSuccess: true,
260 fShaderSource: wtu.getScript("fragmentShaderStructNameFailure"),
261 fShaderSuccess: true,
263 passMsg: "Structures must have the same name to be considered the same type.",
266 vShaderSource: wtu.getScript("vertexShaderStructSequence"),
267 vShaderSuccess: true,
268 fShaderSource: wtu.getScript("fragmentShaderStructSequence"),
269 fShaderSuccess: true,
271 passMsg: "Structures must have the same sequence of type names to be considered the same type.",
274 vShaderSource: wtu.getScript("vertexShaderStructFieldName"),
275 vShaderSuccess: true,
276 fShaderSource: wtu.getScript("fragmentShaderStructFieldName"),
277 fShaderSuccess: true,
279 passMsg: "Structures must have the same field names to be considered the same type.",
282 vShaderSource: wtu.getScript("vertexShaderStructFieldType"),
283 vShaderSuccess: true,
284 fShaderSource: wtu.getScript("fragmentShaderStructFieldType"),
285 fShaderSuccess: true,
287 passMsg: "Structures must have the same type definitions to be considered the same type.",
290 vShaderSource: wtu.getScript("vertexShaderStructFieldPrecision"),
291 vShaderSuccess: true,
292 fShaderSource: wtu.getScript("fragmentShaderStructFieldPrecision"),
293 fShaderSuccess: true,
295 passMsg: "Structures must have the same type definitions (including precision) to be considered the same type.",
298 vShaderSource: wtu.getScript("vertexShaderUnnamedStruct"),
299 vShaderSuccess: true,
300 fShaderSource: wtu.getScript("fragmentShaderSimple"),
301 fShaderSuccess: true,
303 passMsg: "Shaders with uniforms of unnamed struct type should compile and link successfully.",
306 GLSLConformanceTester.runTests(tests);
307 var successfullyParsed = true;