tor-browser

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

gl-fragcoord-multisampling-bug.html (1885B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title>gl_FragCoord multisampling bug</title>
      6 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
      7 <script src="../../../js/js-test-pre.js"></script>
      8 <script src="../../../js/webgl-test-utils.js"></script>
      9 </head>
     10 <body>
     11 <div id="canvasHolder"></div>
     12 <div id="description"></div>
     13 <div id="console"></div>
     14 
     15 <script id="vshader" type="x-shader/x-vertex">
     16 attribute vec4 a_position;
     17 void main() {
     18  gl_Position = vec4(a_position.xy, 1.0, 1.0);
     19 }
     20 </script>
     21 
     22 <script id="fshader" type="x-shader/x-fragment">
     23 precision mediump float;
     24 
     25 void main() {
     26  float depth = gl_FragCoord.z / gl_FragCoord.w;
     27  gl_FragColor = vec4( 0.0, depth, 0.0, 1.0 );
     28 }
     29 </script>
     30 
     31 <script type="application/javascript">
     32 "use strict";
     33 description("gl_FragCoord multisampling bug");
     34 debug("Verifies gl_FragCoord z/w values are unaffected by multisampling.");
     35 debug('Regression test for <a href="https://github.com/mrdoob/three.js/issues/7769">Three.js Issue 7769</a>');
     36 var wtu = WebGLTestUtils;
     37 for (var ii = 0; ii < 2; ++ii) {
     38  debug("Testing " + (ii > 0 ? "with" : "without") + " multisampling");
     39  var canvas = document.createElement('canvas');
     40  canvas.width = 256;
     41  canvas.height = 256;
     42  canvas.style.padding = "2px";
     43  document.getElementById('canvasHolder').appendChild(canvas);
     44  var options;
     45  if (ii > 0) {
     46    options = { antialias: true };
     47  }
     48  var gl = wtu.create3DContext(canvas, options);
     49 
     50  gl.clearColor(1, 0, 0, 1);
     51  gl.clear(gl.COLOR_BUFFER_BIT);
     52 
     53  var attribBuffers = wtu.setupUnitQuad(gl, 0, 1);
     54  var program = wtu.setupProgram(gl, ['vshader', 'fshader'], ['a_position'], [0], true);
     55  if (!program) {
     56    testFailed("Shader compilation/link failed");
     57  } else {
     58    // Draw
     59    wtu.drawUnitQuad(gl);
     60    // Verify output
     61    wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green", 3);
     62  }
     63 }
     64 
     65 finishTest();
     66 </script>