blob: 07a2cf97d84e3da6e4023c2c9a4883aaa90f21cb [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script src="resources/canvas_runner.js"></script>
<script>
var sourceCanvas3D = document.createElement('canvas');
var sourceCtx = sourceCanvas3D.getContext('webgl');
var destCanvas3D = document.createElement('canvas');
var destCtx = destCanvas3D.getContext('webgl');
if (!sourceCtx || !destCtx)
CanvasRunner.logFatalError("WebGL is not supported or enabled on this platform!");
var tex = null;
function setSize(width, height) {
sourceCanvas3D.width = width;
sourceCanvas3D.height = height;
destCanvas3D.width = width;
destCanvas3D.height = height;
}
function rand(range) {
return Math.floor(Math.random() * range);
}
function renderWebGL(gl) {
gl.disable(gl.SCISSOR_TEST);
gl.clear(gl.COLOR_BUFER_BIT);
gl.enable(gl.SCISSOR_TEST);
gl.scissor(rand(1024), rand(1024), rand(1024), rand(1024));
gl.clearColor(Math.random(), Math.random(), Math.random(), 1);
gl.clear(gl.COLOR_BUFFER_BIT);
}
function preRun() {
tex = destCtx.createTexture();
destCtx.bindTexture(destCtx.TEXTURE_2D, tex);
}
function doRun() {
destCtx.texImage2D(destCtx.TEXTURE_2D, 0, destCtx.RGBA, destCtx.RGBA, destCtx.UNSIGNED_BYTE, sourceCanvas3D);
}
function ensureComplete() {
destCtx.readPixels(0, 0, 1, 1, sourceCtx.RGBA, sourceCtx.UNSIGNED_BYTE, new Uint8Array(4));
}
function postRun() {
destCtx.deleteTexture(tex);
}
window.onload = function () {
setSize(1024, 1024);
renderWebGL(sourceCtx);
CanvasRunner.start({
description: "This benchmark checks the speed on uploading WebGL(1024x1024) to WebGL Texture(1024x1024).",
preRun: preRun,
doRun: doRun,
ensureComplete: ensureComplete,
postRun: postRun});
}
</script>
</body>
</html>