tor-browser

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

forward-declaration.html (2422B)


      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 3.00 forward declaration 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="vertexShaderForwardDecl" type="x-shader/x-vertex">#version 300 es
     21 precision mediump float;
     22 
     23 // Forward declaration. Breaks on Pixel C due to flattening of
     24 // precision qualifiers. It seems the GLSL compiler can't handle the
     25 // precision qualifier on the return value.
     26 float identity(float val);
     27 
     28 float identity(float val) {
     29  return val;
     30 }
     31 
     32 void main(void) {
     33    gl_Position = vec4(identity(1.0), 0.0, 0.0, 1.0);
     34 }
     35 </script>
     36 <script id="vertexShader" type="x-shader/x-vertex">#version 300 es
     37 void main(void) {
     38    gl_Position = vec4(1.0, 0.0, 0.0, 1.0);
     39 }
     40 </script>
     41 <script id="fragmentShader" type="x-shader/x-fragment">#version 300 es
     42 precision mediump float;
     43 
     44 out vec4 my_FragColor;
     45 void main(void) {
     46  my_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
     47 }
     48 </script>
     49 <script id="fragmentShaderForwardDecl" type="x-shader/x-fragment">#version 300 es
     50 precision mediump float;
     51 
     52 // Forward declaration. Breaks on Pixel C due to flattening of
     53 // precision qualifiers. It seems the GLSL compiler can't handle the
     54 // precision qualifier on the return value.
     55 float identity(float val);
     56 
     57 float identity(float val) {
     58  return val;
     59 }
     60 
     61 out vec4 my_FragColor;
     62 void main(void) {
     63  my_FragColor = vec4(0.0, identity(1.0), 0.0, 1.0);
     64 }
     65 </script>
     66 <script type="application/javascript">
     67 "use strict";
     68 description("Forward declarations of functions should succeed.");
     69 
     70 GLSLConformanceTester.runTests([
     71  {
     72    vShaderId: "vertexShaderForwardDecl",
     73    vShaderSuccess: true,
     74    fShaderId: "fragmentShader",
     75    fShaderSuccess: true,
     76    linkSuccess: true,
     77    passMsg: "vertex shader with forward declaration must pass",
     78  },
     79  {
     80    vShaderId: "vertexShader",
     81    vShaderSuccess: true,
     82    fShaderId: "fragmentShaderForwardDecl",
     83    fShaderSuccess: true,
     84    linkSuccess: true,
     85    passMsg: "fragment shader with forward declaration must pass",
     86  },
     87 ], 2);
     88 </script>
     89 </body>
     90 </html>