texture-allocation-stress-test.html (1334B)
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>Tests that resources allocated by a WebGL context are freed in a reasonable timeframe.</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 <canvas id="canvas" width="32" height="32"> 20 </canvas> 21 <script> 22 "use strict"; 23 description(); 24 25 debug("Creates a WebGL context and textures consuming ~80 MB of video memory, then reloads the page and does it over again.") 26 debug("GPU memory usage should be capped. It should not grow unboundedly.") 27 28 var wtu = WebGLTestUtils; 29 30 var gl = wtu.create3DContext(document.getElementById("canvas")); 31 var textures = []; 32 33 for (var ii = 0; ii < 20; ++ii) { 34 var tex = gl.createTexture(); 35 gl.bindTexture(gl.TEXTURE_2D, tex); 36 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1024, 1024, 0, gl.RGBA, gl.UNSIGNED_BYTE, 37 null); 38 textures.push(tex); 39 } 40 41 setTimeout(function() { debug("Reloading..."); window.location.reload(); }, 500); 42 43 var successfullyParsed = true; 44 </script> 45 46 </body> 47 </html>