tor-browser

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

gl-vertex-attrib-normalized-int.html (2783B)


      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 <!DOCTYPE html>
      7 <html>
      8 <head>
      9    <title>WebGL 2 Normalized Vertex Attributes Conformance Test</title>
     10    <meta charset="utf-8">
     11    <link rel="stylesheet" href="../../resources/js-test-style.css"/>
     12 </head>
     13 <body>
     14    <canvas width=1 height=1></canvas>
     15    <div id="description"></div>
     16    <div id="console"></div>
     17    <script id="vertex-shader" type="x-shader/x-vertex">#version 300 es
     18        layout(location = 0) in vec3 vertex;
     19 
     20        out float normAttrib;
     21 
     22        void main(void) {
     23            gl_Position = vec4(vertex.xy, 0, 1);
     24            normAttrib = vertex.z;
     25        }
     26    </script>
     27    <script id="fragment-shader" type="x-shader/x-fragment">#version 300 es
     28        in lowp float normAttrib;
     29 
     30        layout(location=0) out lowp vec4 fragColor;
     31 
     32        void main(void) {
     33            fragColor = vec4(vec3(normAttrib == -1.0 ? 1.0 : 0.0), 1);
     34        }
     35    </script>
     36    <script src="../../js/js-test-pre.js"></script>
     37    <script src="../../js/webgl-test-utils.js"></script>
     38    <script>
     39        (function () {
     40            'use strict';
     41 
     42            var wtu = WebGLTestUtils;
     43 
     44            var gl = wtu.create3DContext(document.querySelector('canvas'), null, 2);
     45 
     46            var program = wtu.setupProgram(gl, ['vertex-shader', 'fragment-shader']);
     47 
     48            gl.useProgram(program);
     49 
     50            var buffer = gl.createBuffer();
     51            gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
     52            gl.bufferData(gl.ARRAY_BUFFER, new Int8Array([
     53                // Here we set the third component (the one that's actually tested)
     54                // to (MIN_INT + 1). If non-zero-preserving rules are used, it'll be
     55                // converted to a float that's slightly greater than -1. If zero-preserving
     56                // rules are used, as the GLES 3 spec requires, result of conversion
     57                // should be exactly -1.
     58                -0x80,  0x7f, -0x7f,
     59                 0x7f,  0x7f, -0x7f,
     60                -0x80, -0x7f, -0x7f,
     61                -0x80, -0x7f, -0x7f,
     62                 0x7f,  0x7f, -0x7f,
     63                 0x7f, -0x80, -0x7f
     64            ]), gl.STATIC_DRAW);
     65 
     66            gl.enableVertexAttribArray(0);
     67            gl.vertexAttribPointer(0, 3, gl.BYTE, true, 0, 0);
     68 
     69            gl.drawArrays(gl.TRIANGLE_STRIP, 0, 6);
     70 
     71            wtu.checkCanvas(gl, [255, 255, 255, 255], "should be opaque white");
     72        }());
     73    </script>
     74    <script>
     75        description('Verify that conversion of normalized signed int attributes to floats uses zero-preserving rule.');
     76        window.successfullyParsed = true;
     77    </script>
     78    <script src="../../js/js-test-post.js"></script>
     79 </body>
     80 </html>