tor-browser

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

gl-uniform-struct-unused.html (2400B)


      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 struct Conformance Test</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 <div id="description"></div>
     18 <div id="console"></div>
     19 <canvas id="example" width="2" height="2"> </canvas>
     20 
     21 <script id="vshader" type="x-shader/x-vertex">
     22 attribute vec4 vPosition;
     23 uniform vec4 u0;
     24 struct MyStruct {
     25  vec4 var1;
     26  vec4 var2;
     27  vec4 var3;
     28  vec4 var4;
     29 };
     30 uniform MyStruct u1;
     31 uniform vec4 u2;
     32 varying vec4 v_color;
     33 void main()
     34 {
     35  gl_Position = vPosition;
     36  v_color = (u0 + u2 + u1.var1) - vec4(2.0);
     37 }
     38 </script>
     39 
     40 <script id="fshader" type="x-shader/x-fragment">
     41 precision mediump float;
     42 varying vec4 v_color;
     43 void main()
     44 {
     45  gl_FragColor = v_color;
     46 }
     47 </script>
     48 
     49 <script>
     50 "use strict";
     51 description("This test ensures WebGL implementations handle unused members at the end of structs correctly.");
     52 
     53 var wtu = WebGLTestUtils;
     54 var gl = wtu.create3DContext();
     55 var c = document.getElementById("console");
     56 program = wtu.setupProgram(gl, ["vshader", "fshader"], [ "vPosition"]);
     57 
     58 wtu.setupUnitQuad(gl, [0, 1]);
     59 var white = [1.0, 1.0, 1.0, 1.0];
     60 var black = [0.0, 0.0, 0.0, 0.0];
     61 gl.uniform4fv(gl.getUniformLocation(program, "u0"), white);
     62 gl.uniform4fv(gl.getUniformLocation(program, "u1.var1"), white);
     63 gl.uniform4fv(gl.getUniformLocation(program, "u1.var2"), black);
     64 gl.uniform4fv(gl.getUniformLocation(program, "u1.var3"), black);
     65 gl.uniform4fv(gl.getUniformLocation(program, "u1.var4"), black);
     66 gl.uniform4fv(gl.getUniformLocation(program, "u2"), white);
     67 wtu.clearAndDrawUnitQuad(gl);
     68 wtu.checkCanvas(gl, [255, 255, 255, 255], "should be white", 0);
     69 gl.uniform4fv(gl.getUniformLocation(program, "u1.var2"), black);
     70 gl.uniform4fv(gl.getUniformLocation(program, "u1.var3"), black);
     71 gl.uniform4fv(gl.getUniformLocation(program, "u1.var4"), black);
     72 wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 0]);
     73 wtu.checkCanvas(gl, [255, 255, 255, 255], "should still be white", 0);
     74 
     75 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no GL errors");
     76 debug("");
     77 var successfullyParsed = true;
     78 
     79 </script>
     80 <script src="../../js/js-test-post.js"></script>
     81 
     82 </body>
     83 </html>