tor-browser

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

array-assign.html (2189B)


      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 array assignment 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="fshaderSimple" type="x-shader/x-fragment">#version 300 es
     21 precision mediump float;
     22 
     23 out vec4 my_FragColor;
     24 
     25 void main() {
     26    // This simple test uses the ESSL1 style array initialization in order
     27    // to be able to test array assignment independently of array constructors.
     28    int a[3];
     29    int b[3];
     30    for (int i = 0; i < 3; ++i) {
     31        a[i] = 0;
     32        b[i] = i;
     33    }
     34    a = b;
     35    bool fail = false;
     36    for (int i = 0; i < 3; ++i) {
     37        if (a[i] != i) {
     38            fail = true;
     39        }
     40    }
     41    my_FragColor = vec4(0.0, (fail ? 0.0 : 1.0), 0.0, 1.0);
     42 }
     43 </script>
     44 <script id="fshaderArrayOfStructs" type="x-shader/x-fragment">#version 300 es
     45 precision mediump float;
     46 
     47 out vec4 my_FragColor;
     48 
     49 struct S {
     50    int foo;
     51 };
     52 
     53 void main() {
     54    // This simple test uses the ESSL1 style array initialization in order
     55    // to be able to test array assignment independently of array constructors.
     56    S a[3];
     57    S b[3];
     58    for (int i = 0; i < 3; ++i) {
     59        a[i].foo = 0;
     60        b[i].foo = i;
     61    }
     62    a = b;
     63    bool fail = false;
     64    for (int i = 0; i < 3; ++i) {
     65        if (a[i].foo != i) {
     66            fail = true;
     67        }
     68    }
     69    my_FragColor = vec4(0.0, (fail ? 0.0 : 1.0), 0.0, 1.0);
     70 }
     71 </script>
     72 <script type="application/javascript">
     73 "use strict";
     74 description("Assigning arrays should work.");
     75 
     76 GLSLConformanceTester.runRenderTests([
     77 {
     78  fShaderId: 'fshaderSimple',
     79  fShaderSuccess: true,
     80  linkSuccess: true,
     81  passMsg: 'Arrays of integers'
     82 },
     83 {
     84  fShaderId: 'fshaderArrayOfStructs',
     85  fShaderSuccess: true,
     86  linkSuccess: true,
     87  passMsg: 'Arrays of structs'
     88 }
     89 ], 2);
     90 </script>
     91 </body>
     92 </html>