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>
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=
"goodVertexShader1" type=
"x-shader/x-vertex">
17 // A vertex shader where the uniform name is long, but well below the limit.
19 vec4 identifier62CharactersLong_01234567890123456789012345678901234;
23 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
26 uniform Nesting1 identifier70CharactersLong_01234567890123456789012345678901234567890;
29 gl_Position = identifier70CharactersLong_01234567890123456789012345678901234567890.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234;
32 <script id=
"goodVertexShader2" type=
"x-shader/x-vertex">
33 // A vertex shader where the needed uniform location is exactly
256 characters.
35 vec4 identifier62CharactersLong_01234567890123456789012345678901234;
39 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
42 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
45 gl_Position = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234;
48 <script id=
"badVertexShader" type=
"x-shader/x-vertex">
49 // A vertex shader where the needed uniform location is
257 characters.
51 vec4 identifier63CharactersLong_012345678901234567890123456789012345;
55 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
58 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
61 Nesting2 temp = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456;
62 gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789012345;
65 <script id=
"fragmentShader" type=
"x-shader/x-fragment">
66 precision mediump float;
69 gl_FragColor = vec4(
1.0,
0.0,
0.0,
1.0);
73 if (window
.initNonKhronosFramework
) {
74 window
.initNonKhronosFramework(false);
78 window
.internals
.settings
.setWebGLErrorsToConsoleEnabled(false);
80 var wtu
= WebGLTestUtils
;
81 var gl
= wtu
.create3DContext(document
.getElementById("example"));
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_01234567890123456789012345678901234567890.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234");
87 shouldBeNonNull('uniformLoc');
88 wtu
.glErrorShouldBe(gl
, gl
.NONE
);
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_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234");
94 shouldBeNonNull('uniformLoc');
95 wtu
.glErrorShouldBe(gl
, gl
.NONE
);
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_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier63CharactersLong_012345678901234567890123456789012345");
102 wtu
.glErrorShouldBe(gl
, gl
.INVALID_VALUE
);
103 shouldBeNull('uniformLoc');