feat: WebGPU immersive XR presentation#8717
Merged
Merged
Conversation
- 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
Contributor
There was a problem hiding this comment.
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
XRReferenceSpacethroughXrManager -> XrBridge -> backend beginFrameto 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-basicXR example to usecreateGraphicsDevice+AppBaseso 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.
| */ | ||
| class WebgpuXrBridge { | ||
| /** | ||
| * @type {any} // `XRGPUBinding | null`; using `any` to avoid exporting WebXR GPU types in published typings. |
Contributor
There was a problem hiding this comment.
Since this is a private field, the type won't appear in the TS types anyway....or am I wrong about that?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ignoredbeginFrameargument for API parity.Changes:
xrColorTexture/ view format per frame fromgetViewSubImage, and clears them inendFrame/ destroy.frameStartprefers the XR color texture over the canvas swapchain (with optionalexternalBackbufferfallback for non-canvas hosts).XrBridge.beginFrame(frame, referenceSpace)andXrManagerpass the active reference space through to the backend.ar-basicusesdeviceTypeandcreateGraphicsDeviceso the device selector matches the runtime backend (WebGPU or WebGL2).Examples:
examples/src/examples/xr/ar-basic.example.mjs.Notes:
texture-array/ multiview.This is required to run the example on Android
