Repository navigation
perf(webgpu): no native round trip per setVertexBuffer/setIndexBuffer; per-call benchmark - #218
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
…; per-call benchmark - GPUBuffer caches size and usage once at creation. The wrappers read buffer.size on every setVertexBuffer(slot, buffer) and setIndexBuffer(buffer, format) call to default the size, which crossed into native each time. They now pass "rest of the buffer" through, and the Rust entry points hand wgpu None instead of the whole buffer size, which was also wrong whenever an offset was given. - The pass encoder entry points cloned the pass label and fetched the error sink on every draw and state call without using them. - tools/demo/canvas/webgpu/perf.ts: a per-call WebGPU benchmark next to the 2D and WebGL ones (canvas-perf page, suite "webgpu"). iOS simulator, ns per call, before -> after: setVertexBuffer(slot, buffer) 449 -> 397, setIndexBuffer(buffer, format) 444 -> 395, buffer.size 51 -> 31; the other calls unchanged. A three.js scene at about 4k draws on Linux: median render 40.4 -> 38.3 ms.
triniwiz
force-pushed
the
perf/webgpu-binding-call-cost
branch
from
November 14, 2026 05:33
577dc5b to
6554280
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The hot render-pass methods already go through V8 fast calls, so this pass went after what sits around them.
GPUBuffercachessizeandusageonce at creation. The wrappers readbuffer.sizeon everysetVertexBuffer(slot, buffer)andsetIndexBuffer(buffer, format)call (how three.js calls them) to default the size, which crossed into native each time. They now pass "rest of the buffer" through, and the Rust entry points hand wgpuNoneinstead of the whole buffer size, which was also wrong whenever an offset was given.tools/demo/canvas/webgpu/perf.ts: a per-call WebGPU benchmark next to the 2D and WebGL ones.--es demo canvas-perf --es suite webgpuon Android,--demo=canvas-perf --suite=webgpuon the simulator; onePERF|line per op.iOS simulator (same C++ V8 bindings as Android), ns per call:
A three.js
WebGPURendererscene at about 4k draws per frame on the Linux build: medianrender()40.4 to 38.3 ms, rendering unchanged.