pow-with-constant-exponent-should-not-crash.html (2041B)
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>Bug - pow() with constant vector exponent should not crash</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="fshaderTest" type="x-shader/x-fragment"> 21 precision mediump float; 22 void main() 23 { 24 // pow() with a constant vector exponent may cause a crash on NVIDIA 331 series OpenGL drivers 25 vec2 v = pow(gl_FragCoord.xy, vec2(2.0)); 26 float y = pow(v, vec2(0.45, 0.5)).y; 27 gl_FragColor = vec4(0.0, 1.0 + y - gl_FragCoord.y, 0.0, 1.0); 28 } 29 </script> 30 <script id="fshaderNestedTest" type="x-shader/x-fragment"> 31 precision mediump float; 32 void main() 33 { 34 // pow() with a constant vector exponent may cause a crash on NVIDIA 331 series OpenGL drivers 35 // workarounds for this should work even if problematic pow() statements are nested within 36 // each other. 37 float y = pow(pow(gl_FragCoord.xy, vec2(2.0)), vec2(0.45, 0.5)).y; 38 gl_FragColor = vec4(0.0, 1.0 + y - gl_FragCoord.y, 0.0, 1.0); 39 } 40 </script> 41 <script> 42 "use strict"; 43 44 // This test has quite a lot of tolerance since pow() doesn't have explicit precision requirements 45 // in ESSL1, and in ESSL3 the limits are very loose. 46 GLSLConformanceTester.runRenderTests([ 47 { 48 fShaderId: "fshaderTest", 49 fShaderSuccess: true, 50 linkSuccess: true, 51 renderTolerance: 20, 52 passMsg: "shader with pow() with a constant vector exponent should not crash", 53 }, 54 { 55 fShaderId: "fshaderNestedTest", 56 fShaderSuccess: true, 57 linkSuccess: true, 58 renderTolerance: 20, 59 passMsg: "shader with nested pow() calls with constant vector exponents should not crash", 60 } 61 ]); 62 </script> 63 </body> 64 </html>