| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <!-- |
| |
| /* |
| ** Copyright (c) 2012 The Khronos Group Inc. |
| ** |
| ** Permission is hereby granted, free of charge, to any person obtaining a |
| ** copy of this software and/or associated documentation files (the |
| ** "Materials"), to deal in the Materials without restriction, including |
| ** without limitation the rights to use, copy, modify, merge, publish, |
| ** distribute, sublicense, and/or sell copies of the Materials, and to |
| ** permit persons to whom the Materials are furnished to do so, subject to |
| ** the following conditions: |
| ** |
| ** The above copyright notice and this permission notice shall be included |
| ** in all copies or substantial portions of the Materials. |
| ** |
| ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| */ |
| |
| --> |
| <title>WebGL uniform location length tests</title> |
| <link rel="stylesheet" href="../../../resources/js-test-style.css"/> |
| <link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/> |
| <script src="../../../js/js-test-pre.js"></script> |
| <script src="../../../js/webgl-test-utils.js"> </script> |
| </head> |
| <body> |
| <canvas id="example" width="50" height="50"> |
| There is supposed to be an example drawing here, but it's not important. |
| </canvas> |
| <div id="description">Verify limits on the lengths of uniform locations per WebGL spec, "Maximum Uniform and Attribute Location Lengths".</div> |
| <div id="console"></div> |
| <script id="goodVertexShader" type="x-shader/x-vertex"> |
| // A vertex shader where the needed uniform location is exactly 256 characters. |
| struct Nesting2 { |
| vec4 identifier62CharactersLong_01234567890123456789012345678901234; |
| }; |
| |
| struct Nesting1 { |
| Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456; |
| }; |
| |
| uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789; |
| |
| void main() { |
| gl_Position = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234; |
| } |
| </script> |
| <script id="badVertexShader" type="x-shader/x-vertex"> |
| // A vertex shader where the needed uniform location is 257 characters. |
| struct Nesting2 { |
| vec4 identifier63CharactersLong_012345678901234567890123456789012345; |
| }; |
| |
| struct Nesting1 { |
| Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456; |
| }; |
| |
| uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789; |
| |
| void main() { |
| Nesting2 temp = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456; |
| gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789012345; |
| } |
| </script> |
| <script id="fragmentShader" type="x-shader/x-fragment"> |
| precision mediump float; |
| |
| void main() { |
| gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); |
| } |
| </script> |
| <script> |
| "use strict"; |
| var wtu = WebGLTestUtils; |
| var gl = wtu.create3DContext("example"); |
| |
| debug("Test uniform location underneath the length limit"); |
| var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader"); |
| shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); |
| var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234"); |
| shouldBeNonNull('uniformLoc'); |
| wtu.glErrorShouldBe(gl, gl.NONE); |
| |
| debug("Test uniform location over the length limit"); |
| program = wtu.loadProgramFromScript(gl, "badVertexShader", "fragmentShader"); |
| wtu.glErrorShouldBe(gl, gl.NONE); |
| shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true'); |
| var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier63CharactersLong_012345678901234567890123456789012345"); |
| wtu.glErrorShouldBe(gl, gl.INVALID_VALUE); |
| shouldBeNull('uniformLoc'); |
| |
| var successfullyParsed = true; |
| </script> |
| <script src="../../../js/js-test-post.js"></script> |
| </body> |
| </html> |