Commit ab87b876 authored by Jonah Chin's avatar Jonah Chin Committed by Commit Bot

Remove repeated doRun() calls in video_to_sub_texture perf test

A recent change intentionally stopped caching SkImage readbacks.

This benchmark results in a single video frame being requested multiple
times, forcing multiple readbacks into CPU memory. This is not
representative of a real world regression, as applications are expected
to cache any uploaded WebGL textures themselves.

See discussion on bug for more details.

Bug: 1115128
Change-Id: I4de6fc4bfb82f5c6baf1778342f2c4c9bfc0c3cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437470Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Jonah Chin <jochin@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#815820}
parent 5192f19a
......@@ -164,7 +164,26 @@ class VideoToHWAcceleratedCanvas(SimpleCanvasPage):
class VideoToSubTexture(SimpleCanvasPage):
BASE_NAME = 'video_to_sub_texture'
URL = 'file://../simple_canvas/video_to_sub_texture.html'
# pylint: disable=line-too-long
URL = 'file://../simple_canvas/video_to_sub_texture.html?flip_y=false&premult=false'
class VideoToSubTextureFlipY(SimpleCanvasPage):
BASE_NAME = 'video_to_sub_texture_flip_y'
# pylint: disable=line-too-long
URL = 'file://../simple_canvas/video_to_sub_texture.html?flip_y=true&premult=false'
class VideoToSubTexturePremultiply(SimpleCanvasPage):
BASE_NAME = 'video_to_sub_texture_premultiply'
# pylint: disable=line-too-long
URL = 'file://../simple_canvas/video_to_sub_texture.html?flip_y=false&premult=true'
class VideoToSubTextureFlipAndPremultiply(SimpleCanvasPage):
BASE_NAME = 'video_to_sub_texture_flip_and_premultiply'
# pylint: disable=line-too-long
URL = 'file://../simple_canvas/video_to_sub_texture.html?flip_y=true&premult=true'
class VideoToTexture(SimpleCanvasPage):
......
......@@ -19,39 +19,39 @@ function setSize(width, height) {
canvas3D.height = height;
}
function getArgValue(argname) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
var result = urlParams.get(argname);
if (!result) {
return false;
}
return result === "true";
}
function startPerfTest() {
preRun();
perfTest();
}
function perfTest() {
for (i = 0; i < 10; i++) {
doRun();
}
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiply);
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, videoElement);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(4));
requestAnimationFrame(perfTest);
}
var flipYAndPremultipyAlphas =
[[ false, false ],
[ false, true ],
[ true, false ],
[ true, true ]];
var optionIndex = 0;
var flipY = false;
var premultiply = false;
var tex = null;
function preRun() {
tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, videoElement.videoWidth, videoElement.videoHeight, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
optionIndex = 0;
}
function doRun() {
var i = optionIndex++ % flipYAndPremultipyAlphas.length;
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipYAndPremultipyAlphas[i][0]);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, flipYAndPremultipyAlphas[i][1]);
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, videoElement);
flipY = getArgValue('flip_y');
premultiply = getArgValue('premult');
}
window.onload = function () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment