Skip to content

feat(xr): WebGPU XR depth bridge, examples, and XR camera sync fixes#8721

Merged
mvaligursky merged 2 commits into
mainfrom
mv-xr-depth-webgpu
May 12, 2026
Merged

feat(xr): WebGPU XR depth bridge, examples, and XR camera sync fixes#8721
mvaligursky merged 2 commits into
mainfrom
mv-xr-depth-webgpu

Conversation

@mvaligursky
Copy link
Copy Markdown
Contributor

@mvaligursky mvaligursky commented May 12, 2026

related to #7404

Adds GPU XR depth texture handling behind the XR bridge (WebGL implementation, WebGPU no-op with a one-time warning when GPU depth textures are present), refactors XrView so it stays backend-agnostic for GPU depth, updates AR depth examples for createGraphicsDevice / AppBase and WebGPU-friendly messaging, restores the WebGL default framebuffer after the XR camera color blit so device framebuffer shadow state matches XR, and records WebGPU camera color copies via getCommandEncoder() so copies are not skipped when no encoder existed yet.

Changes:

  • XrBridge.syncCameraDepthTexture facade; WebglXrBridge.syncCameraDepthTexture contains the former WebGL-only depth aliasing from XrView; WebgpuXrBridge.syncCameraDepthTexture warns once if GPU depth texture is present.
  • XrView._updateDepth delegates GPU path to the bridge; CPU depth path unchanged.
  • Examples: ar-camera-depth.example.mjs, ar-depth-sensing-placer.example.mjs use deviceType, createGraphicsDevice, AppBase; WebGPU note for GLSL-only depth preview plane where applicable.
  • WebglXrBridge.syncCameraColorTexture: setFramebuffer(defaultFramebuffer) after blit.
  • WebgpuXrBridge.syncCameraColorTexture: use getCommandEncoder() instead of reading commandEncoder only.

Examples:

  • examples/src/examples/xr/ar-camera-depth.example.mjs
  • examples/src/examples/xr/ar-depth-sensing-placer.example.mjs

Performance: No intentional hot-path regressions; Debug.warnOnce only when WebGPU receives GPU depth texture info.

…fixes

Add syncCameraDepthTexture on XrBridge with WebGL GPU depth aliasing and a
WebGPU stub with warnOnce when GPU depth textures are present. Refactor
XrView to delegate GPU depth updates. Update AR depth examples for
createGraphicsDevice/AppBase and WebGPU notes. Restore default framebuffer
after WebGL camera color blit; use getCommandEncoder for WebGPU camera copy.
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 refactors XR camera depth handling into the backend bridge layer (so XrView stays backend-agnostic), fixes a couple of XR camera color sync edge cases on WebGL/WebGPU, and updates AR depth examples to the newer createGraphicsDevice + AppBase initialization flow.

Changes:

  • Add XrBridge.syncCameraDepthTexture facade and move the WebGL GPU depth-texture aliasing logic out of XrView into WebglXrBridge.
  • WebGL: restore the XR default framebuffer after the camera-color blit; WebGPU: always record camera-color copies by using getCommandEncoder().
  • Update AR depth examples to use createGraphicsDevice/AppBase and add WebGPU messaging/behavior notes.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/platform/graphics/xr-bridge.js Adds a backend-delegated syncCameraDepthTexture API on the XR bridge.
src/platform/graphics/webgpu/webgpu-xr-bridge.js Ensures camera color copies always get recorded; adds a one-time warning for GPU depth textures.
src/platform/graphics/webgl/webgl-xr-bridge.js Restores default framebuffer after blit; implements WebGL GPU depth texture aliasing in the bridge.
src/framework/xr/xr-view.js Delegates GPU depth-texture binding to the bridge instead of directly touching WebGL internals.
examples/src/examples/xr/ar-camera-depth.example.mjs Migrates to createGraphicsDevice/AppBase; adds WebGPU messaging/guards (but currently still compiles GLSL on WebGPU).
examples/src/examples/xr/ar-depth-sensing-placer.example.mjs Migrates to createGraphicsDevice/AppBase.

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

Comment thread examples/src/examples/xr/ar-camera-depth.example.mjs
Comment thread examples/src/examples/xr/ar-camera-depth.example.mjs
@mvaligursky mvaligursky merged commit f5377b7 into main May 12, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv-xr-depth-webgpu branch May 12, 2026 10:46
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.

2 participants