tor-browser

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

compare-structs-containing-arrays.html (1967B)


      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 equality test with structs containing arrays</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 <!--
     21 Structure array comparisons are detailed in the ESSL 3.00 spec section 5.7
     22 -->
     23 <script id="fshader-same-struct" type="x-shader/x-fragment">#version 300 es
     24 precision mediump float;
     25 out vec4 color;
     26 
     27 struct MyStruct {
     28    bool a[2];
     29 };
     30 
     31 void main() {
     32    MyStruct b;
     33    b.a[0] = true;
     34    b.a[1] = false;
     35 
     36    MyStruct c;
     37    c.a[0] = true;
     38    c.a[1] = false;
     39 
     40    color = b == c ? vec4(0, 1.0, 0, 1.0) : vec4(1.0, 0, 0, 1.0);
     41 }
     42 </script>
     43 <script id="fshader-different-struct" type="x-shader/x-fragment">#version 300 es
     44 precision mediump float;
     45 out vec4 color;
     46 
     47 struct MyStruct {
     48    bool a[2];
     49 };
     50 
     51 void main() {
     52    MyStruct b;
     53    b.a[0] = true;
     54    b.a[1] = true;
     55 
     56    MyStruct c;
     57    c.a[0] = true;
     58    c.a[1] = false;
     59 
     60    color = b != c ? vec4(0, 1.0, 0, 1.0) : vec4(1.0, 0, 0, 1.0);
     61 }
     62 </script>
     63 <script type="application/javascript">
     64 "use strict";
     65 description("Comparing structs containing arrays should work.");
     66 debug("");
     67 
     68 GLSLConformanceTester.runRenderTests([
     69 {
     70  fShaderId: 'fshader-same-struct',
     71  fShaderSuccess: true,
     72  linkSuccess: true,
     73  passMsg: 'Comparing two structs containing arrays with the same values should equal to each other'
     74 },
     75 {
     76  fShaderId: 'fshader-different-struct',
     77  fShaderSuccess: true,
     78  linkSuccess: true,
     79  passMsg: 'Comparing two structs containing arrays with different values should not equal to each other'
     80 },
     81 ], 2);
     82 
     83 </script>
     84 </body>
     85 </html>