tor-browser

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

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


      1 <!--
      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.
      5 -->
      6 
      7 <!DOCTYPE html>
      8 <html>
      9 <head>
     10 <meta charset="utf-8">
     11 <title>WebGL uniform 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>
     16 </head>
     17 <body>
     18 <canvas id="example" width="50" height="50">
     19 There is supposed to be an example drawing here, but it's not important.
     20 </canvas>
     21 <div id="description">Verify limits on the lengths of uniform 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 uniform location is exactly 1024 characters.
     25 struct Nesting2 {
     26    vec4 identifier254CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345;
     27 };
     28 
     29 struct Nesting1 {
     30    Nesting2 identifier256CharactersLong_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567;
     31 };
     32 
     33 uniform Nesting1 identifier512CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345670123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345;
     34 
     35 void main() {
     36    gl_Position = identifier512CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345670123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345.identifier256CharactersLong_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567.identifier254CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345;
     37 }
     38 </script>
     39 <script id="badVertexShader" type="x-shader/x-vertex">
     40 // A vertex shader where the needed uniform location is 1025 characters.
     41 struct Nesting2 {
     42    vec4 identifier255CharactersLong_01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
     43 };
     44 
     45 struct Nesting1 {
     46    Nesting2 identifier256CharactersLong_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567;
     47 };
     48 
     49 uniform Nesting1 identifier512CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345670123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345;
     50 
     51 void main() {
     52    Nesting2 temp = identifier512CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345670123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345.identifier256CharactersLong_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567;
     53    gl_Position = temp.identifier255CharactersLong_01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
     54 }
     55 </script>
     56 <script id="fragmentShader" type="x-shader/x-fragment">
     57 precision mediump float;
     58 
     59 void main() {
     60    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
     61 }
     62 </script>
     63 <script>
     64 "use strict";
     65 var wtu = WebGLTestUtils;
     66 var gl = wtu.create3DContext("example", undefined, 2);
     67 var uniform1024Name = "identifier512CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345670123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345.identifier256CharactersLong_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567.identifier254CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
     68 var uniform1025Name = "identifier512CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345670123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345.identifier256CharactersLong_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567.identifier255CharactersLong_01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456";
     69 
     70 debug("Test uniform location underneath the length limit");
     71 var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader");
     72 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
     73 var uniformLoc = gl.getUniformLocation(program, uniform1024Name);
     74 shouldBeNonNull('uniformLoc');
     75 wtu.glErrorShouldBe(gl, gl.NONE);
     76 
     77 debug("Test uniform location over the length limit");
     78 program = wtu.loadProgramFromScript(gl, "badVertexShader", "fragmentShader");
     79 wtu.glErrorShouldBe(gl, gl.NONE);
     80 shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
     81 var uniformLoc = gl.getUniformLocation(program, uniform1025Name);
     82 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
     83 shouldBeNull('uniformLoc');
     84 
     85 var successfullyParsed = true;
     86 </script>
     87 <script src="../../js/js-test-post.js"></script>
     88 </body>
     89 </html>