tor-browser

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

init-array-with-loop.html (1777B)


      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>Initializing an array with a loop 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="fshaderInitLoop" type="x-shader/x-fragment">
     21 precision mediump float;
     22 
     23 void initGlobals();
     24 
     25 uniform vec4 in0;
     26 vec4 out0;
     27 
     28 float func(float a[4]) {
     29    a[0] = -1.0;
     30    return a[0];
     31 }
     32 
     33 float arr[4];
     34 
     35 bool isOk(vec4 a) {
     36    vec4 ref = -(in0 + 1.0);
     37    if (abs(a.x - ref.x) < 0.05 && abs(a.y - ref.y) < 0.05 && abs(a.z - ref.z) < 0.05 && abs(a.w - ref.w) < 0.05)
     38    {
     39        return true;
     40    }
     41    return false;
     42 }
     43 
     44 void main() {
     45    initGlobals();
     46    arr[0] = in0.x + 1.0;
     47    arr[1] = in0.y + 1.0;
     48    arr[2] = in0.z + 1.0;
     49    arr[3] = in0.w + 1.0;
     50    mediump float f = func(arr);
     51    out0 = f * vec4(arr[0], arr[1], arr[2], arr[3]);
     52    if (isOk(out0))
     53    {
     54        gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
     55    }
     56    else
     57    {
     58        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
     59    }
     60 }
     61 
     62 void initGlobals() {
     63    out0 = vec4(0.0, 0.0, 0.0, 0.0);
     64    for (int i = 0; i < 4; ++i)
     65    {
     66        arr[i] = 0.0;
     67    }
     68 }
     69 </script>
     70 <script type="text/javascript">
     71 "use strict";
     72 description();
     73 
     74 GLSLConformanceTester.runRenderTests([
     75 {
     76  fShaderId: 'fshaderInitLoop',
     77  fShaderSuccess: true,
     78  linkSuccess: true,
     79  passMsg: "Initialize a global array using a for loop"
     80 }
     81 ]);
     82 </script>
     83 </body>
     84 </html>