Bug 1945965 – remove new tab April Fools logo. r=home-newtab-reviewers,reemhamz
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / glsl / misc / shader-struct-scope.html
bloba04faf03b150ee52882f9b1b34442ccce93bb161
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 <!-- author: Jamie Madill (jmadill at chromium) -->
9 <!DOCTYPE html>
10 <html>
11 <head>
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>
19 </head>
21 <body>
22 <div id="description"></div>
23 <div id="console"></div>
25 <script id="shader-vs-1" type="x-shader/x-vertex">
26 void main(void) {
28 gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
31 struct T {
32 int v1;
35 T x;
36 gl_Position.x += float(x.v1);
40 struct T {
41 float v2;
44 T x;
45 gl_Position.x += x.v2;
49 </script>
51 <script id="shader-vs-2" type="x-shader/x-vertex">
52 void main(void) {
54 gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
56 struct T {
57 int v1;
60 T x;
61 gl_Position.x += float(x.v1);
64 struct T {
65 float v2;
68 T x;
69 gl_Position.x += x.v2;
73 </script>
75 <script id="shader-vs-3" type="x-shader/x-vertex">
76 void main(void) {
78 gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
81 struct T {
82 int v1;
85 T x;
86 gl_Position.x += float(x.v1);
89 struct T {
90 float v2;
93 T x;
94 gl_Position.x += x.v2;
96 </script>
98 <script id="shader-vs-bad" type="x-shader/x-vertex">
99 void main(void) {
101 gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
103 struct T {
104 int v1;
107 T x;
108 gl_Position.x += float(x.v1);
110 struct T {
111 float v2;
114 T y;
115 gl_Position.x += y.v2;
117 </script>
119 <script id="shader-vs-anglebug" type="x-shader/x-vertex">
121 struct T_0 {
122 int v1;
125 void main(void) {
127 gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
129 struct T {
130 float v2;
133 T_0 x;
134 gl_Position.x += float(x.v1);
136 T y;
137 gl_Position.x += y.v2;
139 </script>
141 <script id="shader-vs-masked-struct-variable" type="x-shader/x-vertex">
143 struct T {
144 float f;
147 void main(void) {
149 T a;
151 gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
153 struct T {
154 float q;
157 gl_Position.x += a.f;
159 T b;
160 gl_Position.x += b.q;
162 </script>
164 <script id="shader-fs" type="x-shader/x-fragment">
165 precision mediump float;
166 void main(void) {
167 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
169 </script>
171 <script>
172 "use strict";
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,
182 linkSuccess: 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,
190 linkSuccess: 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,
198 linkSuccess: 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,
206 linkSuccess: false,
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,
214 linkSuccess: 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,
222 linkSuccess: true,
223 passMsg: "Variables of masked outer scope struct work with inner scope struct",
227 debug("");
228 var successfullyParsed = true;
229 </script>
230 </body>
231 </html>