6 Copyright (c) 2019 The Khronos Group Inc.
7 Use of this source code is governed by an MIT-style license that can be
8 found in the LICENSE.txt file.
10 <title>WebGL uniform location length tests
</title>
11 <link rel=
"stylesheet" href=
"../../../resources/js-test-style.css"/>
12 <link rel=
"stylesheet" href=
"../../../resources/glsl-feature-tests.css"/>
13 <script src=
"../../../js/js-test-pre.js"></script>
14 <script src=
"../../../js/webgl-test-utils.js"> </script>
17 <canvas id=
"example" width=
"50" height=
"50">
18 There is supposed to be an example drawing here, but it's not important.
20 <div id=
"description">Verify limits on the lengths of uniform locations per WebGL spec,
"Maximum Uniform and Attribute Location Lengths".
</div>
21 <div id=
"console"></div>
22 <script id=
"goodVertexShader" type=
"x-shader/x-vertex">
23 // A vertex shader where the needed uniform location is exactly
256 characters.
25 vec4 identifier62CharactersLong_01234567890123456789012345678901234;
29 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
32 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
35 gl_Position = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234;
38 <script id=
"badVertexShader" type=
"x-shader/x-vertex">
39 // A vertex shader where the needed uniform location is
257 characters.
41 vec4 identifier63CharactersLong_012345678901234567890123456789012345;
45 Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
48 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
51 Nesting2 temp = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456;
52 gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789012345;
55 <script id=
"fragmentShader" type=
"x-shader/x-fragment">
56 precision mediump float;
59 gl_FragColor = vec4(
1.0,
0.0,
0.0,
1.0);
64 var wtu
= WebGLTestUtils
;
65 var gl
= wtu
.create3DContext("example");
67 debug("Test uniform location underneath the length limit");
68 var program
= wtu
.loadProgramFromScript(gl
, "goodVertexShader", "fragmentShader");
69 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
70 var uniformLoc
= gl
.getUniformLocation(program
, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234");
71 shouldBeNonNull('uniformLoc');
72 wtu
.glErrorShouldBe(gl
, gl
.NONE
);
74 debug("Test uniform location over the length limit");
75 program
= wtu
.loadProgramFromScript(gl
, "badVertexShader", "fragmentShader");
76 wtu
.glErrorShouldBe(gl
, gl
.NONE
);
77 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
78 var uniformLoc
= gl
.getUniformLocation(program
, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier63CharactersLong_012345678901234567890123456789012345");
79 wtu
.glErrorShouldBe(gl
, gl
.INVALID_VALUE
);
80 shouldBeNull('uniformLoc');
82 var successfullyParsed
= true;
84 <script src=
"../../../js/js-test-post.js"></script>