tor-browser

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

shader-struct-scope.html (4150B)


      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 <!-- author: Jamie Madill (jmadill at chromium) -->
      8 
      9 <!DOCTYPE html>
     10 <html>
     11 <head>
     12 <meta charset="utf-8">
     13 <title>Struct Scope Test</title>
     14 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
     15 <link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
     16 <script src="../../../js/js-test-pre.js"></script>
     17 <script src="../../../js/webgl-test-utils.js"></script>
     18 <script src="../../../js/glsl-conformance-test.js"></script>
     19 </head>
     20 
     21 <body>
     22 <div id="description"></div>
     23 <div id="console"></div>
     24 
     25 <script id="shader-vs-1" type="x-shader/x-vertex">
     26 void main(void) {
     27 
     28  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
     29 
     30  {
     31    struct T {
     32      int v1;
     33    };
     34 
     35    T x;
     36    gl_Position.x += float(x.v1);
     37  }
     38 
     39  {
     40    struct T {
     41      float v2;
     42    };
     43 
     44    T x;
     45    gl_Position.x += x.v2;
     46  }
     47 
     48 }
     49 </script>
     50 
     51 <script id="shader-vs-2" type="x-shader/x-vertex">
     52 void main(void) {
     53 
     54  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
     55 
     56  struct T {
     57    int v1;
     58  };
     59 
     60  T x;
     61  gl_Position.x += float(x.v1);
     62 
     63  {
     64    struct T {
     65      float v2;
     66    };
     67 
     68    T x;
     69    gl_Position.x += x.v2;
     70  }
     71 
     72 }
     73 </script>
     74 
     75 <script id="shader-vs-3" type="x-shader/x-vertex">
     76 void main(void) {
     77 
     78  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
     79 
     80  {
     81    struct T {
     82      int v1;
     83    };
     84 
     85    T x;
     86    gl_Position.x += float(x.v1);
     87  }
     88 
     89  struct T {
     90    float v2;
     91  };
     92 
     93  T x;
     94  gl_Position.x += x.v2;
     95 }
     96 </script>
     97 
     98 <script id="shader-vs-bad" type="x-shader/x-vertex">
     99 void main(void) {
    100 
    101  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
    102 
    103  struct T {
    104    int v1;
    105  };
    106 
    107  T x;
    108  gl_Position.x += float(x.v1);
    109 
    110  struct T {
    111    float v2;
    112  };
    113 
    114  T y;
    115  gl_Position.x += y.v2;
    116 }
    117 </script>
    118 
    119 <script id="shader-vs-anglebug" type="x-shader/x-vertex">
    120 
    121 struct T_0 {
    122  int v1;
    123 };
    124 
    125 void main(void) {
    126 
    127  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
    128 
    129  struct T {
    130    float v2;
    131  };
    132 
    133  T_0 x;
    134  gl_Position.x += float(x.v1);
    135 
    136  T y;
    137  gl_Position.x += y.v2;
    138 }
    139 </script>
    140 
    141 <script id="shader-vs-masked-struct-variable" type="x-shader/x-vertex">
    142 
    143 struct T {
    144  float f;
    145 };
    146 
    147 void main(void) {
    148 
    149  T a;
    150 
    151  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
    152 
    153  struct T {
    154    float q;
    155  };
    156 
    157  gl_Position.x += a.f;
    158 
    159  T b;
    160  gl_Position.x += b.q;
    161 }
    162 </script>
    163 
    164 <script id="shader-fs" type="x-shader/x-fragment">
    165 precision mediump float;
    166 void main(void) {
    167  gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
    168 }
    169 </script>
    170 
    171 <script>
    172 "use strict";
    173 description("Testing struct definition scope");
    174 
    175 var wtu = WebGLTestUtils;
    176 GLSLConformanceTester.runTests([
    177  {
    178    vShaderId: "shader-vs-1",
    179    vShaderSuccess: true,
    180    fShaderId: "shader-fs",
    181    fShaderSuccess: true,
    182    linkSuccess: true,
    183    passMsg: "Two structs defined within non-overlapping scopes should be able to use the same name",
    184  },
    185  {
    186    vShaderId: "shader-vs-2",
    187    vShaderSuccess: true,
    188    fShaderId: "shader-fs",
    189    fShaderSuccess: true,
    190    linkSuccess: true,
    191    passMsg: "A struct defined inside a scope overrides a struct defined in a outer scope with the same name",
    192  },
    193  {
    194    vShaderId: "shader-vs-3",
    195    vShaderSuccess: true,
    196    fShaderId: "shader-fs",
    197    fShaderSuccess: true,
    198    linkSuccess: true,
    199    passMsg: "A struct can use the same name of another out-of-scope struct",
    200  },
    201  {
    202    vShaderId: "shader-vs-bad",
    203    vShaderSuccess: false,
    204    fShaderId: "shader-fs",
    205    fShaderSuccess: true,
    206    linkSuccess: false,
    207    passMsg: "A struct can't be defined with the same name as another struct defined in the same scope",
    208  },
    209  {
    210    vShaderId: "shader-vs-anglebug",
    211    vShaderSuccess: true,
    212    fShaderId: "shader-fs",
    213    fShaderSuccess: true,
    214    linkSuccess: true,
    215    passMsg: "Structs with appended underscored numbers don't cause link errors (ANGLE bug)",
    216  },
    217  {
    218    vShaderId: "shader-vs-masked-struct-variable",
    219    vShaderSuccess: true,
    220    fShaderId: "shader-fs",
    221    fShaderSuccess: true,
    222    linkSuccess: true,
    223    passMsg: "Variables of masked outer scope struct work with inner scope struct",
    224  },
    225 ]);
    226 
    227 debug("");
    228 var successfullyParsed = true;
    229 </script>
    230 </body>
    231 </html>