Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2077)

Side by Side Diff: third_party/webgl/sdk/tests/conformance/glsl/misc/shader-with-reserved-words.html

Issue 10399113: Roll webgl conformance tests to r17874: part 2, adding r17874 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
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:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
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.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8">
32 <title>WebGL GLSL Conformance Tests - Reserved Words</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>
38 </head>
39 <body>
40 <div id="description"></div>
41 <div id="console"></div>
42 <script id="vertexShader0" type="text/something-not-javascript">
43 struct $replaceMe {
44 vec4 $replaceMe;
45 };
46 struct Foo {
47 $replaceMe $replaceMe;
48 };
49 attribute vec4 position;
50 void main()
51 {
52 Foo f;
53 f.$replaceMe.$replaceMe = position;
54 gl_Position = f.$replaceMe.$replaceMe;
55 }
56 </script>
57 <script id="fragmentShader0" type="text/something-not-javascript">
58 precision mediump float;
59 vec4 $replaceMe() {
60 return vec4(0,1,0,1);
61 }
62 void main()
63 {
64 gl_FragColor = $replaceMe();
65 }
66 </script>
67 <script id="vertexShader1" type="text/something-not-javascript">
68 attribute vec4 $replaceMe;
69 void main()
70 {
71 gl_Position = $replaceMe;
72 }
73 </script>
74 <script id="fragmentShader1" type="text/something-not-javascript">
75 precision mediump float;
76 vec4 foo(vec4 $replaceMe) {
77 return $replaceMe;
78 }
79 void main()
80 {
81 gl_FragColor = foo(vec4(1,0,1,1));
82 }
83 </script>
84 <script id="vertexShader2" type="text/something-not-javascript">
85 varying vec4 $replaceMe;
86 attribute vec4 position;
87 void main()
88 {
89 gl_Position = position;
90 $replaceMe = position;
91 }
92 </script>
93 <script id="fragmentShader2" type="text/something-not-javascript">
94 precision mediump float;
95 varying vec4 $replaceMe;
96 void main()
97 {
98 gl_FragColor = $replaceMe;
99 }
100 </script>
101 <script id="vertexShader3" type="text/something-not-javascript">
102 attribute vec4 position;
103 void main()
104 {
105 gl_Position = position;
106 }
107 </script>
108 <script id="fragmentShader3" type="text/something-not-javascript">
109 precision mediump float;
110 uniform vec4 $replaceMe;
111 void main()
112 {
113 gl_FragColor = $replaceMe;
114 }
115 </script>
116 <script>
117 var GLSL_1_0_17_words = [
118 "attribute",
119 "const",
120 "uniform",
121 "varying",
122 "break",
123 "continue",
124 "do",
125 "for",
126 "while",
127 "if",
128 "else",
129 "in",
130 "out",
131 "inout",
132 "float",
133 "int",
134 "void",
135 "bool",
136 "true",
137 "false",
138 "lowp",
139 "mediump",
140 "highp",
141 "precision",
142 "invariant",
143 "discard",
144 "return",
145 "mat2",
146 "mat3",
147 "mat4",
148 "vec2",
149 "vec3",
150 "vec4",
151 "ivec2",
152 "ivec3",
153 "ivec4",
154 "bvec2",
155 "bvec3",
156 "bvec4",
157 "sampler2D",
158 "samplerCube",
159 "struct"
160 ]
161
162 var GLSL_1_0_17_FutureWords = [
163 "asm",
164 "class",
165 "union",
166 "enum",
167 "typedef",
168 "template",
169 "this",
170 "packed",
171 "goto",
172 "switch",
173 "default",
174 "inline",
175 "noinline",
176 "volatile",
177 "public",
178 "static",
179 "extern",
180 "external",
181 "interface",
182 "flat",
183 "long",
184 "short",
185 "double",
186 "half",
187 "fixed",
188 "unsigned",
189 "superp",
190 "input",
191 "output",
192 "hvec2",
193 "hvec3",
194 "hvec4",
195 "dvec2",
196 "dvec3",
197 "dvec4",
198 "fvec2",
199 "fvec3",
200 "fvec4",
201 "sampler1D",
202 "sampler3D",
203 "sampler1DShadow",
204 "sampler2DShadow",
205 "sampler2DRect",
206 "sampler3DRect",
207 "sampler2DRectShadow",
208 "sizeof",
209 "cast",
210 "namespace",
211 "using",
212 "__foo", // something that has 2 underscores
213 "foo__bar", // something that has 2 underscores
214 "gl_foo", // something that starts with gl_
215 "webgl_foo" // something that starts with webgl_
216 ];
217
218 description();
219
220 var wtu = WebGLTestUtils;
221 var gl = wtu.create3DContext();
222 var c = document.getElementById("console");
223
224 var reservedWordsLists = [
225 GLSL_1_0_17_words,
226 GLSL_1_0_17_FutureWords
227 ];
228
229 var reservedWords = [];
230 for (var ii = 0; ii < reservedWordsLists.length; ++ii) {
231 var list = reservedWordsLists[ii];
232 for (var jj = 0; jj < list.length; ++jj) {
233 reservedWords.push(list[jj]);
234 }
235 }
236
237 var src = [];
238 for (var ii = 0; ii < 4; ++ii) {
239 var vsrc = document.getElementById("vertexShader" + ii).text;
240 var fsrc = document.getElementById("fragmentShader" + ii).text;
241 src.push({vsrc: vsrc, fsrc: fsrc});
242 }
243
244 var wordNdx = 0;
245
246 function testNextWord() {
247 if (wordNdx >= reservedWords.length) {
248 finishTest();
249 return;
250 }
251 testWord(reservedWords[wordNdx]);
252 ++wordNdx;
253 setTimeout(testNextWord,1);
254 }
255 testNextWord();
256
257 function testWord(word) {
258 debug("");
259 debug("testing: " + word);
260
261 for (var ii = 0; ii < src.length; ++ii) {
262 var vs = src[ii].vsrc.replace(/\$replaceMe/g, word);
263 var fs = src[ii].fsrc.replace(/\$replaceMe/g, word);
264
265 wtu.addShaderSource(c, "vertex shader", vs);
266 wtu.addShaderSource(c, "fragment shader", fs);
267
268 var success = true;
269 var program = wtu.loadProgram(gl, vs, fs, function(msg) {
270 //debug(msg);
271 success = false;
272 });
273 if (success) {
274 testFailed("shader with: '" + word + "' compiled even though it should not ");
275 } else {
276 testPassed("shader with: '" + word + "' correctly failed to compile");
277 }
278 if (program) {
279 gl.deleteProgram(program);
280 }
281 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no GL errors");
282 }
283 }
284
285
286 successfullyParsed = true;
287 </script>
288 </body>
289 </html>
290
291
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698