fragment-shader-loop-crash.html (1753B)
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>Fragment shader containing loop 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 precision highp float; 23 out vec2 v_tex_coord; 24 uniform mat4 matrix; 25 26 void main() { 27 v_tex_coord = vec2(0.0, 0.0); 28 gl_Position = vec4(0.0, 0.0, 0.0, 0.0); 29 } 30 </script> 31 <script id="fshader" type="x-shader/x-fragment">#version 300 es 32 precision highp float; 33 34 in vec2 v_tex_coord; 35 out vec4 out_color; 36 37 uniform sampler2D texture_1; 38 uniform vec2 resolution; 39 40 vec4 do_loops(vec4 z) 41 { 42 vec4 v[16]; 43 for (int i = 0; i < 16; i++) 44 { 45 v[i] = z; 46 } 47 return v[1]; 48 } 49 50 void main() { 51 out_color = do_loops(vec4(0.2, 0.4, 0.6, 1.0)) - texture(texture_1, v_tex_coord); 52 } 53 </script> 54 <script type="application/javascript"> 55 "use strict"; 56 description(); 57 const wtu = WebGLTestUtils; 58 const tests = [ 59 { 60 vShaderSource: wtu.getScript('vshader'), 61 fShaderSource: wtu.getScript('fshader'), 62 vShaderSuccess: true, 63 fShaderSuccess: true, 64 linkSuccess: true, 65 passMsg: 'Fragment shader containing a simple loop should compile and link' 66 } 67 ]; 68 69 GLSLConformanceTester.runTests(tests, 2); 70 </script> 71 </body> 72 </html>