WebGPURenderer: Preserve material side during async compilation#34104
WebGPURenderer: Preserve material side during async compilation#34104RenaudRohlinger wants to merge 1 commit into
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
🖼️ E2E screenshot tests✅ All examples render correctly again (run). |
5af4b01 to
7269b7f
Compare
| * @return {NodeBuilder} The configured node builder. | ||
| */ | ||
| _createNodeBuilder( renderObject, material ) { | ||
| _createNodeBuilder( renderObject, material, materialSide = material.side ) { |
There was a problem hiding this comment.
Could the property be inside RenderObject? That way, perhaps we could make the function signatures cleaner. We have a backSide passId that is also used, while keeping the RenderObject unique in a similar context.
There was a problem hiding this comment.
Indeed! The side now lives on RenderObject as materialSide, they're already unique per pass thanks to the backSide passId, so the extra params are gone and the signatures are back to normal.
The root issue was compileAsync() calling _objects.get() after material.side had been restored. It now requests the render object during the traversal instead, so all the temporary save/restore is gone. The pipeline cache key and cull mode read it too, otherwise compileAsync() precompiles the wrong pipeline and the first render has to build it again anyway.
The diff removes more lines than it adds now 🙂
While working on it I also realized I wrongly implemented getForRenderDeferred a few months ago which is deadcode, I will remove that deadcode in a follow up PR.
There was a problem hiding this comment.
I don't want to block the PR but I'm in general not happy how much complexity the whole async compile feature introduces into the renderer.
There was a problem hiding this comment.
Happy to discuss the bigger picture in another thread. On this PR specifically it goes in your direction: it removes the duplicated sync/async path in createObjectPipeline, −73/+56 lines.
On the feature in general I agree, which is even why I considered rethinking the whole thing in #33766. But part of it is unavoidable: in the WebGLRenderer things like cull face, blending and the render target are set at draw time, while in the WebGPURenderer they're baked into the pipeline. So precompiling needs the full render context, and that's where the complexity comes from.
a063a72 to
3c297d7
Compare
3c297d7 to
e0c2048
Compare
Preserves BackSide and FrontSide when
compileAsync()yields during double-pass transparent material compilation.