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.
7 <!-- author: Jamie Madill (jmadill at chromium) -->
12 <meta charset=
"utf-8">
13 <title>Struct Scope Test
</title>
14 <link rel=
"stylesheet" href=
"../../../resources/js-test-style.css"/>
15 <link rel=
"stylesheet" href=
"../../../resources/glsl-feature-tests.css"/>
16 <script src=
"../../../js/js-test-pre.js"></script>
17 <script src=
"../../../js/webgl-test-utils.js"></script>
18 <script src=
"../../../js/glsl-conformance-test.js"></script>
22 <div id=
"description"></div>
23 <div id=
"console"></div>
25 <script id=
"shader-vs-1" type=
"x-shader/x-vertex">
28 gl_Position = vec4(
0.0,
0.0,
0.0,
1.0);
36 gl_Position.x += float(x.v1);
45 gl_Position.x += x.v2;
51 <script id=
"shader-vs-2" type=
"x-shader/x-vertex">
54 gl_Position = vec4(
0.0,
0.0,
0.0,
1.0);
61 gl_Position.x += float(x.v1);
69 gl_Position.x += x.v2;
75 <script id=
"shader-vs-3" type=
"x-shader/x-vertex">
78 gl_Position = vec4(
0.0,
0.0,
0.0,
1.0);
86 gl_Position.x += float(x.v1);
94 gl_Position.x += x.v2;
98 <script id=
"shader-vs-bad" type=
"x-shader/x-vertex">
101 gl_Position = vec4(
0.0,
0.0,
0.0,
1.0);
108 gl_Position.x += float(x.v1);
115 gl_Position.x += y.v2;
119 <script id=
"shader-vs-anglebug" type=
"x-shader/x-vertex">
127 gl_Position = vec4(
0.0,
0.0,
0.0,
1.0);
134 gl_Position.x += float(x.v1);
137 gl_Position.x += y.v2;
141 <script id=
"shader-vs-masked-struct-variable" type=
"x-shader/x-vertex">
151 gl_Position = vec4(
0.0,
0.0,
0.0,
1.0);
157 gl_Position.x += a.f;
160 gl_Position.x += b.q;
164 <script id=
"shader-fs" type=
"x-shader/x-fragment">
165 precision mediump float;
167 gl_FragColor = vec4(
1.0,
0.0,
0.0,
1.0);
173 description("Testing struct definition scope");
175 var wtu
= WebGLTestUtils
;
176 GLSLConformanceTester
.runTests([
178 vShaderId
: "shader-vs-1",
179 vShaderSuccess
: true,
180 fShaderId
: "shader-fs",
181 fShaderSuccess
: true,
183 passMsg
: "Two structs defined within non-overlapping scopes should be able to use the same name",
186 vShaderId
: "shader-vs-2",
187 vShaderSuccess
: true,
188 fShaderId
: "shader-fs",
189 fShaderSuccess
: true,
191 passMsg
: "A struct defined inside a scope overrides a struct defined in a outer scope with the same name",
194 vShaderId
: "shader-vs-3",
195 vShaderSuccess
: true,
196 fShaderId
: "shader-fs",
197 fShaderSuccess
: true,
199 passMsg
: "A struct can use the same name of another out-of-scope struct",
202 vShaderId
: "shader-vs-bad",
203 vShaderSuccess
: false,
204 fShaderId
: "shader-fs",
205 fShaderSuccess
: true,
207 passMsg
: "A struct can't be defined with the same name as another struct defined in the same scope",
210 vShaderId
: "shader-vs-anglebug",
211 vShaderSuccess
: true,
212 fShaderId
: "shader-fs",
213 fShaderSuccess
: true,
215 passMsg
: "Structs with appended underscored numbers don't cause link errors (ANGLE bug)",
218 vShaderId
: "shader-vs-masked-struct-variable",
219 vShaderSuccess
: true,
220 fShaderId
: "shader-fs",
221 fShaderSuccess
: true,
223 passMsg
: "Variables of masked outer scope struct work with inner scope struct",
228 var successfullyParsed
= true;