Skip to content

WebGPU XR view-instanced rendering#8732

Draft
cabanier wants to merge 2 commits into
playcanvas:mainfrom
cabanier:webgpu_webxr_patches
Draft

WebGPU XR view-instanced rendering#8732
cabanier wants to merge 2 commits into
playcanvas:mainfrom
cabanier:webgpu_webxr_patches

Conversation

@cabanier
Copy link
Copy Markdown
Contributor

@cabanier cabanier commented May 15, 2026

  • Add native WebGPU XR view-instanced rendering when projection-layer sub-images share a texture array. The WebGPU XR bridge now detects compatible layered sub-images, records the view-count state on the device, and drives FramePassMultiView through a single native pass when supported.
  • Request and expose the WebGPU view-instancing and multisampled-array-textures capabilities, including maxViewInstanceCount handling. Backbuffer render-target setup now allocates array-layered color/depth attachments for native view-instanced XR, including multisampled texture-array attachments when needed.
  • Teach WGSL processing and bind group layout generation about multisampled 2D array textures, native view-index handling, and view-uniform arrays. Materials and mesh shader caching now include the view-instancing shader variant so XR array uniforms select the correct per-view matrices and camera data.

@mvaligursky
Copy link
Copy Markdown
Contributor

Amazing, I'll look into details next week, thanks so much!

@mvaligursky
Copy link
Copy Markdown
Contributor

I think we should move the built-ins / clustered lighting changes to a separate PRs, as those are pretty much read to be merged. I'll do it next week, unless you do before then. Great changes overall. Any idea where we might get those other multi-view / multi-sampled arrays extensions?

@cabanier
Copy link
Copy Markdown
Contributor Author

I can move those to their own separate PR.

@cabanier
Copy link
Copy Markdown
Contributor Author

They will land as experimental features in the next 2 releases of Quest Browser. As soon as the proposals are merged, I will ship them by default.

Add native WebGPU XR view-instanced rendering when projection-layer sub-images share a texture array. The WebGPU XR bridge now detects compatible layered sub-images, records the view-count state on the device, and drives FramePassMultiView through a single native pass when supported.

Request and expose the WebGPU view-instancing and multisampled-array-textures capabilities, including maxViewInstanceCount handling. Backbuffer render-target setup now allocates array-layered color/depth attachments for native view-instanced XR, including multisampled texture-array attachments when needed.

Teach WGSL processing and bind group layout generation about multisampled 2D array textures, native view-index handling, and view-uniform arrays. Materials and mesh shader caching now include the view-instancing shader variant so XR array uniforms select the correct per-view matrices and camera data.
@cabanier cabanier force-pushed the webgpu_webxr_patches branch from 00cb5b4 to 9fe3f8c Compare May 15, 2026 19:56
@cabanier
Copy link
Copy Markdown
Contributor Author

cabanier commented May 15, 2026

@mvaligursky done. I moved the optimization to a different patch. I'll keep this one as "draft"

@willeastcott willeastcott added performance Relating to load times or frame rate area: graphics Graphics related issue area: xr XR related issue labels May 17, 2026
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 adds a WebGPU-native XR view-instancing path so compatible XR stereo projection-layer texture arrays can render through a single native multi-view pass instead of replaying passes per eye.

Changes:

  • Adds WebGPU XR capability/state detection for view instancing, multisampled array textures, and layered XR sub-image descriptors.
  • Extends renderer/view uniform setup, shader processing, and material shader cache keys to support view-indexed uniform arrays.
  • Updates WebGPU render-target/backbuffer setup to allocate and bind array-layered color/depth attachments for native XR passes.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/scene/renderer/renderer.js Adds view-instancing uniform formats, array upload, and bind-group switching.
src/scene/renderer/frame-pass-multi-view.js Adds native single-pass XR path and preserves/restores XR render state.
src/scene/renderer/forward-renderer.js Propagates view-instancing shader variants and draws native XR views once.
src/scene/particle-system/particle-material.js Passes view-instancing shader processing option.
src/scene/mesh-instance.js Includes view-instancing in shader instance cache/input params.
src/scene/materials/standard-material.js Passes view-instancing shader processing option.
src/scene/materials/shader-material.js Passes view-instancing shader processing option.
src/scene/materials/material.js Documents the material shader parameter.
src/scene/materials/lit-material.js Passes view-instancing shader processing option.
src/platform/graphics/webgpu/webgpu-xr-bridge.js Detects compatible XR texture-array sub-images and exposes native view descriptor state.
src/platform/graphics/webgpu/webgpu-shader-processor-wgsl.js Adds multisampled 2D-array texture handling and native view-index uniform array rewriting.
src/platform/graphics/webgpu/webgpu-render-target.js Configures view-count render passes and array-layered attachments.
src/platform/graphics/webgpu/webgpu-graphics-device.js Requests/exposes WebGPU features and reallocates backbuffer on view-count changes.
src/platform/graphics/webgpu/webgpu-bind-group-format.js Propagates multisampled texture binding metadata.
src/platform/graphics/shader-processor-options.js Tracks view-instancing in processing options and generated shader keys.
src/platform/graphics/shader-definition-utils.js Emits multisampled array texture WGSL enable when supported.
src/platform/graphics/bind-group-format.js Adds multisampled metadata to texture bind formats.

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

@mvaligursky mvaligursky changed the title add WebGPU XR optimization WebGPU XR view-instanced rendering May 18, 2026
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 performance Relating to load times or frame rate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants