| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <meta charset="utf-8"> | |
| 5 <title>WebGL uniform 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 uniform locations.</div> | |
| 15 <div id="console"></div> | |
| 16 <script id="goodVertexShader1" type="x-shader/x-vertex"> | |
| 17 // A vertex shader where the uniform name is long, but well below the limit. | |
| 18 struct Nesting2 { | |
| 19 vec4 identifier62CharactersLong_01234567890123456789012345678901234; | |
| 20 }; | |
| 21 | |
| 22 struct Nesting1 { | |
| 23 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456; | |
| 24 }; | |
| 25 | |
| 26 uniform Nesting1 identifier70CharactersLong_012345678901234567890123456789012345
67890; | |
| 27 | |
| 28 void main() { | |
| 29 gl_Position = identifier70CharactersLong_01234567890123456789012345678901234
567890.identifier64CharactersLong_0123456789012345678901234567890123456.identifi
er62CharactersLong_01234567890123456789012345678901234; | |
| 30 } | |
| 31 </script> | |
| 32 <script id="goodVertexShader2" type="x-shader/x-vertex"> | |
| 33 // A vertex shader where the needed uniform location is exactly 256 characters. | |
| 34 struct Nesting2 { | |
| 35 vec4 identifier62CharactersLong_01234567890123456789012345678901234; | |
| 36 }; | |
| 37 | |
| 38 struct Nesting1 { | |
| 39 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456; | |
| 40 }; | |
| 41 | |
| 42 uniform Nesting1 identifier128CharactersLong_01234567890123456789012345678901234
56789012345678901234567890123456789012345678901234567890123456789; | |
| 43 | |
| 44 void main() { | |
| 45 gl_Position = identifier128CharactersLong_0123456789012345678901234567890123
456789012345678901234567890123456789012345678901234567890123456789.identifier64C
haractersLong_0123456789012345678901234567890123456.identifier62CharactersLong_0
1234567890123456789012345678901234; | |
| 46 } | |
| 47 </script> | |
| 48 <script id="badVertexShader" type="x-shader/x-vertex"> | |
| 49 // A vertex shader where the needed uniform location is 257 characters. | |
| 50 struct Nesting2 { | |
| 51 vec4 identifier63CharactersLong_012345678901234567890123456789012345; | |
| 52 }; | |
| 53 | |
| 54 struct Nesting1 { | |
| 55 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456; | |
| 56 }; | |
| 57 | |
| 58 uniform Nesting1 identifier128CharactersLong_01234567890123456789012345678901234
56789012345678901234567890123456789012345678901234567890123456789; | |
| 59 | |
| 60 void main() { | |
| 61 Nesting2 temp = identifier128CharactersLong_01234567890123456789012345678901
23456789012345678901234567890123456789012345678901234567890123456789.identifier6
4CharactersLong_0123456789012345678901234567890123456; | |
| 62 gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789
012345; | |
| 63 } | |
| 64 </script> | |
| 65 <script id="fragmentShader" type="x-shader/x-fragment"> | |
| 66 precision mediump float; | |
| 67 | |
| 68 void main() { | |
| 69 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); | |
| 70 } | |
| 71 </script> | |
| 72 <script> | |
| 73 if (window.initNonKhronosFramework) { | |
| 74 window.initNonKhronosFramework(false); | |
| 75 } | |
| 76 | |
| 77 if (window.internals) | |
| 78 window.internals.settings.setWebGLErrorsToConsoleEnabled(false); | |
| 79 | |
| 80 var wtu = WebGLTestUtils; | |
| 81 var gl = wtu.create3DContext(document.getElementById("example")); | |
| 82 | |
| 83 debug("Test uniform location underneath the length limit"); | |
| 84 var program = wtu.loadProgramFromScript(gl, "goodVertexShader1", "fragmentShader
"); | |
| 85 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); | |
| 86 var uniformLoc = gl.getUniformLocation(program, "identifier70CharactersLong_0123
4567890123456789012345678901234567890.identifier64CharactersLong_012345678901234
5678901234567890123456.identifier62CharactersLong_012345678901234567890123456789
01234"); | |
| 87 shouldBeNonNull('uniformLoc'); | |
| 88 wtu.glErrorShouldBe(gl, gl.NONE); | |
| 89 | |
| 90 debug("Test uniform location exactly at the length limit"); | |
| 91 var program = wtu.loadProgramFromScript(gl, "goodVertexShader2", "fragmentShader
"); | |
| 92 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); | |
| 93 var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
34567890123456789.identifier64CharactersLong_01234567890123456789012345678901234
56.identifier62CharactersLong_01234567890123456789012345678901234"); | |
| 94 shouldBeNonNull('uniformLoc'); | |
| 95 wtu.glErrorShouldBe(gl, gl.NONE); | |
| 96 | |
| 97 debug("Test uniform location over the length limit"); | |
| 98 program = wtu.loadProgramFromScript(gl, "badVertexShader", "fragmentShader"); | |
| 99 wtu.glErrorShouldBe(gl, gl.NONE); | |
| 100 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); | |
| 101 var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_012
34567890123456789012345678901234567890123456789012345678901234567890123456789012
34567890123456789.identifier64CharactersLong_01234567890123456789012345678901234
56.identifier63CharactersLong_012345678901234567890123456789012345"); | |
| 102 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE); | |
| 103 shouldBeNull('uniformLoc'); | |
| 104 | |
| 105 </script> | |
| 106 </body> | |
| 107 </html> | |
| OLD | NEW |