OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>WebGL uniform 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 uniform locations per WebG
L 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 uniform location is exactly 256 characters. |
| 19 struct Nesting2 { |
| 20 vec4 identifier62CharactersLong_01234567890123456789012345678901234; |
| 21 }; |
| 22 |
| 23 struct Nesting1 { |
| 24 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456; |
| 25 }; |
| 26 |
| 27 uniform Nesting1 identifier128CharactersLong_01234567890123456789012345678901234
56789012345678901234567890123456789012345678901234567890123456789; |
| 28 |
| 29 void main() { |
| 30 gl_Position = identifier128CharactersLong_0123456789012345678901234567890123
456789012345678901234567890123456789012345678901234567890123456789.identifier64C
haractersLong_0123456789012345678901234567890123456.identifier62CharactersLong_0
1234567890123456789012345678901234; |
| 31 } |
| 32 </script> |
| 33 <script id="badVertexShader" type="x-shader/x-vertex"> |
| 34 // A vertex shader where the needed uniform location is 257 characters. |
| 35 struct Nesting2 { |
| 36 vec4 identifier63CharactersLong_012345678901234567890123456789012345; |
| 37 }; |
| 38 |
| 39 struct Nesting1 { |
| 40 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456; |
| 41 }; |
| 42 |
| 43 uniform Nesting1 identifier128CharactersLong_01234567890123456789012345678901234
56789012345678901234567890123456789012345678901234567890123456789; |
| 44 |
| 45 void main() { |
| 46 Nesting2 temp = identifier128CharactersLong_01234567890123456789012345678901
23456789012345678901234567890123456789012345678901234567890123456789.identifier6
4CharactersLong_0123456789012345678901234567890123456; |
| 47 gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789
012345; |
| 48 } |
| 49 </script> |
| 50 <script id="fragmentShader" type="x-shader/x-fragment"> |
| 51 precision mediump float; |
| 52 |
| 53 void main() { |
| 54 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); |
| 55 } |
| 56 </script> |
| 57 <script> |
| 58 if (window.initNonKhronosFramework) { |
| 59 window.initNonKhronosFramework(false); |
| 60 } |
| 61 |
| 62 var wtu = WebGLTestUtils; |
| 63 var gl = wtu.create3DContext(document.getElementById("example")); |
| 64 |
| 65 debug("Test uniform location underneath the length limit"); |
| 66 var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader"
); |
| 67 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); |
| 68 var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
34567890123456789.identifier64CharactersLong_01234567890123456789012345678901234
56.identifier62CharactersLong_01234567890123456789012345678901234"); |
| 69 shouldBeNonNull('uniformLoc'); |
| 70 wtu.glErrorShouldBe(gl, gl.NONE); |
| 71 |
| 72 debug("Test uniform location over the length limit"); |
| 73 program = wtu.loadProgramFromScript(gl, "badVertexShader", "fragmentShader"); |
| 74 wtu.glErrorShouldBe(gl, gl.NONE); |
| 75 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); |
| 76 var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
34567890123456789.identifier64CharactersLong_01234567890123456789012345678901234
56.identifier63CharactersLong_012345678901234567890123456789012345"); |
| 77 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE); |
| 78 shouldBeNull('uniformLoc'); |
| 79 |
| 80 successfullyParsed = true; |
| 81 </script> |
| 82 <script src="../../../resources/js-test-post.js"></script> |
| 83 </body> |
| 84 </html> |
OLD | NEW |