Skip to content

Commit

Permalink
Add blink_perf stories for WebGL bindBuffer and bufferSubData
Browse files Browse the repository at this point in the history
This CL adds stories that exercise gl.bindBuffer and gl.bufferSubData to
the existing blink_perf.webgl_fast_call benchmark suite.

Bug: chromium:1155348

Change-Id: I7e84e07835fcf2924377f837ba46b4d465988264
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2874607
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#882947}
  • Loading branch information
MayaLekova authored and Chromium LUCI CQ committed May 14, 2021
1 parent 6e89607 commit 34a0d15
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
35 changes: 35 additions & 0 deletions third_party/blink/perf_tests/webgl/binding-bind-buffer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>

<head>
<title>
Test CPU performance of the WebGLRenderingContext.bindBuffer binding
</title>
<script src="../resources/runner.js"></script>
</head>

<body>
<canvas id="canvas" width=400 height=400></canvas>
<script>
const canvas = document.getElementById('canvas');
const gl = canvas.getContext('webgl');

const vertexBuffer1 = gl.createBuffer();
const vertexBuffer2 = gl.createBuffer();

const iterations = 10000;
PerfTestRunner.measureInnerRAFTime({
description: `CPU time for ${iterations*3} calls to WebGLRenderingContext.bindBuffer`,
warmUpCount: 10,
run() {
for (let i = 0; i < iterations; ++i) {
gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer1);
gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer2);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
}
}
});
</script>
</body>

</html>
49 changes: 49 additions & 0 deletions third_party/blink/perf_tests/webgl/binding-buffer-sub-data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>

<head>
<title>
Test CPU performance of the WebGLRenderingContext.bufferSubData binding
</title>
<script src="../resources/runner.js"></script>
</head>

<body>
<canvas id="canvas" width=400 height=400></canvas>
<script>
const canvas = document.getElementById('canvas');
const gl = canvas.getContext('webgl');

const vertexBuffer = gl.createBuffer();

const data = new Float32Array([
0.0, 0.5, 0.0,
-0.5, -0.5, 0.0,
0.5, -0.5, 0.0,
]);
const dataCopy = new Float32Array([
0.0, 0.5, 0.0,
-0.5, -0.5, 0.0,
0.5, -0.5, 0.0,
]);
const sizeInBytes = data.length * data.BYTES_PER_ELEMENT;

gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
// Ensure twice the size of `data`.
gl.bufferData(gl.ARRAY_BUFFER, sizeInBytes * 2, gl.STATIC_DRAW);

const iterations = 10000;
PerfTestRunner.measureInnerRAFTime({
description: `CPU time for ${iterations * 2} calls to WebGLRenderingContext.bufferSubData`,
warmUpCount: 10,
run() {
for (let i = 0; i < iterations; ++i) {
gl.bufferSubData(gl.ARRAY_BUFFER, 0, data);
gl.bufferSubData(gl.ARRAY_BUFFER, sizeInBytes, dataCopy);
}
}
});
</script>
</body>

</html>

0 comments on commit 34a0d15

Please sign in to comment.