Skip to content

feat(xr): WebGPU AR camera color and syncCameraColorTexture bridge#8720

Merged
mvaligursky merged 1 commit into
mainfrom
mv-webgpu-ar-camera-color
May 12, 2026
Merged

feat(xr): WebGPU AR camera color and syncCameraColorTexture bridge#8720
mvaligursky merged 1 commit into
mainfrom
mv-webgpu-ar-camera-color

Conversation

@mvaligursky
Copy link
Copy Markdown
Contributor

@mvaligursky mvaligursky commented May 12, 2026

related to #7404

Enables immersive AR camera color (camera-access) when using a WebGPU graphics device, routes camera image sync through the XR bridge implementations, and updates the AR camera color example to the modern device bootstrap.

Changes:

  • Example: ar-camera-color uses createGraphicsDevice + AppBase (same pattern as ar-basic), drops WEBGPU_DISABLED, and keeps camera color / drawTexture behavior.
  • Session options: camera-access is requested whenever cameraColor is set and views.supportedColor is true (no longer gated on WebGL only).
  • XrViews.supportedColor: Computed in the constructor from the active graphics device so WebGL apps only require XRWebGLBinding, WebGPU apps only XRGPUBinding (plus XRCamera).
  • Camera color sync: XrBridge.syncCameraColorTexture delegates to WebglXrBridge (FBO + blitFramebuffer with original comments) or WebgpuXrBridge (getCameraImage + copyTextureToTexture when available). XrView only calls the bridge each frame.

Examples:

  • Updated examples/src/examples/xr/ar-camera-color.example.mjs.

Notes: WebGPU getCameraImage / texture format compatibility depends on the user agent; the WebGPU path no-ops if the API is missing. Camera color texture resize-on-XRCamera dimension change is unchanged from prior behavior (still allocated once in XrView).

- ar-camera-color: createGraphicsDevice + AppBase; allow WebGPU
- XrViews: supportedColor from active device (XRWebGLBinding vs XRGPUBinding)
- XrManager: request camera-access when supportedColor without WebGL-only gate
- XrBridge/Webgl/Webgpu: syncCameraColorTexture; XrView delegates; GL FBO path + comments in WebglXrBridge; WebGPU copyTextureToTexture when getCameraImage exists
@mvaligursky mvaligursky self-assigned this May 12, 2026
@mvaligursky mvaligursky requested review from Maksims and Copilot May 12, 2026 08:55
@mvaligursky mvaligursky added area: graphics Graphics related issue area: xr XR related issue labels May 12, 2026
@mvaligursky mvaligursky merged commit 48ea590 into main May 12, 2026
10 checks passed
@mvaligursky mvaligursky deleted the mv-webgpu-ar-camera-color branch May 12, 2026 08:57
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 extends the engine’s XR camera color pipeline to work across both WebGL and WebGPU by moving “camera image → engine texture” syncing behind the XR bridge implementations, and updates the AR camera color example to the modern createGraphicsDevice + AppBase bootstrap.

Changes:

  • Adds XrBridge.syncCameraColorTexture() and routes per-frame camera color syncing through backend bridge implementations (WebGL blit, WebGPU copy).
  • Requests camera-access for AR when cameraColor is enabled and the runtime/device supports camera color (no longer WebGL-only).
  • Updates the ar-camera-color example to match modern device/app initialization patterns.

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 Adds a bridge-level syncCameraColorTexture entry point delegating to backend impls.
src/platform/graphics/webgpu/webgpu-xr-bridge.js Implements WebGPU camera image copy path using XRGPUBinding.getCameraImage + copyTextureToTexture.
src/platform/graphics/webgl/webgl-xr-bridge.js Implements WebGL camera image blit path using FBOs + blitFramebuffer (with Y-flip).
src/framework/xr/xr-views.js Computes supportedColor based on active graphics backend (WebGL vs WebGPU binding availability).
src/framework/xr/xr-view.js Removes inline WebGL camera blit logic and delegates to xrBridge.syncCameraColorTexture.
src/framework/xr/xr-manager.js Requests camera-access whenever cameraColor is requested and views.supportedColor is true.
examples/src/examples/xr/ar-camera-color.example.mjs Updates example initialization to createGraphicsDevice + AppBase.

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

Comment on lines +205 to +212

// set frame buffer to read from
device.setFramebuffer(this._cameraFbSource);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, src, 0);

// set frame buffer to write to
device.setFramebuffer(this._cameraFbDest);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture.impl._glTexture, 0);
}

const device = this.xrBridge.device;
const encoder = device.commandEncoder;
Comment on lines +64 to +67
if (this._cameraFbSource) {
const gl = device.gl;
gl.deleteFramebuffer(this._cameraFbSource);
this._cameraFbSource = null;
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