feat(xr): WebGPU XR depth bridge, examples, and XR camera sync fixes#8721
Merged
Conversation
…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.
Contributor
There was a problem hiding this comment.
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.syncCameraDepthTexturefacade and move the WebGL GPU depth-texture aliasing logic out ofXrViewintoWebglXrBridge. - 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/AppBaseand 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.
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.
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
XrViewso it stays backend-agnostic for GPU depth, updates AR depth examples forcreateGraphicsDevice/AppBaseand 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 viagetCommandEncoder()so copies are not skipped when no encoder existed yet.Changes:
XrBridge.syncCameraDepthTexturefacade;WebglXrBridge.syncCameraDepthTexturecontains the former WebGL-only depth aliasing fromXrView;WebgpuXrBridge.syncCameraDepthTexturewarns once if GPU depthtextureis present.XrView._updateDepthdelegates GPU path to the bridge; CPU depth path unchanged.ar-camera-depth.example.mjs,ar-depth-sensing-placer.example.mjsusedeviceType,createGraphicsDevice,AppBase; WebGPU note for GLSL-only depth preview plane where applicable.WebglXrBridge.syncCameraColorTexture:setFramebuffer(defaultFramebuffer)after blit.WebgpuXrBridge.syncCameraColorTexture: usegetCommandEncoder()instead of readingcommandEncoderonly.Examples:
examples/src/examples/xr/ar-camera-depth.example.mjsexamples/src/examples/xr/ar-depth-sensing-placer.example.mjsPerformance: No intentional hot-path regressions;
Debug.warnOnceonly when WebGPU receives GPU depth texture info.