Open Bug 1972517 Opened 6 months ago Updated 1 month ago

[WebGPU] Very poor texture upload performance when passing canvas

Categories

(Core :: Graphics: WebGPU, defect, P4)

Firefox 141
defect

Tracking

()

People

(Reporter: ashley, Unassigned, NeedInfo)

References

(Blocks 1 open bug, )

Details

Steps to reproduce:

Visit repro URL and observe framerate: https://downloads.scirra.com/labs/textscaling/webgpu4/index.html

NOTE: this issue requires WebGPU support to reproduce which is currently only enabled in pre-release channels. Check that WebGPU is logged to the browser console to verify. This reproduces for me on Firefox Nightly 141.

The repro URL renders text at lots of different scales by drawing text to canvas2d and then uploading that as a texture. This is a way to get high-quality text rendering in WebGPU as it does not have any direct way to render text. It's used by our web-based game engine Construct (www.construct.net).

Actual results:

The performance of doing this is extremely poor. The test runs at around 8 FPS on a system with an NVIDIA GeForce RTX 3050.

Expected results:

On a high-end system this should be able to achieve a smooth 60 FPS. Indeed Chrome rendering with WebGL can achieve that. (Chrome with WebGPU is also slow - see https://issues.chromium.org/issues/40273077)

Firefox's WebGL renderer is also slow doing the same thing (see WebGL test: https://downloads.scirra.com/labs/textscaling/webgl/index.html). It would be nice if it was fixed for WebGL too, but for the future the main thing we care about is that it's fast in WebGPU.

The Bugbug bot thinks this bug should belong to the 'Core::Graphics: WebGPU' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Graphics: WebGPU
Product: Firefox → Core
Blocks: webgpu-perf
Status: UNCONFIRMED → NEW
Ever confirmed: true
See Also: → 1972649

UPDATE: wrong Bug, sorry. Bug 1971296 is likely the same cause as this Bug, but that one started only recently. It's probably just a mis-attribution of the crash signature. I'll try to replicate on iCloud and when I have a fix for the other Bug, I'll see if it fixes the issue here.

See Also: → 1971296

Sorry, was on the wrong Bug page and I correlated these Bugs incorrectly.

See Also: 1971296

The severity field is not set for this bug.
:jimb, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(jimb)
Severity: -- → S3

FWIW I have an updated repro as we have made some changes to our WebGPU rendering code to try to handle this more efficiently: https://downloads.scirra.com/labs/textscaling/webgpu-batched/index.html

It no longer generates mipmaps, and it also batches all texture uploads together to avoid creating render passes in between every texture upload. In Firefox 143 on a high-end dev machine with a GeForce RTX 4070 this still runs so slowly as to appear to freeze.

We on the WebGPU team think that you might notice a significant improvement after we fix bug 1870699. We'll check in with you when that's resolved.

See Also: → 1870699
Priority: -- → P4

Here's an updated repro where we've further tried to optimize things on our side: https://downloads.scirra.com/labs/textscaling/webgpu-two-phase/index.html

This now updates all canvases, before proceeding to upload all canvases to WebGPU textures with consecutive calls to copyExternalImageToTexture(). However it does not appear to have improved performance much in Firefox (guessing we're still waiting on bug 1870699 anyway)

You need to log in before you can comment on or make changes to this bug.