5 <title>WebGL uniform location length tests</title>
6 <script src="../../js/resources/js-test-pre.js"></script>
7 <script src="resources/webgl-test.js"> </script>
8 <script src="resources/webgl-test-utils.js"> </script>
11 <canvas id="example" width="50" height="50">
12 There is supposed to be an example drawing here, but it's not important.
14 <div id="description">Verify limits on the lengths of uniform locations.</div>
15 <div id="console"></div>
16 <script id="goodVertexShader" type="x-shader/x-vertex">
17 // A vertex shader where the needed uniform location is exactly 256 characters.
19 vec4 identifier62CharactersLong_01234567890123456789012345678901234;
23 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
26 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
29 gl_Position = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234;
32 <script id="badVertexShader" type="x-shader/x-vertex">
33 // A vertex shader where the needed uniform location is 257 characters.
35 vec4 identifier63CharactersLong_012345678901234567890123456789012345;
39 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
42 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
45 Nesting2 temp = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456;
46 gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789012345;
49 <script id="fragmentShader" type="x-shader/x-fragment">
50 precision mediump float;
53 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
57 if (window.initNonKhronosFramework) {
58 window.initNonKhronosFramework(false);
61 var wtu = WebGLTestUtils;
62 var gl = wtu.create3DContext(document.getElementById("example"));
64 debug("Test uniform location underneath the length limit");
65 var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader");
66 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
67 var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234");
68 shouldBeNonNull('uniformLoc');
69 wtu.glErrorShouldBe(gl, gl.NONE);
71 debug("Test uniform location over the length limit");
72 program = wtu.loadProgramFromScript(gl, "badVertexShader", "fragmentShader");
73 wtu.glErrorShouldBe(gl, gl.NONE);
74 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
75 var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier63CharactersLong_012345678901234567890123456789012345");
76 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
77 shouldBeNull('uniformLoc');
80 <script src="../../js/resources/js-test-post.js"></script>