Skip to content

Add renderer backend and reversedDepthBuffer properties, pass multiview option to WebGPURenderer - #5847

Open
vincentfretin wants to merge 4 commits into
aframevr:masterfrom
vincentfretin:webgpu-renderer-options
Open

Add renderer backend and reversedDepthBuffer properties, pass multiview option to WebGPURenderer#5847
vincentfretin wants to merge 4 commits into
aframevr:masterfrom
vincentfretin:webgpu-renderer-options

Conversation

@vincentfretin

Copy link
Copy Markdown
Contributor

Fixes #5749

New renderer properties

  • multiviewStereo is now also passed as the multiview option used by WebGPURenderer (WebGLRenderer keeps reading multiviewStereo, each renderer ignores the other's key).
  • New reversedDepthBuffer property, passed as-is to both WebGLRenderer and WebGPURenderer.
  • New backend property (webgpu or webgl): backend: webgl maps to the forceWebGL option of WebGPURenderer. When unset, nothing is passed so the WebGPU build keeps its current behavior (try WebGPU, fall back to WebGL2). Ignored by WebGLRenderer.

Wait for async renderer init before starting the render loop

WebGPURenderer initializes its backend asynchronously via init(). Previously renderStarted was set and renderstart emitted while the backend was still initializing (three.js setAnimationLoop recovers by awaiting init internally, but anything reacting to renderstart calling e.g. renderer.render() or compileAsync() would throw .render() called before the backend is initialized). The render loop kickoff now awaits renderer.init() when it exists; WebGLRenderer has no init method and keeps the fully synchronous path.

Tests

The renderer attribute parsing is extracted from setupRenderer() into getRendererConfig() so it is unit-testable without creating a WebGL context (setupRenderer is stubbed on CI). Added tests for multiviewStereo/multiview, reversedDepthBuffer, backend and the async init behavior. There were no existing tests covering multiviewStereo.

Also adds a code note that setPoseTarget (A-Frame specific super-three patch to WebXRManager) will need an equivalent in the XRManager used by WebGPURenderer when WebXR support is added.

Verified at runtime with both builds (npm run dev and npm run start:webgpu) driving headless Chrome: options reach the renderer (backend.isWebGLBackend, reversedDepthBuffer, xr._useMultiviewIfPossible) and renderer.initialized is now true when renderstart fires. Actual multiview rendering in VR still needs a headset test with examples/performance/multiview-extension.

🤖 Generated with Claude Code

vincentfretin and others added 3 commits July 4, 2026 16:03
…ew to WebGPURenderer

- multiviewStereo is now also passed as the multiview option used by
  WebGPURenderer (fixes aframevr#5749)
- new reversedDepthBuffer property passed to both WebGLRenderer and
  WebGPURenderer
- new backend property (webgpu or webgl) mapped to the forceWebGL option
  of WebGPURenderer; ignored by WebGLRenderer

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…derer config tests

WebGPURenderer initializes its backend asynchronously via init().
Previously renderStarted was set and renderstart emitted while the
backend was still initializing (three.js setAnimationLoop recovers by
awaiting init internally, but anything reacting to renderstart could
call renderer methods that throw before initialization). The render
loop kickoff now awaits renderer.init() when it exists; WebGLRenderer
has no init method and keeps the synchronous path.

Extract getRendererConfig() from setupRenderer() so the renderer
attribute parsing is unit-testable without creating a WebGL context,
and add tests for multiviewStereo/multiview, reversedDepthBuffer,
backend and the async init behavior.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
setPoseTarget is an A-Frame specific patch in super-three to the
WebXRManager used by WebGLRenderer. An equivalent will need to be
implemented in super-three for the XRManager used by WebGPURenderer
when WebXR support for WebGPURenderer is added.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mrxz

mrxz commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

New backend property (webgpu or webgl): backend: webgl maps to the forceWebGL option of WebGPURenderer. When unset, nothing is passed so the WebGPU build keeps its current behavior (try WebGPU, fall back to WebGL2). Ignored by WebGLRenderer.

I think it would be better to use the values webgl and auto for now (defaulting to the latter). It's quite likely that some users might end up with setups that require WebGPU and won't work with the WebGL backend of the WebGPURenderer. Down the line we could then introduce a webgpu value for this property that asserts WebGPU support.

For reference, quite a few WebGPU examples in Three.js require WebGPU support and show a simple error message "Your browser does not support WebGPU yet" when it's not supported.

As suggested in PR review, the default value is auto (WebGPU when
available, falling back to WebGL 2) since the WebGPU backend is not
guaranteed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vincentfretin

Copy link
Copy Markdown
Contributor Author

yes, I changed webpgu to auto

Alvis1 added a commit to Alvis1/FastShaders that referenced this pull request Aug 31, 2026
…igator.gpu hack

Bumps the a-frame-shaderloader submodule, which now carries the relevant
half of the still-open aframevr/aframe#5847: `<a-scene renderer="backend:
webgl">` maps to WebGPURenderer's `forceWebGL`. That is the only way to
enter WebXR on this bundle — three refuses XR on a WebGPU backend — and
it replaces hiding navigator.gpu in an inline <script> per document.

MEASURED in headless Chrome with navigator.gpu present: backend: webgl ->
WebGL2, no attribute -> WebGPU. The rebuilt bundle minus its two
insertions is byte-identical to the previous one, so the copies every
exported shader loads from jsdelivr are unchanged in behaviour.

aframeBackendProperty.test.ts guards all three vendored copies against a
rebuild that silently drops the patch, checking the strings esbuild
actually EMITS (it re-minifies, renaming the config object) rather than
the ones build.mjs writes — a source-only check would pass on a bundle
that was never rebuilt. It also asserts three still refuses XR on WebGPU:
the day that fails is the day the whole carry can be deleted.

NOT YET SWITCHED: tslToPreviewHTML's XR mode, podest.html (x2),
ShaderCarousel/bench-inout and the A-Frame embed export still hide
navigator.gpu. That migration must come AFTER this bundle is pushed and
jsdelivr is purged, or a page using the attribute against the old cached
bundle silently gets WebGPU and throws on Enter VR.

167 files / 2934 tests green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

Add support for multiview with WebGPURenderer

2 participants