Skip to content

feat: WebGPU immersive XR presentation#8717

Merged
mvaligursky merged 3 commits into
mainfrom
mv-webgpu-xr
May 11, 2026
Merged

feat: WebGPU immersive XR presentation#8717
mvaligursky merged 3 commits into
mainfrom
mv-webgpu-xr

Conversation

@mvaligursky

@mvaligursky mvaligursky commented May 11, 2026

Copy link
Copy Markdown
Contributor

partial implementation of #7404

Adds initial WebXR immersive rendering support when using a WebGPU graphics device (XRGPUBinding, XRGPUProjectionLayer), including routing the session color texture into the WebGPU backbuffer path each frame. WebGL behavior is unchanged aside from an extra ignored beginFrame argument for API parity.

Changes:

  • WebGPU: XR bridge attaches a projection layer, updates xrColorTexture / view format per frame from getViewSubImage, and clears them in endFrame / destroy.
  • WebGPU: frameStart prefers the XR color texture over the canvas swapchain (with optional externalBackbuffer fallback for non-canvas hosts).
  • WebGPU: render-target color assignment and MSAA formats follow the configured attachment view format (including XR subimage format).
  • XR: XrBridge.beginFrame(frame, referenceSpace) and XrManager pass the active reference space through to the backend.
  • Examples: ar-basic uses deviceType and createGraphicsDevice so the device selector matches the runtime backend (WebGPU or WebGL2).

Examples:

  • Updated examples/src/examples/xr/ar-basic.example.mjs.

Notes:

  • Stereo WebGPU is still first-view oriented; follow-up work is noted in code for texture-array / multiview.

This is required to run the example on Android
Screenshot 2026-05-11 at 15 34 34

Screenshot_20260511-151153

- Wire XRGPUBinding / projection layer and per-frame color texture for WebGPU
- Pass reference space through XrBridge.beginFrame for subimage resolution
- Align WebGL XR bridge beginFrame signature; update ar-basic example for deviceType

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial immersive WebXR presentation support for the WebGPU backend by wiring XRGPUBinding / projection layers into the engine’s per-frame backbuffer selection, while keeping the WebGL XR path API-compatible.

Changes:

  • Pass active XRReferenceSpace through XrManager -> XrBridge -> backend beginFrame to enable WebGPU subimage acquisition.
  • WebGPU: create/update an XR projection layer, route XR subimage color textures into WebgpuGraphicsDevice.frameStart, and propagate view format into render-target/MSAA setup.
  • Update ar-basic XR example to use createGraphicsDevice + AppBase so the runtime-selected device backend (WebGPU/WebGL2) matches the example’s initialization.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/platform/graphics/xr-bridge.js Extends beginFrame API to accept referenceSpace and forwards to backend impl.
src/platform/graphics/webgpu/webgpu-xr-bridge.js Implements WebGPU XR binding + projection layer handling; extracts per-frame subimage color textures / formats.
src/platform/graphics/webgpu/webgpu-render-target.js Allows assigned backbuffer texture view format to be specified and used for MSAA allocation/resolve.
src/platform/graphics/webgpu/webgpu-graphics-device.js Prefers XR color texture (or external backbuffer) over canvas swapchain, and plumbs attachment view format through backbuffer setup.
src/platform/graphics/webgl/webgl-xr-bridge.js Updates beginFrame signature for parity (referenceSpace ignored).
src/framework/xr/xr-manager.js Passes the active reference space into xrBridge.beginFrame.
examples/src/examples/xr/ar-basic.example.mjs Switches to backend-selected device creation + AppBase initialization for XR AR example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/platform/graphics/webgpu/webgpu-xr-bridge.js
Comment thread src/platform/graphics/webgpu/webgpu-xr-bridge.js Outdated
Comment thread src/platform/graphics/webgpu/webgpu-graphics-device.js
@mvaligursky mvaligursky merged commit d726cce into main May 11, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv-webgpu-xr branch May 11, 2026 14:37
*/
class WebgpuXrBridge {
/**
* @type {any} // `XRGPUBinding | null`; using `any` to avoid exporting WebXR GPU types in published typings.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a private field, the type won't appear in the TS types anyway....or am I wrong about that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, will fix

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