OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <meta charset="utf-8"> | |
5 <title>WebGL attrib location length tests</title> | |
6 <script src="../../../resources/js-test.js"></script> | |
7 <script src="resources/webgl-test.js"> </script> | |
8 <script src="resources/webgl-test-utils.js"> </script> | |
9 </head> | |
10 <body> | |
11 <canvas id="example" width="50" height="50"> | |
12 There is supposed to be an example drawing here, but it's not important. | |
13 </canvas> | |
14 <div id="description">Verify limits on the lengths of attrib locations.</div> | |
15 <div id="console"></div> | |
16 <script id="goodVertexShader1" type="x-shader/x-vertex"> | |
17 // A vertex shader where the needed attrib location is long, but not over the li
mit. | |
18 attribute vec4 vPosition01234567890123456789012345678901234567890123456789012345
678901234567890; | |
19 | |
20 void main() | |
21 { | |
22 gl_Position = vPosition01234567890123456789012345678901234567890123456789012
345678901234567890; | |
23 } | |
24 </script> | |
25 <script id="goodVertexShader2" type="x-shader/x-vertex"> | |
26 // A vertex shader where the needed attrib location is exactly 256 characters. | |
27 attribute vec4 vPosition01234567890123456789012345678901234567890123456789012345
67890123456789012345678901234567890123456789012345678901234567890123456789012345
67890123456789012345678901234567890123456789012345678901234567890123456789012345
6789012345678901234567890123456; | |
28 | |
29 void main() | |
30 { | |
31 gl_Position = vPosition01234567890123456789012345678901234567890123456789012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
3456789012345678901234567890123456; | |
32 } | |
33 </script> | |
34 <script id="badVertexShader" type="x-shader/x-vertex"> | |
35 // A vertex shader where the needed attrib location is 257 characters. | |
36 attribute vec4 vPosition01234567890123456789012345678901234567890123456789012345
67890123456789012345678901234567890123456789012345678901234567890123456789012345
67890123456789012345678901234567890123456789012345678901234567890123456789012345
67890123456789012345678901234567; | |
37 | |
38 void main() | |
39 { | |
40 gl_Position = vPosition01234567890123456789012345678901234567890123456789012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
34567890123456789012345678901234567; | |
41 } | |
42 </script> | |
43 <script id="fragmentShader" type="x-shader/x-fragment"> | |
44 precision mediump float; | |
45 | |
46 void main() { | |
47 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); | |
48 } | |
49 </script> | |
50 <script> | |
51 if (window.initNonKhronosFramework) { | |
52 window.initNonKhronosFramework(false); | |
53 } | |
54 if (window.internals) | |
55 window.internals.settings.setWebGLErrorsToConsoleEnabled(false); | |
56 | |
57 var wtu = WebGLTestUtils; | |
58 var gl = wtu.create3DContext(document.getElementById("example")); | |
59 | |
60 debug("Test attrib location underneath the length limit"); | |
61 var program = wtu.loadProgramFromScript(gl, "goodVertexShader1", "fragmentShader
"); | |
62 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); | |
63 var attribLoc = gl.getAttribLocation(program, "vPosition012345678901234567890123
45678901234567890123456789012345678901234567890"); | |
64 if (attribLoc == -1) { | |
65 testFailed("attrib location was -1, should not be"); | |
66 } else { | |
67 testPassed("attrib location should not be -1"); | |
68 } | |
69 wtu.glErrorShouldBe(gl, gl.NONE); | |
70 | |
71 debug("Test attrib location exactly at the length limit"); | |
72 var program = wtu.loadProgramFromScript(gl, "goodVertexShader2", "fragmentShader
"); | |
73 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); | |
74 var attribLoc = gl.getAttribLocation(program, "vPosition012345678901234567890123
45678901234567890123456789012345678901234567890123456789012345678901234567890123
45678901234567890123456789012345678901234567890123456789012345678901234567890123
456789012345678901234567890123456789012345678901234567890123456"); | |
75 if (attribLoc == -1) { | |
76 testFailed("attrib location was -1, should not be"); | |
77 } else { | |
78 testPassed("attrib location should not be -1"); | |
79 } | |
80 wtu.glErrorShouldBe(gl, gl.NONE); | |
81 | |
82 debug("Test attrib location over the length limit"); | |
83 debug("Shader compilation should fail"); | |
84 shouldBe('wtu.loadShaderFromScript(gl, "badVertexShader", gl.VERTEX_SHADER, func
tion (err) {})', 'null'); | |
85 wtu.glErrorShouldBe(gl, gl.NONE); | |
86 | |
87 debug("Attempt to bind too-long attrib location should produce error"); | |
88 var program = gl.createProgram(); | |
89 gl.bindAttribLocation(program, 0, "vPosition012345678901234567890123456789012345
67890123456789012345678901234567890123456789012345678901234567890123456789012345
67890123456789012345678901234567890123456789012345678901234567890123456789012345
6789012345678901234567890123456789012345678901234567"); | |
90 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE); | |
91 | |
92 debug("Attempt to fetch too-long attrib location should produce error"); | |
93 shouldBe('gl.getAttribLocation(program, "vPosition012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567")', '-1'); | |
94 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE); | |
95 | |
96 </script> | |
97 </body> | |
98 </html> | |
OLD | NEW |