temp-expressions-should-not-crash.html (2571B)
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>Driver Bug - temp experssions 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 <canvas id="example" width="40" height="40"> </canvas> 19 <div id="description"></div> 20 <div id="console"></div> 21 <script id="vshader" type="x-shader/x-vertex"> 22 void main(){ 23 gl_Position = vec4(0, 0, 0, 1); 24 } 25 </script> 26 <script id="fshaderUniformTest" type="x-shader/x-fragment"> 27 precision mediump float; 28 uniform vec4 u_uniform; 29 void main() 30 { 31 vec4 temp = vec4(0, 0, 0, 0); 32 $(code) 33 gl_FragColor = temp; 34 } 35 </script> 36 <script> 37 "use strict"; 38 var wtu = WebGLTestUtils; 39 var gl = wtu.create3DContext(); 40 41 var fUniformTestSource = wtu.getScript("fshaderUniformTest"); 42 43 var tests = [ 44 ]; 45 var counts = [ 46 { count:100, 47 mustPass: true, 48 }, 49 { count: 1000, 50 mustPass: false, 51 }, 52 { count: 10000, 53 mustPass: false, 54 }, 55 ]; 56 var operators = ["+", "-", "/", "*"]; 57 counts.forEach(function(info) { 58 var generateCode = function(numVars) { 59 var codes = []; 60 var count = 0; 61 var step = 10; 62 for (var uu = 0; uu < numVars; uu += step) { 63 var subCodes = [""]; 64 for (var vv = 0; vv < step; ++vv) { 65 subCodes.push(operators[(count++) % operators.length]); 66 } 67 subCodes.push(""); 68 codes.push(" temp += " + subCodes.join("\n u_uniform ") + ";"); 69 } 70 return { 71 code: codes.join("\n"), 72 }; 73 }; 74 75 var subs = generateCode(info.count); 76 tests.push({ 77 vShaderId: "vshader", 78 vShaderSuccess: true, 79 fShaderSource: wtu.replaceParams(fUniformTestSource, subs), 80 fShaderSuccess: true, 81 linkSuccess: true, 82 ignoreResults: !info.mustPass, 83 passMsg: "shader with uniform with " + info.count + " operators in temp expressions in multiple lines", 84 }); 85 subs.code = subs.code.replace(/\n +/g, " ") 86 tests.push({ 87 vShaderId: "vshader", 88 vShaderSuccess: true, 89 fShaderSource: wtu.replaceParams(fUniformTestSource, subs), 90 fShaderSuccess: true, 91 linkSuccess: true, 92 ignoreResults: !info.mustPass, 93 passMsg: "shader with uniform with " + info.count + " operators in temp expressions in one line", 94 }); 95 }); 96 GLSLConformanceTester.runTests(tests); 97 </script> 98 </body> 99 </html>