feat: Add XrBridge for backend-specific WebXR presentation#8712
Merged
Conversation
Move XRWebGLLayer/binding and device lost/restore handling into platform graphics with WebGL and WebGPU implementations. XrManager exposes graphicsBinding for camera/depth paths; session-scoped shared state lives on the bridge facade.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an XrBridge abstraction to move WebXR immersive presentation responsibilities (output layer, optional graphics binding, and device lost/restore handling) into the graphics backend layer, reducing WebGL-specific logic inside the XR framework and preparing for backend-specific XR implementations.
Changes:
- Added a backend bridge facade (
XrBridge) with a WebGL implementation (WebglXrBridge) and a stub WebGPU implementation (WebgpuXrBridge), wired viaGraphicsDevice#createXrBridgeImpl. - Updated
XrManagerto create/destroy the bridge per XR session, route presentation attach/release through it, and expose a new publicgraphicsBindinggetter. - Updated XR view paths to use
XrManager#graphicsBindingfor camera/depth APIs that rely on the WebXR graphics binding.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/platform/graphics/xr-bridge.js | Introduces the bridge facade, lifetime management, and accessors for presentation layer / graphics binding. |
| src/platform/graphics/webgl/webgl-xr-bridge.js | Implements WebGL XR presentation, XRWebGLBinding creation, and device lost/restore handling. |
| src/platform/graphics/webgpu/webgpu-xr-bridge.js | Adds a WebGPU XR bridge stub (currently non-functional). |
| src/platform/graphics/webgl/webgl-graphics-device.js | Wires WebGL device to create the XR bridge implementation. |
| src/platform/graphics/webgpu/webgpu-graphics-device.js | Wires WebGPU device to create the XR bridge implementation. |
| src/framework/xr/xr-manager.js | Uses the bridge for session presentation and exposes the new graphicsBinding public API. |
| src/framework/xr/xr-view.js | Switches camera/depth binding usage from webglBinding to graphicsBinding. |
| examples/src/examples/gaussian-splatting-xr/vr-lod.example.mjs | Updates example metadata to hide the example in the viewer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Introduces a small platform graphics abstraction so WebXR immersive presentation (output layer, optional
XRWebGLBinding, and GPU loss/restore glue) lives next to each graphics backend instead of only inside the XR framework.Changes:
XrBridgefacade plusWebglXrBridgeand stubWebgpuXrBridge, wired fromWebglGraphicsDevice/WebgpuGraphicsDeviceviacreateXrBridgeImpl.XrManagercreates a bridge for the active session, uses it forattachPresentation/releasePresentation,graphicsBinding,presentationLayer(e.g. fixed foveation), and routes restore failures through the managerEventHandler.devicelost/devicerestoredsubscriptions onto the bridge for the session lifetime; bridge holds shared session presentation fields used across backends.XrViewreadsgraphicsBindingfor camera/depth paths that use the WebXR GL binding.Public API:
XrManager#graphicsBinding— getter returning the active backend binding for XR camera/depth (XRWebGLBindingon WebGL when supported), ornull.related to #7404