tor-browser

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

fragcoord-linking-bug.html (2984B)


      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>GLSL compiler bug referencing gl_FragCoord</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 <!-- These shaders were extracted from Skia's GPU accelerated backend "Ganesh". -->
     18 <script id="shader-vs" type="x-shader/x-vertex">
     19 uniform mat3 uViewM;
     20 uniform mat3 uStageMatrix_Stage1;
     21 uniform vec4 urtAdjustment;
     22 attribute vec2 aPosition;
     23 attribute vec4 aColor;
     24 varying vec4 vColor;
     25 varying vec2 vMatrixCoord_Stage1;
     26 void main() {
     27    vec3 pos3 = uViewM * vec3(aPosition, 1);
     28    vColor = aColor;
     29    { // Stage 0: XferEffect
     30    }
     31    vMatrixCoord_Stage1 = (uStageMatrix_Stage1 * vec3(aPosition, 1)).xy;
     32    { // Stage 1: Texture
     33    }
     34    gl_Position = vec4(dot(pos3.xz, urtAdjustment.xy), dot(pos3.yz, urtAdjustment.zw), 0, pos3.z);
     35 }
     36 </script>
     37 
     38 <script id="shader-fs" type="x-shader/x-fragment">
     39 precision mediump float;
     40 uniform sampler2D uDstCopySampler;
     41 uniform vec2 uDstCopyUpperLeft;
     42 uniform vec2 uDstCopyCoordScale;
     43 uniform float uRTHeight;
     44 uniform sampler2D uSampler0_Stage1;
     45 varying vec4 vColor;
     46 varying vec2 vMatrixCoord_Stage1;
     47 void main() {
     48    vec4 fragCoordYDown = vec4(gl_FragCoord.x, uRTHeight - gl_FragCoord.y, gl_FragCoord.zw);
     49    // Read color from copy of the destination.
     50    vec2 _dstTexCoord = (fragCoordYDown.xy - uDstCopyUpperLeft) * uDstCopyCoordScale;
     51    _dstTexCoord.y = 1.0 - _dstTexCoord.y;
     52    vec4 _dstColor = texture2D(uDstCopySampler, _dstTexCoord);
     53 
     54    vec4 output_Stage0;
     55    { // Stage 0: XferEffect
     56        // SkXfermode::Mode: Multiply
     57        output_Stage0.a = vColor.a + (1.0 - vColor.a) * _dstColor.a;
     58        output_Stage0.rgb = (1.0 - vColor.a) * _dstColor.rgb + (1.0 - _dstColor.a) * vColor.rgb + vColor.rgb * _dstColor.rgb;
     59    }
     60    vec4 output_Stage1;
     61    { // Stage 1: Texture
     62    output_Stage1 = texture2D(uSampler0_Stage1, vMatrixCoord_Stage1);
     63    }
     64    gl_FragColor = ((output_Stage0 * output_Stage1) + ((vec4(1) - output_Stage1) * _dstColor));
     65 }
     66 </script>
     67 <div id="description"></div>
     68 <div id="console"></div>
     69 <script>
     70 "use strict";
     71 
     72 description();
     73 debug("");
     74 debug('Verify shaders using gl_FragCoord z and w components compile and link correctly');
     75 debug('Regression test for Qualcomm bug ID CR649654');
     76 var wtu = WebGLTestUtils;
     77 var gl = wtu.create3DContext();
     78 if (!gl) {
     79  testFailed("context does not exist");
     80 } else {
     81  var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], null, null, true);
     82  if (program) {
     83    testPassed("Program compiled and linked successfully");
     84  } else {
     85    testFailed("Program failed to compile and link");
     86  }
     87 }
     88 
     89 var successfullyParsed = true;
     90 </script>
     91 <script src="../../../js/js-test-post.js"></script>
     92 </body>
     93 </html>