Skip to content

Add WebGPU backend interop for WebXR integration - #9350

Closed
RenzoraEngine wants to merge 5 commits into
gfx-rs:trunkfrom
renzora:trunk
Closed

Add WebGPU backend interop for WebXR integration#9350
RenzoraEngine wants to merge 5 commits into
gfx-rs:trunkfrom
renzora:trunk

Conversation

@RenzoraEngine

@RenzoraEngine RenzoraEngine commented Mar 31, 2026

Copy link
Copy Markdown

the code in the PR is generated with AI assistance using Claude Opus 4.6 (1M context)

Relates to #4067

Add Device::as_webgpu() and Device::create_texture_from_webgpu() as the WebGPU backend equivalents of as_hal()/create_texture_from_hal(). Add RequestAdapterOptions::xr_compatible to pass through the xrCompatible flag per the WebXR WebGPU Binding spec.

There is currently no way to use wgpu for WebXR rendering on the WebGPU backend. The XR compositor provides GPUTexture objects that wgpu needs to render into, and requires the underlying GPUDevice to create an XRGPUBinding. These three additions solve that.

No internal types are exposed. Both methods use JsValue at the public API boundary. 62 lines across 3 files, no breaking changes, no new dependencies.

Working demo: renzora/wgpu-webxr-webgpu — renders a scene in stereo VR directly into XR projection layer textures. Tested on Chrome + Meta Quest via Horizon Link.

Tested manually with a working WebXR demo on Chrome with Meta Quest headset via Horizon Link. WebXR cannot be tested in CI as it requires VR hardware and browser flags (chrome://flags/#webxr-incubations).

Single commit, ready to rebase.

Add Device::as_webgpu() and Device::create_texture_from_webgpu()
as the WebGPU backend equivalents of as_hal()/create_texture_from_hal().
Add RequestAdapterOptions::xr_compatible to pass through the
xrCompatible flag per the WebXR WebGPU Binding spec.

Relates to #4067
@TheButlah

TheButlah commented Mar 31, 2026

Copy link
Copy Markdown

After just a cursory glance, this PR does introduce breaking changes. For example the addition of a new field in RequestAdapterOptions I recommend that you begin disclosing when a PR description/content is ai generated :/

@RenzoraEngine

Copy link
Copy Markdown
Author

@TheButlah I have updated the description to include the disclaimer.

@cwfitzgerald cwfitzgerald self-assigned this Apr 1, 2026
@cwfitzgerald

Copy link
Copy Markdown
Member

This PR doesn't appear to follow our guidelines of change ownership and LLM policy, see https://github.com/gfx-rs/wgpu/blob/trunk/CONTRIBUTING.md#change-ownership. We'd welcome a change of this nature, but as it stands, we cannot accept this.

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.

3 participants