shader-with-global-variable-precision-mismatch.html (3084B)
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="fshaderWithMediumpGlobal" type="text/something-not-javascript"> 22 // There is no default float precision in fragment shaders, so specify mediump. 23 precision mediump float; 24 25 uniform vec4 foo; 26 27 void main() 28 { 29 gl_FragColor = foo; 30 } 31 </script> 32 <script id="fshaderWithMediumpGlobalInt" type="text/something-not-javascript"> 33 // Default precision for int in fragment shaders is mediump. 34 uniform int foo; 35 36 void main() 37 { 38 gl_FragColor = vec4(foo, 0, 0, 1); 39 } 40 </script> 41 <script id="fshaderWithMediumpGlobalStruct" type="text/something-not-javascript"> 42 // There is no default float precision in fragment shaders, so specify mediump. 43 precision mediump float; 44 45 struct foo 46 { 47 vec4 bar; 48 }; 49 50 uniform foo baz; 51 52 void main() 53 { 54 gl_FragColor = baz.bar; 55 } 56 </script> 57 <script id="vshaderWithHighpGlobal" type="x-shader/x-vertex"> 58 // Default precision for vertex shaders is highp. 59 uniform vec4 foo; 60 61 void main() { 62 gl_Position = foo; 63 } 64 </script> 65 <script id="vshaderWithHighpGlobalInt" type="x-shader/x-vertex"> 66 // Default precision for int in vertex shaders is highp. 67 uniform int foo; 68 69 void main() { 70 gl_Position = vec4(foo, 0, 0, 1); 71 } 72 </script> 73 <script id="vshaderWithHighpGlobalStruct" type="x-shader/x-vertex"> 74 // Default precision for vertex shaders is highp. 75 struct foo 76 { 77 vec4 bar; 78 }; 79 80 uniform foo baz; 81 82 void main() 83 { 84 gl_Position = baz.bar; 85 } 86 </script> 87 <script> 88 "use strict"; 89 description("Checks shaders with global variables and precision qualifier mismatch."); 90 91 var wtu = WebGLTestUtils; 92 93 var glslTests = []; 94 95 glslTests.push({ 96 vShaderId: 'vshaderWithHighpGlobal', 97 vShaderSuccess: true, 98 fShaderId: 'fshaderWithMediumpGlobal', 99 fShaderSuccess: true, 100 linkSuccess: false, 101 passMsg: "mismatching precision for uniforms causes link error (as expected)", 102 }); 103 104 glslTests.push({ 105 vShaderId: 'vshaderWithHighpGlobalInt', 106 vShaderSuccess: true, 107 fShaderId: 'fshaderWithMediumpGlobalInt', 108 fShaderSuccess: true, 109 linkSuccess: false, 110 passMsg: "mismatching precision for int uniforms with default precision causes link error (as expected)", 111 }); 112 113 glslTests.push({ 114 vShaderId: 'vshaderWithHighpGlobalStruct', 115 vShaderSuccess: true, 116 fShaderId: 'fshaderWithMediumpGlobalStruct', 117 fShaderSuccess: true, 118 linkSuccess: false, 119 passMsg: "mismatching precision for structure uniforms causes link error (as expected)", 120 }); 121 122 GLSLConformanceTester.runTests(glslTests); 123 124 debug(""); 125 var successfullyParsed = true; 126 </script> 127 </body> 128 </html>