content/canvas/test/webgl-conformance/conformance/glsl/misc/attrib-location-length-limits.html

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4 <meta charset="utf-8">
     5 <title>WebGL attrib location length tests</title>
     6 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
     7 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
     8 <script src="../../../resources/js-test-pre.js"></script>
     9 <script src="../../resources/webgl-test.js"> </script>
    10 <script src="../../resources/webgl-test-utils.js"> </script>
    11 </head>
    12 <body>
    13 <canvas id="example" width="50" height="50">
    14 There is supposed to be an example drawing here, but it's not important.
    15 </canvas>
    16 <div id="description">Verify limits on the lengths of attribute locations per WebGL spec, "Maximum Uniform and Attribute Location Lengths".</div>
    17 <div id="console"></div>
    18 <script id="goodVertexShader" type="x-shader/x-vertex">
    19 // A vertex shader where the needed attrib location is exactly 256 characters.
    20 attribute vec4 vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
    22 void main()
    23 {
    24     gl_Position = vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
    25 }
    26 </script>
    27 <script id="badVertexShader" type="x-shader/x-vertex">
    28 // A vertex shader where the needed attrib location is 257 characters.
    29 attribute vec4 vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567;
    31 void main()
    32 {
    33     gl_Position = vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567;
    34 }
    35 </script>
    36 <script id="fragmentShader" type="x-shader/x-fragment">
    37 precision mediump float;
    39 void main() {
    40     gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
    41 }
    42 </script>
    43 <script>
    44 if (window.initNonKhronosFramework) {
    45     window.initNonKhronosFramework(false);
    46 }
    47 description("test attrib location length limit");
    49 var wtu = WebGLTestUtils;
    50 var gl = wtu.create3DContext("example");
    52 debug("Test attrib location underneath the length limit");
    53 var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader");
    54 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
    55 var attribLoc = gl.getAttribLocation(program, "vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456");
    56 if (attribLoc == -1) {
    57     testFailed("attrib location was -1, should not be");
    58 } else {
    59     testPassed("attrib location should not be -1");
    60 }
    61 wtu.glErrorShouldBe(gl, gl.NONE);
    63 debug("Test attrib location over the length limit");
    64 debug("Shader compilation or link should fail");
    65 shouldBe('wtu.loadProgramFromScriptExpectError(gl, "badVertexShader", "fragmentShader")', 'null');
    66 wtu.glErrorShouldBe(gl, gl.NONE);
    68 debug("Attempt to bind too-long attrib location should produce error");
    69 program = gl.createProgram();
    70 gl.bindAttribLocation(program, 0, "vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
    71 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
    73 debug("Attempt to fetch too-long attrib location should produce error");
    74 program = wtu.loadStandardProgram(gl);
    75 shouldBe('gl.getAttribLocation(program, "vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567")', '-1');
    76 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
    78 successfullyParsed = true;
    79 </script>
    80 <script>finishTest();</script>
    81 </body>
    82 </html>

mercurial