tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

uniform-location-length-limits.html (3961B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <!--
      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.
      9 -->
     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>
     15 </head>
     16 <body>
     17 <canvas id="example" width="50" height="50">
     18 There is supposed to be an example drawing here, but it's not important.
     19 </canvas>
     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.
     24 struct Nesting2 {
     25    vec4 identifier62CharactersLong_01234567890123456789012345678901234;
     26 };
     27 
     28 struct Nesting1 {
     29    Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
     30 };
     31 
     32 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
     33 
     34 void main() {
     35    gl_Position = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234;
     36 }
     37 </script>
     38 <script id="badVertexShader" type="x-shader/x-vertex">
     39 // A vertex shader where the needed uniform location is 257 characters.
     40 struct Nesting2 {
     41    vec4 identifier63CharactersLong_012345678901234567890123456789012345;
     42 };
     43 
     44 struct Nesting1 {
     45    Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
     46 };
     47 
     48 uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
     49 
     50 void main() {
     51    Nesting2 temp = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456;
     52    gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789012345;
     53 }
     54 </script>
     55 <script id="fragmentShader" type="x-shader/x-fragment">
     56 precision mediump float;
     57 
     58 void main() {
     59    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
     60 }
     61 </script>
     62 <script>
     63 "use strict";
     64 var wtu = WebGLTestUtils;
     65 var gl = wtu.create3DContext("example");
     66 
     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);
     73 
     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');
     81 
     82 var successfullyParsed = true;
     83 </script>
     84 <script src="../../../js/js-test-post.js"></script>
     85 </body>
     86 </html>