Skip to content

perf(webgpu): pooled buffer uploads; core adapter for compatibility requests - #198

Open
triniwiz wants to merge 1 commit into
masterfrom
perf/webgpu-uploads-and-adapter
Open

triniwiz wants to merge 1 commit into
masterfrom
perf/webgpu-uploads-and-adapter

Conversation

@triniwiz

@triniwiz triniwiz commented Nov 9, 2026

Copy link
Copy Markdown
Member

What

Buffer uploads (wgpu fork bump, e5c0aa02 → 399344e78)

queue.writeBuffer used to create, allocate and map a new staging buffer on every call, then record its own barrier and copy. The fork commit changes that:

  • Writes up to 256 KiB are sub-allocated from persistently mapped 1 MiB staging chunks.
  • A chunk is reused once the GPU has finished the submission that used it.
  • Copies from one chunk to one buffer go out as a single multi-region copy.
  • Write order is kept. An overlapping write, or any other command recorded into the queue's pending encoder, records the queued copies first.

Larger writes, and the GL backend, keep the old path.

Adapter on Android (crates/canvas-c/src/webgpu/gpu.rs)

requestAdapter({ featureLevel: 'compatibility' }) went straight to wgpu's GL backend, which finds no adapter, so it resolved to null. three.js WebGPURenderer always asks for compatibility, so it silently fell back to its WebGL2 backend.

Now:

  • A compatibility request gets the hardware Vulkan adapter, with GL only when there is none.
  • Non-GL adapters report core and core-features-and-limits.

Measurements

Galaxy S25 Ultra at 60 Hz, three.js r184 WebGPURenderer, a mixed-material scene of about 2,600 draws and 6,000 writeBuffer calls per frame. Before and after are the same tree in the same session.

before after
fps 28.3 46.2
median render() 34.6 ms 20.8 ms
writeBuffer per frame 19.2 ms 3.5 ms
app PSS 979 MiB 799 MiB

At about 5,200 draws, fps went from 10.9 to 19.3 and median render() from 79.6 ms to 50.5 ms.

Testing

  • Android: canvas WebGPU spec suite on device, 21/23. Both failures are the webgpu.video specs, which fail the same way before this change.
  • wgpu fork: GPU suite on Metal, 499/501. The 2 passthrough failures also fail on the previous rev. A new queue_write_pooled test writes thousands of mixed-size ranges across submissions and reads them back; it fails if the pool's offsets are broken.
  • Limitation: the Metal backend runs copy regions in order, so the overlap flush only really matters on Vulkan. The device spec run covers that.

…equests

- Bump wgpu to the fork commit that sub-allocates small Queue::write_buffer
  uploads from reused staging chunks and records them as batched copies,
  instead of creating, mapping and copying from a new staging buffer per call.
- Android: a featureLevel "compatibility" request now gets the hardware Vulkan
  adapter (GL only without it), and the adapter reports core with
  "core-features-and-limits" unless it is GL. Before, it went to the GL backend,
  which returned no adapter, so libraries that ask for compatibility (three.js
  WebGPURenderer) fell back to WebGL2.
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 321e4b9b-013b-4511-bb63-67025d5a9e37

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant