2010-06-04 12:03:40 -07:00
|
|
|
<!--
|
|
|
|
Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
|
|
|
Use of this source code is governed by a BSD-style license that can be
|
|
|
|
found in the LICENSE file.
|
|
|
|
-->
|
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
|
|
"http://www.w3.org/TR/html4/loose.dtd">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
<title>WebGL Out Of Resources Test</title>
|
|
|
|
<link rel="stylesheet" href="../resources/js-test-style.css"/>
|
|
|
|
<script src="../resources/desktop-gl-constants.js" type="text/javascript"></script>
|
|
|
|
<script src="../../debug/webgl-debug.js"></script>
|
|
|
|
<script src="../resources/js-test-pre.js"></script>
|
2010-12-03 14:44:01 -08:00
|
|
|
<script src="../conformance/resources/webgl-test.js"></script>
|
2010-06-04 12:03:40 -07:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="description"></div>
|
|
|
|
<div id="console"></div>
|
|
|
|
<canvas id="canvas" width="2" height="2"> </canvas>
|
|
|
|
<canvas id="canvas2" width="2" height="2"> </canvas>
|
|
|
|
<script>
|
2010-12-03 14:44:01 -08:00
|
|
|
window.onload = init;
|
|
|
|
debug("Tests a WebGL program that tries to use all of vram.");
|
2010-06-04 12:03:40 -07:00
|
|
|
|
2010-12-03 14:44:01 -08:00
|
|
|
function init() {
|
|
|
|
if (confirm(
|
|
|
|
"after clicking ok your machine may be come unresponsive or crash")) {
|
|
|
|
main();
|
|
|
|
} else {
|
|
|
|
debug("cancelled");
|
|
|
|
}
|
|
|
|
}
|
2010-06-04 12:03:40 -07:00
|
|
|
|
2010-12-03 14:44:01 -08:00
|
|
|
function main() {
|
2010-06-04 12:03:40 -07:00
|
|
|
debug("");
|
2010-12-03 14:44:01 -08:00
|
|
|
debug("Canvas.getContext");
|
|
|
|
|
|
|
|
var gl = create3DContext(document.getElementById("canvas"));
|
|
|
|
if (!gl) {
|
|
|
|
testFailed("context does not exist");
|
|
|
|
} else {
|
|
|
|
testPassed("context exists");
|
2010-06-04 12:03:40 -07:00
|
|
|
|
2010-12-03 14:44:01 -08:00
|
|
|
debug("");
|
|
|
|
debug("Checking for out of memory handling.");
|
2010-06-04 12:03:40 -07:00
|
|
|
|
2010-12-03 14:44:01 -08:00
|
|
|
var size = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE);
|
|
|
|
debug("max render buffer size: " + size);
|
2010-06-04 12:03:40 -07:00
|
|
|
|
2010-12-03 14:44:01 -08:00
|
|
|
var allocateFramebuffers = true;
|
|
|
|
var itervalId;
|
|
|
|
var count = 0;
|
2010-06-04 12:03:40 -07:00
|
|
|
|
2010-12-03 14:44:01 -08:00
|
|
|
gl = WebGLDebugUtils.makeDebugContext(gl, function(err, functionName, args) {
|
|
|
|
window.clearInterval(intervalId);
|
|
|
|
assertMsg(err == gl.OUT_OF_MEMORY,
|
|
|
|
"correctly returns gl.OUT_OF_MEMORY when out of memory");
|
|
|
|
finish();
|
|
|
|
});
|
|
|
|
|
|
|
|
intervalId = window.setInterval(function() {
|
|
|
|
++count;
|
|
|
|
var mem = count * size * size * 4;
|
|
|
|
debug("#" + count + " : memory allocated so far " + (mem / 1024 / 1024) + "MB");
|
|
|
|
var tex = gl.createTexture();
|
|
|
|
gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
|
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
|
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
|
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
|
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
|
|
gl.texImage2D(gl.TEXTURE_2D,
|
|
|
|
0, // level
|
|
|
|
gl.RGBA, // internalFormat
|
|
|
|
size, // width
|
|
|
|
size, // height
|
|
|
|
0, // border
|
|
|
|
gl.RGBA, // format
|
|
|
|
gl.UNSIGNED_BYTE, // type
|
|
|
|
null); // data
|
|
|
|
if (allocateFrameBuffers) {
|
|
|
|
var fb = gl.createFramebuffer();
|
|
|
|
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
|
|
|
|
gl.framebufferTexture2D(
|
|
|
|
gl.FRAMEBUFFER,
|
|
|
|
gl.COLOR_ATTACHMENT0,
|
|
|
|
gl.TEXTURE_2D,
|
|
|
|
tex,
|
|
|
|
0);
|
|
|
|
var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
|
|
|
|
if (status != gl.FRAMEBUFFER_COMPLETE) {
|
|
|
|
testFailed("gl.checkFramebufferStatus() returned " + WebGLDebugUtils.glEnumToString(status) +
|
|
|
|
" should have gotten gl.OUT_OF_MEMORY before getting this.");
|
|
|
|
window.clearInterval(intervalId);
|
|
|
|
finish();
|
|
|
|
}
|
2010-06-04 12:03:40 -07:00
|
|
|
}
|
2010-12-03 14:44:01 -08:00
|
|
|
}, 1000/10);
|
|
|
|
}
|
2010-06-04 12:03:40 -07:00
|
|
|
|
2010-12-03 14:44:01 -08:00
|
|
|
function finish() {
|
|
|
|
debug("");
|
|
|
|
successfullyParsed = true;
|
|
|
|
}
|
2010-06-04 12:03:40 -07:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|