tor-browser

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

gl-min-textures.html (2392B)


      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 the minimum number of uniforms are supported.</title>
     12 <link rel="stylesheet" href="../../resources/js-test-style.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="4" height="4" style="width: 40px; height: 30px;"></canvas>
     18 <div id="description"></div>
     19 <div id="console"></div>
     20 <script id="vshader" type="x-shader/x-vertex">
     21 attribute vec4 vPosition;
     22 void main()
     23 {
     24    gl_Position = vPosition;
     25 }
     26 </script>
     27 
     28 <script id="fshader" type="x-shader/x-fragment">
     29 #define NUM_TEXTURES 8 // See spec
     30 precision mediump float;
     31 uniform sampler2D uni[NUM_TEXTURES];
     32 void main()
     33 {
     34    vec4 c = vec4(0,0,0,0);
     35    // The loop was manually unrolled in order to verify that this works.
     36    // A separate test sampler-array-using-loop-index.html checks that
     37    // loops indexing sampler arrays still work.
     38    c += texture2D(uni[0], vec2(0.5, 0.5));
     39    c += texture2D(uni[1], vec2(0.5, 0.5));
     40    c += texture2D(uni[2], vec2(0.5, 0.5));
     41    c += texture2D(uni[3], vec2(0.5, 0.5));
     42    c += texture2D(uni[4], vec2(0.5, 0.5));
     43    c += texture2D(uni[5], vec2(0.5, 0.5));
     44    c += texture2D(uni[6], vec2(0.5, 0.5));
     45    c += texture2D(uni[7], vec2(0.5, 0.5));
     46    gl_FragColor = c;
     47 }
     48 </script>
     49 <script>
     50 "use strict";
     51 description(document.title);
     52 var wtu = WebGLTestUtils;
     53 var gl = wtu.create3DContext("example");
     54 var program = wtu.setupTexturedQuad(gl);
     55 
     56 //------------------------------------------------------------------------------
     57 var program = wtu.setupProgram(
     58    gl, ['vshader', 'fshader'], ['vPosition'], [0]);
     59 
     60 for (var ii = 0; ii < 8; ++ii) {
     61  var loc = gl.getUniformLocation(program, "uni[" + ii + "]");
     62  gl.activeTexture(gl.TEXTURE0 + ii);
     63  var tex = gl.createTexture();
     64  wtu.fillTexture(gl, tex, 1, 1, [32, 16, 8, ii * 9], 0);
     65  gl.uniform1i(loc, ii);
     66 }
     67 
     68 wtu.clearAndDrawUnitQuad(gl);
     69 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
     70 wtu.checkCanvas(gl, [255, 128, 64, 252],
     71                "Should render using all texture units", 1);
     72 
     73 var successfullyParsed = true;
     74 
     75 </script>
     76 <script src="../../js/js-test-post.js"></script>
     77 
     78 </body>
     79 </html>