tor-browser

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

shaders-with-mis-matching-uniforms.html (2752B)


      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>WebGL GLSL Conformance Tests</title>
     12 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
     13 <link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
     14 <script src="../../../js/js-test-pre.js"></script>
     15 <script src="../../../js/webgl-test-utils.js"></script>
     16 <script src="../../../js/glsl-conformance-test.js"></script>
     17 </head>
     18 <body>
     19 <div id="description"></div>
     20 <div id="console"></div>
     21 <script id="vertexShader" type="text/something-not-javascript">
     22 // Shaders with mis-matching uniform types should fail
     23 // GLSL 1.017 4.3.4
     24 uniform $(type) u_uniform;
     25 
     26 void main()
     27 {
     28    gl_Position = $(code);
     29 }
     30 </script>
     31 <script id="fragmentShader" type="text/something-not-javascript">
     32 // Shaders with mis-matching uniform types should fail
     33 // GLSL 1.017 4.3.4
     34 precision mediump float;
     35 
     36 uniform $(type) u_uniform;
     37 
     38 void main()
     39 {
     40    gl_FragColor = $(code);
     41 }
     42 </script>
     43 <script>
     44 "use strict";
     45 var wtu = WebGLTestUtils;
     46 var uniformTypes = [
     47  { type: "bool",  code: "vec4(u_uniform, 0, 0, 0)", },
     48  { type: "float", code: "vec4(u_uniform, 0, 0, 0)", },
     49  { type: "int",   code: "vec4(u_uniform, 0, 0, 0)", },
     50  { type: "vec2",  code: "vec4(u_uniform, 0, 0)", },
     51  { type: "ivec2", code: "vec4(u_uniform, 0, 0)", },
     52  { type: "bvec2", code: "vec4(u_uniform, 0, 0)", },
     53  { type: "vec3",  code: "vec4(u_uniform, 0)", },
     54  { type: "ivec3", code: "vec4(u_uniform, 0)", },
     55  { type: "bvec3", code: "vec4(u_uniform, 0)", },
     56  { type: "vec4",  code: "vec4(u_uniform)", },
     57  { type: "ivec4", code: "vec4(u_uniform)", },
     58  { type: "bvec4", code: "vec4(u_uniform)", },
     59  { type: "mat2",  code: "vec4(u_uniform[0][0], 0, 0, 0)", },
     60  { type: "mat3",  code: "vec4(u_uniform[0][0], 0, 0, 0)", },
     61  { type: "mat4",  code: "vec4(u_uniform[0][0], 0, 0, 0)", },
     62 ];
     63 var vSource = wtu.getScript("vertexShader");
     64 var fSource = wtu.getScript("fragmentShader");
     65 var tests = [];
     66 for (var ii = 0; ii < uniformTypes.length; ++ii) {
     67  var u1 = uniformTypes[ii];
     68  var vs = wtu.replaceParams(vSource, u1);
     69  for (var jj = ii + 1; jj < uniformTypes.length; ++jj) {
     70    var u2 = uniformTypes[jj];
     71    var fs = wtu.replaceParams(fSource, u2);
     72    tests.push({
     73      vShaderSource: vs,
     74      vShaderSuccess: true,
     75      fShaderSource: fs,
     76      fShaderSuccess: true,
     77      linkSuccess: false,
     78      passMsg: "vertex shader with uniform " + u1.type + " and fragment shader with uniform " + u2.type + " with the same name should fail to link",
     79    });
     80  }
     81 }
     82 
     83 GLSLConformanceTester.runTests(tests);
     84 var successfullyParsed = true;
     85 </script>
     86 </body>
     87 </html>