reciprocal-sqrt-of-sum-of-squares-crash.html (1837B)
1 <!-- 2 Copyright (c) 2021 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>Shader identified as containing reciprocal square root of sum of squares should not crash</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="vshader" type="x-shader/x-vertex">#version 300 es 22 void main() { 23 gl_Position = vec4(0.0, 0.0, 0.0, 0.0); 24 } 25 </script> 26 <script id="fshader" type="x-shader/x-fragment">#version 300 es 27 precision highp float; 28 29 #define CRASH 1 30 31 out vec4 fragmentColor; 32 void main() 33 { 34 vec2 p = gl_FragCoord.xy; 35 // This expression meets the requirement of being the reciprocal 36 // square root of a sum of squares. 37 float d = 1.0 / length(p); 38 #if CRASH 39 if (p.x > 0.0) 40 { 41 d *= 2.0; 42 } 43 #endif 44 fragmentColor = vec4(d); 45 } 46 </script> 47 <script type="application/javascript"> 48 "use strict"; 49 description(); 50 debug('Regression test for <a href="https://crbug.com/1079309">crbug.com/1079309</a>'); 51 const wtu = WebGLTestUtils; 52 const tests = [ 53 { 54 vShaderSource: wtu.getScript('vshader'), 55 fShaderSource: wtu.getScript('fshader'), 56 vShaderSuccess: true, 57 fShaderSuccess: true, 58 linkSuccess: true, 59 passMsg: 'Shader containing expression that driver recognizes as reciprocal square root of sum of squares should compile and link' 60 } 61 ]; 62 63 GLSLConformanceTester.runTests(tests, 2); 64 </script> 65 </body> 66 </html>