WebGPURenderer: Ensure render targets have consistent default depth values.#33191
Merged
Mugen87 merged 2 commits intomrdoob:devfrom Mar 17, 2026
Merged
WebGPURenderer: Ensure render targets have consistent default depth values.#33191Mugen87 merged 2 commits intomrdoob:devfrom
Mugen87 merged 2 commits intomrdoob:devfrom
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Collaborator
Author
|
Something with the framebuffer setup/clear in the WebGL backend isn't right. Investigating... |
Mugen87
commented
Mar 16, 2026
| const renderTargetData = this._textures.get( renderTarget ); | ||
|
|
||
| renderContext = this._renderContexts.get( renderTarget ); | ||
| renderContext = this._renderContexts.get( renderTarget, null, - 1 ); // using - 1 for the call depth to get a render context for the clear operation |
Collaborator
Author
There was a problem hiding this comment.
This was actually a bug. Nested calls of clear() corrupted the render context. It's not a common use case but the new clearDepth() call exposed it.
The callDepth approach introduced in #32546 for managing render contexts isn't ideal, tbh. While it helps to reduce the overall number of render contexts, it is error prone since you have to be careful not to request the wrong context like clear() did.
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 issue: -
Description
This issue has driven me nuts^^. I've encountered a strange rendering issue in a complex render setup and couldn't find the root cause. It took a while to isolate this issue but the following test case demonstrates a bug in
WebGPURenderer:https://jsfiddle.net/2mdwzyge/
As you can see nothing is rendered but when switching to the WebGL 2 backend the result is as expected (a rotating cube producing trails).
When
autoClearis set tofalse, the default values in a depth texture actually vary between WebGPU and WebGL (0 vs 1). This can produce hard to track bugs/inconsistent behavior so we should make sureWebGPURenderersetups depth textures with consistent default depth values.The PR is doing this by checking for uninitialized render targets and clears the depth once if
autoClearorautoClearDepthis disabled. When the auto clear flags are not changed, the render target will be guaranteed in a valid state because of the automatic clear.