Skip to content

Is OffscreenCanvas rendering supported in WebGPU context? #17776

@lisanlow

Description

@lisanlow

I see that webgpu OffscreenCanvas rendering is already available in chromium with this bug fix:

Looking at current implementation of wgpuInstanceCreateSurface(), it appears to me that rendering to OffscreenCanvas is currently not available in native webgpu API.
This code section shows that wgpuInstanceCreateSurface() asserts expect webgpu surface to be associated only to HTML canvas element?
https://github.com/emscripten-core/emscripten/blob/main/src/library_webgpu.js#L2410
WebGPUOffscreenNotSupported
Is my understanding correct?
If so, is there any known alternatives to render to canvas on webworker then transfer rendered output to main thread for chrome browser display?

In my prototype code, I am trying to configure OffscreenCanvas in the HTML and referencing this canvas in wgpuInstanceCreateSurface() call to be used for subsequent rendering.
It appears mandatory to define WGPUSurfaceDescriptorFromCanvasHTMLSelector when creating webgpu surface.
https://github.com/emscripten-core/emscripten/blob/main/src/library_webgpu.js#L2399
OffscreenHTML

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions