3 ** Copyright (c) 2014 The Khronos Group Inc.
\r
5 ** Permission is hereby granted, free of charge, to any person obtaining a
\r
6 ** copy of this software and/or associated documentation files (the
\r
7 ** "Materials"), to deal in the Materials without restriction, including
\r
8 ** without limitation the rights to use, copy, modify, merge, publish,
\r
9 ** distribute, sublicense, and/or sell copies of the Materials, and to
\r
10 ** permit persons to whom the Materials are furnished to do so, subject to
\r
11 ** the following conditions:
\r
13 ** The above copyright notice and this permission notice shall be included
\r
14 ** in all copies or substantial portions of the Materials.
\r
16 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
17 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
18 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
\r
19 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
\r
20 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
\r
21 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
\r
22 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
\r
28 <meta charset="utf-8">
\r
29 <link rel="stylesheet" href="../../../resources/js-test-style.css" />
\r
30 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
\r
31 <script src="../../../resources/js-test-pre.js"></script>
\r
32 <script src="../../resources/webgl-test-utils.js"></script>
\r
33 <script src="../../resources/glsl-conformance-test.js"></script>
\r
37 <div id="description"></div>
\r
38 <div id="console"></div>
\r
39 <script id="fragmentShader" type="text/something-not-javascript">
\r
40 precision mediump float;
\r
41 struct S { $(outer_type) u; };
\r
43 S S; // This is legal, 'S' as a typename is defined in another scope.
\r
45 struct S { $(inner_type) a; }; // This is legal as well, 'S' is now defined as a variable name in an ancestor scope
\r
47 newvar.a = $(initializer);
\r
48 gl_FragColor = $(fragColor);
\r
54 description("This test verifies that defining a typename in a new scope when the typename is the name of a variable that hides a typename declaration succeeds for all combinations of GLSL types.");
\r
56 var wtu = WebGLTestUtils;
\r
58 { Type: 'float', initializer: '1.0', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' },
\r
59 { Type: 'vec2', initializer: 'vec2(0.0, 1.0)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' },
\r
60 { Type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', fragColor: 'vec4(newvar.a, 1.0)' },
\r
61 { Type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', fragColor: 'newvar.a' },
\r
62 { Type: 'int', initializer: '1', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' },
\r
63 { Type: 'ivec2', initializer: 'ivec2(0, 1)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' },
\r
64 { Type: 'ivec3', initializer: 'ivec3(0, 1, 0)', fragColor: 'vec4(newvar.a, 1.0)' },
\r
65 { Type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', fragColor: 'vec4(newvar.a)' },
\r
66 { Type: 'bool', initializer: 'true', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' },
\r
67 { Type: 'bvec2', initializer: 'bvec2(false, true)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' },
\r
68 { Type: 'bvec3', initializer: 'bvec3(false, true, false)', fragColor: 'vec4(newvar.a, 1.0)' },
\r
69 { Type: 'bvec4', initializer: 'bvec4(false,true,false,true)',fragColor: 'vec4(newvar.a)' },
\r
71 typeInfo.forEach(function (outerType) {
\r
72 typeInfo.forEach(function (innerType) {
\r
73 var replaceParams = {
\r
74 outer_type: outerType.Type,
\r
75 inner_type: innerType.Type,
\r
76 // use the initializer and fragColor for the inner type. Its definition should override the variable name in the outerscope.
\r
77 initializer: innerType.initializer,
\r
78 fragColor: innerType.fragColor
\r
81 fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
\r
82 passMsg: 'Outer struct type: ' + outerType.Type + ' inner struct type: ' + innerType.Type,
\r
83 fShaderSuccess: true,
\r
89 GLSLConformanceTester.runTests(tests);
\r
90 var successfullyParsed = true;
\r