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

Side by Side Diff: conformance/glsl-conformance.html

Issue 8344024: Remove older revision of webgl conformance tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 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
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta charset="utf-8">
10 <title>WebGL GLSL Conformance Tests</title>
11 <link rel="stylesheet" href="../resources/js-test-style.css"/>
12 <script src="../resources/desktop-gl-constants.js" type="text/javascript"></scri pt>
13 <script src="../resources/js-test-pre.js"></script>
14 <script src="resources/webgl-test-utils.js"></script>
15 </head>
16 <body>
17 <div id="description"></div>
18 <div id="console"></div>
19 <script id="vshader" type="text/something-not-javascript">
20 attribute vec4 vPosition;
21 void main()
22 {
23 gl_Position = vPosition;
24 }
25 </script>
26 <script id="fshader" type="text/something-not-javascript">
27 precision mediump float;
28 void main()
29 {
30 gl_FragColor = vec4(1.0,0.0,0.0,1.0);
31 }
32 </script>
33 <script id="fshaderWithPrecision" type="text/something-not-javascript">
34 void main()
35 {
36 mediump vec4 color = vec4(1.0, 0.0, 0.0, 1.0);
37 gl_FragColor = color;
38 }
39 </script>
40 <script id="vshaderWithDefaultPrecision" type="text/something-not-javascript">
41 precision mediump float;
42 attribute vec4 vPosition;
43 void main()
44 {
45 gl_Position = vPosition;
46 }
47 </script>
48 <script id="fshaderWithDefaultPrecision" type="text/something-not-javascript">
49 precision mediump float;
50 void main()
51 {
52 gl_FragColor = vec4(1.0,0.0,0.0,1.0);
53 }
54 </script>
55 <script id="fshaderWithOutPrecision" type="text/something-not-javascript">
56 uniform vec4 color;
57 void main()
58 {
59 gl_FragColor = color;
60 }
61 </script>
62 <script id="fshaderWithInvalidIdentifier" type="text/something-not-javascript">
63 precision mediump float;
64 uniform float gl_foo;
65 void main()
66 {
67 gl_FragColor = vec4(gl_foo,0.0,0.0,1.0);
68 }
69 </script>
70 <script id="fshaderWithGL_ESeq1" type="text/something-not-javascript">
71 #if GL_ES == 1
72 precision mediump float;
73 void main()
74 {
75 gl_FragColor = vec4(0.0,0.0,0.0,1.0);
76 }
77 #else
78 foo
79 #endif
80 </script>
81 <script id="fshaderWithGLSLPreprocessorSymbol" type="text/something-not-javascri pt">
82 #if defined(GL_ES)
83 precision mediump float;
84 void main()
85 {
86 gl_FragColor = vec4(0.0,0.0,0.0,1.0);
87 }
88 #else
89 foo
90 #endif
91 </script>
92 <script id="fshaderWithVERSION100PreprocessorSymbol" type="text/something-not-ja vascript">
93 #if __VERSION__ == 100
94 precision mediump float;
95 void main()
96 {
97 gl_FragColor = vec4(0.0,0.0,0.0,1.0);
98 }
99 #else
100 foo
101 #endif
102 </script>
103 <script id="fshaderWithUndefinedPreprocessorSymbol" type="text/something-not-jav ascript">
104 #if UNDEFINED_FOO
105 // according to ES GLSL spec 3.4 undefined symbols should fail.
106 #else
107 precision mediump float;
108 void main()
109 {
110 gl_FragColor = vec4(0.0,0.0,0.0,1.0);
111 }
112 #endif
113 </script>
114 <script id="fshaderWithFragDepth" type="text/something-not-javascript">
115 precision mediump float;
116 void main()
117 {
118 gl_FragColor = vec4(0.0,0.0,0.0,1.0);
119 gl_FragDepth = 1.0;
120 }
121 </script>
122 <script id="vshaderWithClipVertex" type="text/something-not-javascript">
123 attribute vec4 vPosition;
124 void main()
125 {
126 gl_Position = vPosition;
127 gl_ClipVertex = vPosition;
128 }
129 </script>
130 <script id="fshaderWith__Define" type="text/something-not-javascript">
131 #define __foo 1
132 precision mediump float;
133 void main()
134 {
135 gl_FragColor = vec4(0.0,0.0,0.0,1.0);
136 }
137 </script>
138 <script id="fshaderWithGL_Define" type="text/something-not-javascript">
139 #define GL_FOO 1
140 precision mediump float;
141 void main()
142 {
143 gl_FragColor = vec4(0.0,0.0,0.0,1.0);
144 }
145 </script>
146 <script id="fshaderWithDefineLineContinuation" type="text/something-not-javascri pt">
147 #define foo this \
148 is a test
149 precision mediump float;
150 void main()
151 {
152 gl_FragColor = vec4(0.0,0.0,0.0,1.0);
153 }
154 </script>
155 <script id="vshaderWithgl_Color" type="text/something-not-javascript">
156 attribute vec4 vPosition;
157 void main()
158 {
159 gl_Position = gl_Color;
160 }
161 </script>
162 <script id="vshaderWithgl_ProjectionMatrix" type="text/something-not-javascript" >
163 attribute vec4 vPosition;
164 void main()
165 {
166 gl_Position = vPosition * gl_ProjectionMatrix;
167 }
168 </script>
169 <script id="vshaderWithAttributeArray" type="text/something-not-javascript">
170 attribute vec4 vPosition[2];
171 void main()
172 {
173 gl_Position = vPosition[0] + vPosition[1];
174 }
175 </script>
176 <script id="vshaderWithwebgl_" type="text/something-not-javascript">
177 attribute vec4 webgl_vPosition;
178 void main()
179 {
180 gl_Position = webgl_vPosition;
181 }
182 </script>
183 <script id="vshaderWith_webgl_" type="text/something-not-javascript">
184 attribute vec4 _webgl_vPosition;
185 void main()
186 {
187 gl_Position = _webgl_vPosition;
188 }
189 </script>
190 <script id="vshaderWithImplicitVec3Cast" type="text/something-not-javascript">
191 attribute vec4 vPosition;
192 void main()
193 {
194 mediump vec3 k = vec3(1, 2, 3);
195 gl_Position = k;
196 }
197 </script>
198 <script id="vshaderWithExplicitIntCast" type="text/something-not-javascript">
199 attribute vec4 vPosition;
200 void main()
201 {
202 int k = 123;
203 gl_Position = vec4(vPosition.x, vPosition.y, vPosition.z, float(k));
204 }
205 </script>
206 <script id="vshaderWithVersion130" type="text/something-not-javascript">
207 #version 130
208 attribute vec4 vPosition;
209 void main()
210 {
211 gl_Position = vPosition;
212 }
213 </script>
214 <script id="vshaderWithVersion120" type="text/something-not-javascript">
215 #version 120
216 attribute vec4 vPosition;
217 void main()
218 {
219 gl_Position = vPosition;
220 }
221 </script>
222 <script id="vshaderWithVersion100" type="text/something-not-javascript">
223 #version 100
224 attribute vec4 vPosition;
225 void main()
226 {
227 gl_Position = vPosition;
228 }
229 </script>
230 <script id="vshaderWithLineDirective" type="text/something-not-javascript">
231 #line 123
232 foo
233 </script>
234 <script id="vshaderWith__FILE__" type="text/something-not-javascript">
235 __FILE__
236 </script>
237 <script id="vshaderWithIncludeDirective" type="text/something-not-javascript">
238 // Sadly I can not force the current path so this could fail beacuse include.vs
239 // does not exist, not because #include is disallowed.
240 #include "include.vs"
241 attribute vec4 vPosition;
242 void main()
243 {
244 gl_Position = vPosition;
245 }
246 </script>
247 <script id="fshaderWithdFdx" type="text/something-not-javascript">
248 #extension GL_OES_standard_derivatives:enable
249 precision mediump float;
250 void main()
251 {
252 gl_FragColor = vec4(dFdx(0.5),0.0,0.0,1.0);
253 }
254 </script>
255 <script id="fshaderWithdFdxNoExt" type="text/something-not-javascript">
256 precision mediump float;
257 void main()
258 {
259 gl_FragColor = vec4(dFdx(0.5),0.0,0.0,1.0);
260 }
261 </script>
262 <script id="fshaderWith256CharacterIdentifier" type="text/something-not-javascri pt">
263 precision mediump float;
264 uniform float a12345678901234567890123456789012345678901234567890123456789012345 67890123456789012345678901234567890123456789012345678901234567890123456789012345 67890123456789012345678901234567890123456789012345678901234567890123456789012345 678901234567890123456789012345;
265 void main()
266 {
267 gl_FragColor = vec4(a123456789012345678901234567890123456789012345678901234567 89012345678901234567890123456789012345678901234567890123456789012345678901234567 89012345678901234567890123456789012345678901234567890123456789012345678901234567 89012345678901234567890123456789012345,0.0,0.0,1.0);
268 }
269 </script>
270 <script id="fshaderWith257CharacterIdentifier" type="text/something-not-javascri pt">
271 precision mediump float;
272 uniform float a12345678901234567890123456789012345678901234567890123456789012345 67890123456789012345678901234567890123456789012345678901234567890123456789012345 67890123456789012345678901234567890123456789012345678901234567890123456789012345 6789012345678901234567890123456;
273 void main()
274 {
275 gl_FragColor = vec4(a123456789012345678901234567890123456789012345678901234567 89012345678901234567890123456789012345678901234567890123456789012345678901234567 89012345678901234567890123456789012345678901234567890123456789012345678901234567 890123456789012345678901234567890123456,0.0,0.0,1.0);
276 }
277 </script>
278 <script id="fshaderWithLongLine" type="text/something-not-javascript">
279 precision mediump float;
280 uniform float fooo;
281 #if defined(someSymbolNotDefined)
282 #error long
283 #endif
284 void main()
285 {
286 gl_FragColor = vec4(fooo+fooo+fooo+fooo, fooo+fooo+fooo+fooo, fooo+fooo+fooo +fooo, 1.0);
287 }
288 </script>
289 <script id="fshaderWithErrorDirective" type="text/something-not-javascript">
290 #error testing123 testing123
291 void main()
292 {
293 gl_FragColor = vec4(0,0,0,0);
294 }
295 </script>
296 <script id="fshaderWithQuotedErrorDirective" type="text/something-not-javascript ">
297 #error "testing123 testing123" // will return INVALID_VALUE. See WebGL 6.18
298 void main()
299 {
300 gl_FragColor = vec4(0,0,0,0);
301 }
302 </script>
303 <script id="fshaderWithNonASCIIErrorDirective" type="text/something-not-javascri pt">
304 #error ‚±‚ê‚Í‚`‚r‚b‚h‚h‚ł͂Ȃ¢ // will return INVALID_VALUE. See WebGL 6.18
305 void main()
306 {
307 gl_FragColor = vec4(0,0,0,0);
308 }
309 </script>
310 <canvas id="canvas" width="2" height="2"> </canvas>
311 <script>
312 description("This test ensures WebGL implementations allow proper GLES2 shaders compile and improper ones fail.");
313
314 debug("");
315 debug("Canvas.getContext");
316
317 var wtu = WebGLTestUtils;
318 var gl = wtu.create3DContext(document.getElementById("canvas"));
319 if (!gl) {
320 testFailed("context does not exist");
321 } else {
322 testPassed("context exists");
323
324 debug("");
325 debug("Checking various GLSL programs.");
326
327 function log(msg) {
328 if (window.console && window.console.log) {
329 window.console.log(msg);
330 }
331 }
332
333 var shaderInfo = [
334 { vShaderId: 'vshader',
335 vShaderSuccess: true,
336 fShaderId: 'fshaderWithPrecision',
337 fShaderSuccess: true,
338 linkSuccess: true,
339 passMsg: 'frament shader with precision compiled and linked'
340 },
341 { vShaderId: 'vshader',
342 vShaderSuccess: true,
343 fShaderId: 'fshaderWithDefaultPrecision',
344 fShaderSuccess: true,
345 linkSuccess: true,
346 passMsg: 'fragment shader with default precision compiled and linked'
347 },
348 { vShaderId: 'vshaderWithDefaultPrecision',
349 vShaderSuccess: true,
350 fShaderId: 'fshader',
351 fShaderSuccess: true,
352 linkSuccess: true,
353 passMsg: 'vertex shader with default precision compiled and linked'
354 },
355 { vShaderId: 'vshader',
356 vShaderSuccess: true,
357 fShaderId: 'fshaderWithOutPrecision',
358 fShaderSuccess: false,
359 linkSuccess: false,
360 passMsg: 'fragment shader without precision should fail',
361 },
362 { vShaderId: 'vshader',
363 vShaderSuccess: true,
364 fShaderId: 'fshaderWithInvalidIdentifier',
365 fShaderSuccess: false,
366 linkSuccess: false,
367 passMsg: 'fragment shader with gl_ identifier should fail',
368 },
369 { vShaderId: 'vshader',
370 vShaderSuccess: true,
371 fShaderId: 'fshaderWithGL_ESeq1',
372 fShaderSuccess: true,
373 linkSuccess: true,
374 passMsg: 'fragment shader that expects GL_ES == 1 should succeed',
375 },
376 { vShaderId: 'vshader',
377 vShaderSuccess: true,
378 fShaderId: 'fshaderWithGLSLPreprocessorSymbol',
379 fShaderSuccess: true,
380 linkSuccess: true,
381 passMsg: 'fragment shader that uses GL_ES preprocessor symbol should succe ed',
382 },
383 { vShaderId: 'vshader',
384 vShaderSuccess: true,
385 fShaderId: 'fshaderWithVERSION100PreprocessorSymbol',
386 fShaderSuccess: true,
387 linkSuccess: true,
388 passMsg: 'fragment shader that uses __VERSION__==100 should succeed',
389 },
390 { vShaderId: 'vshader',
391 vShaderSuccess: true,
392 fShaderId: 'fshaderWithUndefinedPreprocessorSymbol',
393 fShaderSuccess: false,
394 linkSuccess: false,
395 passMsg: 'fragment shader undefined preprocessor symbol should fail (3.4)' ,
396 },
397 { vShaderId: 'vshader',
398 vShaderSuccess: true,
399 fShaderId: 'fshaderWithFragDepth',
400 fShaderSuccess: false,
401 linkSuccess: false,
402 passMsg: 'fragment shader that uses gl_FragDepth should fail',
403 },
404 { vShaderId: 'vshader',
405 vShaderSuccess: true,
406 fShaderId: 'fshaderWithdFdx',
407 fShaderSuccess: false,
408 linkSuccess: false,
409 passMsg: 'fragment shader that uses dFdx should fail',
410 },
411 { vShaderId: 'vshader',
412 vShaderSuccess: true,
413 fShaderId: 'fshaderWithdFdxNoExt',
414 fShaderSuccess: false,
415 linkSuccess: false,
416 passMsg: 'fragment shader that uses dFdx without #extension should fail',
417 },
418 { vShaderId: 'vshaderWithClipVertex',
419 vShaderSuccess: false,
420 fShaderId: 'fshader',
421 fShaderSuccess: true,
422 linkSuccess: false,
423 passMsg: 'vertex shader that uses gl_ClipVertex should fail',
424 },
425 //{ vShaderId: 'vshader',
426 // vShaderSuccess: true,
427 // fShaderId: 'fshaderWith__Define',
428 // fShaderSuccess: false,
429 // linkSuccess: false,
430 // passMsg: 'fragment shader that uses __ define should fail',
431 //},
432 //{ vShaderId: 'vshader',
433 // vShaderSuccess: true,
434 // fShaderId: 'fshaderWithGL_Define',
435 // fShaderSuccess: false,
436 // linkSuccess: false,
437 // passMsg: 'fragment shader that uses GL_ define should fail',
438 //},
439 { vShaderId: 'vshader',
440 vShaderSuccess: true,
441 fShaderId: 'fshaderWithDefineLineContinuation',
442 fShaderSuccess: false,
443 linkSuccess: false,
444 passMsg: 'fragment shader that uses has line continuation macro should fai l',
445 },
446 { vShaderId: 'vshaderWithgl_Color',
447 vShaderSuccess: false,
448 fShaderId: 'fshader',
449 fShaderSuccess: true,
450 linkSuccess: false,
451 passMsg: 'vertex shader that uses gl_Color should fail',
452 },
453 { vShaderId: 'vshaderWithgl_ProjectionMatrix',
454 vShaderSuccess: false,
455 fShaderId: 'fshader',
456 fShaderSuccess: true,
457 linkSuccess: false,
458 passMsg: 'vertex shader that uses gl_ProjectionMatrix should fail',
459 },
460 { vShaderId: 'vshaderWithAttributeArray',
461 vShaderSuccess: false,
462 fShaderId: 'fshader',
463 fShaderSuccess: true,
464 linkSuccess: false,
465 passMsg: 'vertex shader that uses attribute array should fail as per GLSL page 110, appendix A, section 5',
466 },
467 { vShaderId: 'vshaderWithwebgl_',
468 vShaderSuccess: false,
469 fShaderId: 'fshader',
470 fShaderSuccess: true,
471 linkSuccess: false,
472 passMsg: 'vertex shader that uses _webgl identifier should fail',
473 },
474 { vShaderId: 'vshaderWith_webgl_',
475 vShaderSuccess: false,
476 fShaderId: 'fshader',
477 fShaderSuccess: true,
478 linkSuccess: false,
479 passMsg: 'vertex shader that uses _webgl_ identifier should fail',
480 },
481 { vShaderId: 'vshaderWithExplicitIntCast',
482 vShaderSuccess: true,
483 fShaderId: 'fshader',
484 fShaderSuccess: true,
485 linkSuccess: true,
486 passMsg: 'vertex shader that explicit int to float cast should succeed',
487 },
488 { vShaderId: 'vshaderWithImplicitVec3Cast',
489 vShaderSuccess: false,
490 fShaderId: 'fshader',
491 fShaderSuccess: true,
492 linkSuccess: false,
493 passMsg: 'vertex shader that implicit vec3 to vec4 cast should fail',
494 },
495 { vShaderId: 'vshaderWithVersion130',
496 vShaderSuccess: false,
497 fShaderId: 'fshader',
498 fShaderSuccess: true,
499 linkSuccess: false,
500 passMsg: 'vertex shader uses the #version not 100 directive should fail',
501 },
502 { vShaderId: 'vshaderWithVersion120',
503 vShaderSuccess: false,
504 fShaderId: 'fshader',
505 fShaderSuccess: true,
506 linkSuccess: false,
507 passMsg: 'vertex shader uses the #version not 100 directive should fail',
508 },
509 { vShaderId: 'vshaderWithVersion100',
510 vShaderSuccess: true,
511 fShaderId: 'fshader',
512 fShaderSuccess: true,
513 linkSuccess: true,
514 passMsg: 'vertex shader uses the #version 100 directive should succeed',
515 },
516 { vShaderId: 'vshaderWithLineDirective',
517 vShaderSuccess: false,
518 vShaderTest: (function() { return wtu.getLastError().indexOf("124") >= 0; }),
519 fShaderId: 'fshader',
520 fShaderSuccess: true,
521 linkSuccess: false,
522 passMsg: 'vertex shader uses #line directive should report correct line',
523 },
524 { vShaderId: 'vshaderWithIncludeDirective',
525 vShaderSuccess: false,
526 fShaderId: 'fshader',
527 fShaderSuccess: true,
528 linkSuccess: false,
529 passMsg: 'vertex shader uses #include should fail',
530 },
531 { vShaderId: 'vshader',
532 vShaderSuccess: true,
533 fShaderId: 'fshaderWith257CharacterIdentifier',
534 fShaderSuccess: false,
535 linkSuccess: false,
536 passMsg: 'shader that uses 257 character identifier should fail',
537 },
538 { vShaderId: 'vshader',
539 vShaderSuccess: true,
540 fShaderId: 'fshaderWith256CharacterIdentifier',
541 fShaderSuccess: true,
542 linkSuccess: true,
543 passMsg: 'shader that uses 256 character identifier should succeed',
544 },
545 { vShaderId: 'vshader',
546 vShaderSuccess: true,
547 fShaderId: 'fshaderWithLongLine',
548 fShaderSuccess: true,
549 fShaderPrep: function(str) {
550 function expand(str, re, replacement, count) {
551 for (var ii = 0; ii < count; ++ii) {
552 str = str.replace(re, replacement);
553 }
554 return str;
555 }
556 str = expand(str, new RegExp(" ", 'g'), " ", 12);
557 var manyZeros = expand("0", new RegExp("0", 'g'), "00", 8).substring(2);
558 str = expand(str, new RegExp("0", 'g'), manyZeros, 1);
559 str = expand(str, new RegExp("fooo", 'g'), "fooofooo", 6);
560 str = expand(str, new RegExp("long", 'g'), "longlong", 6);
561 //debug("len:" + str.length);
562 //debug(str);
563 return str;
564 },
565 linkSuccess: true,
566 passMsg: 'shader that uses long lines should succeed',
567 },
568 { vShaderId: 'vshader',
569 vShaderSuccess: true,
570 fShaderId: 'fshaderWithErrorDirective',
571 fShaderSuccess: false,
572 fShaderTest: (function() {
573 return wtu.getLastError().indexOf("testing123 testing123") >= 0; }),
574 linkSuccess: false,
575 passMsg: "error directive returns error user's error message",
576 },
577 { vShaderId: 'vshader',
578 vShaderSuccess: true,
579 fShaderId: 'fshaderWithQuotedErrorDirective',
580 fShaderSuccess: false,
581 linkSuccess: false,
582 passMsg: "error directive using quotes fails",
583 },
584 { vShaderId: 'vshader',
585 vShaderSuccess: true,
586 fShaderId: 'fshaderWithNonASCIIErrorDirective',
587 fShaderSuccess: false,
588 linkSuccess: false,
589 passMsg: "error directive using characters outside of allowed set fails",
590 }
591 ];
592
593 // Read in all the shader source.
594 for (var ii = 0; ii < shaderInfo.length; ++ii) {
595 var si = shaderInfo[ii];
596 si.vShaderSource = document.getElementById(si.vShaderId).text;
597 si.fShaderSource = document.getElementById(si.fShaderId).text;
598 }
599
600 // Add more tests from external file
601 var simpleVertShader = document.getElementById('vshader').text;
602 var simpleFragShader = document.getElementById('fshader').text;
603
604 function addExternalShaders(filename, passMsg) {
605 var lines = wtu.readFileList(filename);
606 for (var ii = 0; ii < lines.length; ++ii) {
607 var info = {
608 vShaderId: 'vshader',
609 vShaderSource: simpleVertShader,
610 vShaderSuccess: true,
611 fShaderId: 'fshader',
612 fShaderSource: simpleFragShader,
613 fShaderSuccess: true,
614 linkSuccess: true,
615 };
616
617 var line = lines[ii];
618 var files = line.split(/ +/);
619 var passMsg = "";
620 for (var jj = 0; jj < files.length; ++jj) {
621 var file = files[jj];
622 var shaderSource = wtu.readFile(file);
623 var firstLine = shaderSource.split("\n")[0];
624 var success = undefined;
625 if (wtu.endsWith(firstLine, " fail") ||
626 wtu.endsWith(firstLine, " fail.")) {
627 success = false;
628 } else if (wtu.endsWith(firstLine, " succeed") ||
629 wtu.endsWith(firstLine, " succeed.")) {
630 success = true;
631 }
632 if (success === undefined) {
633 testFailed("bad first line in " + file + ":" + firstLine);
634 continue;
635 }
636 if (!wtu.startsWith(firstLine, "// ")) {
637 testFailed("bad first line in " + file + ":" + firstLine);
638 continue;
639 }
640 passMsg = passMsg + (passMsg.length ? ", " : "") + firstLine.substr(3);
641 if (wtu.endsWith(file, ".vert")) {
642 info.vShaderId = file;
643 info.vShaderSource = shaderSource;
644 info.vShaderSuccess = success;
645 } else if (wtu.endsWith(file, ".frag")) {
646 info.fShaderId = file;
647 info.fShaderSource = shaderSource;
648 info.fShaderSuccess = success;
649 }
650 }
651 info.linkSuccess = info.vShaderSuccess && info.fShaderSuccess;
652 info.passMsg = passMsg;
653 shaderInfo.push(info);
654 }
655 }
656
657 addExternalShaders('shaders/00_shaders.txt');
658
659 var vShaderDB = { };
660 var fShaderDB = { };
661
662 for (var ii = 0; ii < shaderInfo.length; ++ii) {
663 var info = shaderInfo[ii];
664 var passMsg = '[' + info.vShaderId + '/' + info.fShaderId + ']: ' +
665 info.passMsg
666 log(passMsg);
667
668 //debug(info.fShaderId);
669 var vSource = info.vShaderPrep ? info.vShaderPrep(info.vShaderSource) :
670 info.vShaderSource;
671
672 // Reuse identical shaders so we test shared shader.
673 var vShader = vShaderDB[vSource];
674 if (!vShader) {
675 vShader = wtu.loadShader(gl, vSource, gl.VERTEX_SHADER);
676 if (info.vShaderTest) {
677 if (!info.vShaderTest(vShader)) {
678 testFailed(passMsg);
679 continue;
680 }
681 }
682 if ((vShader != null) != info.vShaderSuccess) {
683 testFailed(passMsg);
684 continue;
685 }
686 // Save the shaders so we test shared shader.
687 if (vShader) {
688 vShaderDB[vSource] = vShader;
689 }
690 }
691
692 var fSource = info.fShaderPrep ? info.fShaderPrep(info.fShaderSource) :
693 info.fShaderSource;
694
695 // Reuse identical shaders so we test shared shader.
696 var fShader = fShaderDB[fSource];
697 if (!fShader) {
698 fShader = wtu.loadShader(gl, fSource, gl.FRAGMENT_SHADER);
699 if (info.fShaderTest) {
700 if (!info.fShaderTest(fShader)) {
701 testFailed(passMsg);
702 continue;
703 }
704 }
705 //debug(fShader == null ? "fail" : "succeed");
706 if ((fShader != null) != info.fShaderSuccess) {
707 testFailed(passMsg);
708 continue;
709 }
710 // Safe the shaders so we test shared shader.
711 if (fShader) {
712 fShaderDB[fSource] = fShader;
713 }
714 }
715
716 if (vShader && fShader) {
717 var program = gl.createProgram();
718 gl.attachShader(program, vShader);
719 gl.attachShader(program, fShader);
720 gl.linkProgram(program);
721 var linked = (gl.getProgramParameter(program, gl.LINK_STATUS) != 0);
722 if (!linked) {
723 var error = gl.getProgramInfoLog(program);
724 log("*** Error linking program '"+program+"':"+error);
725 }
726 if (linked != info.linkSuccess) {
727 testFailed(passMsg);
728 continue;
729 }
730 } else {
731 if (info.linkSuccess) {
732 testFailed(passMsg);
733 continue;
734 }
735 }
736 testPassed(passMsg);
737 }
738 }
739
740 debug("");
741 successfullyParsed = true;
742
743 </script>
744 <script src="../resources/js-test-post.js"></script>
745
746 </body>
747 </html>
OLDNEW
« no previous file with comments | « conformance/glsl-2types-of-textures-on-same-unit.html ('k') | conformance/glsl-long-variable-names.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698