Skip to content

feat: Add XrBridge for backend-specific WebXR presentation#8712

Merged
mvaligursky merged 2 commits into
mainfrom
mv-xr-presentation-bridge
May 11, 2026
Merged

feat: Add XrBridge for backend-specific WebXR presentation#8712
mvaligursky merged 2 commits into
mainfrom
mv-xr-presentation-bridge

Conversation

@mvaligursky
Copy link
Copy Markdown
Contributor

@mvaligursky mvaligursky commented May 11, 2026

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:

  • Add XrBridge facade plus WebglXrBridge and stub WebgpuXrBridge, wired from WebglGraphicsDevice / WebgpuGraphicsDevice via createXrBridgeImpl.
  • XrManager creates a bridge for the active session, uses it for attachPresentation / releasePresentation, graphicsBinding, presentationLayer (e.g. fixed foveation), and routes restore failures through the manager EventHandler.
  • Move devicelost / devicerestored subscriptions onto the bridge for the session lifetime; bridge holds shared session presentation fields used across backends.
  • XrView reads graphicsBinding for camera/depth paths that use the WebXR GL binding.

Public API:

  • XrManager#graphicsBinding — getter returning the active backend binding for XR camera/depth (XRWebGLBinding on WebGL when supported), or null.

related to #7404

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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 via GraphicsDevice#createXrBridgeImpl.
  • Updated XrManager to create/destroy the bridge per XR session, route presentation attach/release through it, and expose a new public graphicsBinding getter.
  • Updated XR view paths to use XrManager#graphicsBinding for 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.

Comment thread src/platform/graphics/webgpu/webgpu-xr-bridge.js
Comment thread src/platform/graphics/webgpu/webgpu-xr-bridge.js
Comment thread src/framework/xr/xr-manager.js
@mvaligursky mvaligursky merged commit f27d65e into main May 11, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv-xr-presentation-bridge branch May 11, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue area: xr XR related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants