gradient-in-discontinuous-loop.html (1726B)
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>Short circuit in loop condition 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 </head> 16 <body> 17 <div id="description"></div> 18 <div id="console"></div> 19 <script id="vertex-shader" type="x-shader/x-vertex">#version 300 es 20 precision highp float; 21 in vec4 aPosition; 22 23 void main() { 24 gl_Position = aPosition; 25 } 26 </script> 27 <script id="fragment-shader" type="x-shader/x-fragment">#version 300 es 28 precision highp float; 29 precision highp int; 30 31 uniform vec4 iMouse; 32 uniform sampler2D iChannel0; 33 34 float map(float p) 35 { 36 return texture(iChannel0, vec2(p, p), 0.0).y; 37 } 38 39 out vec4 outColor; 40 41 void main(void) 42 { 43 float sum = 0.0; 44 45 for(int i=0; i<1000; i++) 46 { 47 if( sum > 0.99 ) break; 48 float p = iMouse.x + gl_FragCoord.x; 49 sum = map(p); 50 } 51 52 outColor = vec4(sum); 53 } 54 </script> 55 <script type="text/javascript"> 56 "use strict"; 57 description("Test an HLSL compiler freeze on a gradient inside a discontinuous loop."); 58 59 var wtu = WebGLTestUtils; 60 var gl = wtu.create3DContext(undefined, undefined, 2); 61 wtu.setupUnitQuad(gl); 62 63 if (!gl) { 64 testFailed("context does not exist"); 65 } else { 66 var program = wtu.setupProgram(gl, ["vertex-shader", "fragment-shader"], ['aPosition'], undefined, true); 67 if (!program) { 68 testFailed('Program compilation failed'); 69 } 70 } 71 var successfullyParsed = true; 72 finishTest(); 73 </script> 74 </body> 75 </html>