tor-browser

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

vector-dynamic-indexing-nv-driver-bug.html (1919B)


      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 dynamic vector and matrix indexing 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 <script src="../../js/glsl-conformance-test.js"></script>
     16 </head>
     17 <body>
     18 <div id="description"></div>
     19 <div id="console"></div>
     20 <script id="fshaderLValueVectorBeingIndexedHasSideEffects" type="x-shader/x-fragment">#version 300 es
     21 precision mediump float;
     22 
     23 out vec4 my_FragColor;
     24 
     25 uniform int u_zero;
     26 
     27 int sideEffectCounter = 0;
     28 
     29 int funcWithSideEffects() {
     30    sideEffectCounter++;
     31    return 1;
     32 }
     33 
     34 void main() {
     35    vec4 V[2];
     36    V[0] = vec4(1.0, 2.0, 3.0, 4.0);
     37    V[1] = vec4(5.0, 6.0, 7.0, 8.0);
     38    // In case this is broken down to two expressions where one reads V[funcWithSideEffects()]
     39    // and another writes it, it needs to be made sure that funcWithSideEffects() only gets called once.
     40    V[funcWithSideEffects()][u_zero + 1]++;
     41    vec4 expectedV0 = vec4(1.0, 2.0, 3.0, 4.0);
     42    vec4 expectedV1 = vec4(5.0, 7.0, 7.0, 8.0);
     43    float f = 1.0 - distance(V[0], expectedV0) - distance(V[1], expectedV1);
     44    if (sideEffectCounter != 1) {
     45        f = 0.0;
     46    }
     47    my_FragColor = vec4(1.0 - f, f, 0.0, 1.0);
     48 }
     49 </script>
     50 <script type="application/javascript">
     51 "use strict";
     52 description("Dynamic indexing of vectors and matrices should work.");
     53 
     54 debug("This test exposes a NVidia driver bug on Linux");
     55 
     56 GLSLConformanceTester.runRenderTests([
     57 {
     58  fShaderId: 'fshaderLValueVectorBeingIndexedHasSideEffects',
     59  fShaderSuccess: true,
     60  linkSuccess: true,
     61  passMsg: 'Index a vector expression that itself has side effects, in an l-value'
     62 },
     63 ], 2);
     64 </script>
     65 </body>
     66 </html>