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