2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL attrib location length tests
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <link rel=
"stylesheet" href=
"../../resources/glsl-feature-tests.css"/>
14 <script src=
"../../js/js-test-pre.js"></script>
15 <script src=
"../../js/webgl-test-utils.js"> </script>
18 <canvas id=
"example" width=
"50" height=
"50">
19 There is supposed to be an example drawing here, but it's not important.
21 <div id=
"description">Verify limits on the lengths of attribute locations per WebGL
2 spec
"Maximum Uniform and Attribute Location Lengths"</div>
22 <div id=
"console"></div>
23 <script id=
"goodVertexShader" type=
"x-shader/x-vertex">
24 // A vertex shader where the needed attrib location is exactly
1024 characters.
25 attribute vec4 vPosition1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345;
28 gl_Position = vPosition1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345;
31 <script id=
"badVertexShader" type=
"x-shader/x-vertex">
32 // A vertex shader where the needed attrib location is
1025 characters.
33 attribute vec4 vPosition12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
37 gl_Position = vPosition12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
40 <script id=
"fragmentShader" type=
"x-shader/x-fragment">
41 precision mediump float;
44 gl_FragColor = vec4(
1.0,
0.0,
0.0,
1.0);
49 description("test attrib location length limit");
51 var wtu
= WebGLTestUtils
;
52 var gl
= wtu
.create3DContext("example", undefined, 2);
54 debug("Test attrib location underneath the length limit");
55 var program
= wtu
.loadProgramFromScript(gl
, "goodVertexShader", "fragmentShader");
56 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
57 var attrib1024Name
= "vPosition1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
58 gl
.bindAttribLocation(program
, 0, attrib1024Name
);
59 wtu
.glErrorShouldBe(gl
, gl
.NONE
);
60 var attribLoc
= gl
.getAttribLocation(program
, attrib1024Name
);
61 if (attribLoc
== -1) {
62 testFailed("attrib location was -1, should not be");
64 testPassed("attrib location should not be -1");
66 wtu
.glErrorShouldBe(gl
, gl
.NONE
);
68 debug("Test attrib length over the length limit");
69 var attrib1025Name
= attrib1024Name
+ "6";
71 debug("Shader compilation or link should fail");
72 shouldBe('wtu.loadProgramFromScriptExpectError(gl, "badVertexShader", "fragmentShader")', 'null');
73 wtu
.glErrorShouldBe(gl
, gl
.NONE
);
75 debug("Attempt to bind too-long attrib location should produce error");
76 program
= gl
.createProgram();
77 gl
.bindAttribLocation(program
, 0, attrib1025Name
);
78 wtu
.glErrorShouldBe(gl
, gl
.INVALID_VALUE
);
80 debug("Attempt to fetch too-long attrib location should produce error");
81 program
= wtu
.loadStandardProgram(gl
);
82 shouldBe('gl.getAttribLocation(program, attrib1025Name)', '-1');
83 wtu
.glErrorShouldBe(gl
, gl
.INVALID_VALUE
);
85 var successfullyParsed
= true;
87 <script src=
"../../js/js-test-post.js"></script>