fix(pipeline): keep MANAGED render targets alive across frames in release builds - #19198
Open
hakastein wants to merge 1 commit into
Open
fix(pipeline): keep MANAGED render targets alive across frames in release builds#19198hakastein wants to merge 1 commit into
hakastein wants to merge 1 commit into
Conversation
…ease builds pipeline.resourceUses is filled only by Compiler, which does not contribute in a release build: web-pipeline.ts wraps the compiler in `if (DEBUG)`, and the RasterPass node is created with `valid = !DEBUG` so _fetchValidPass returns before the loop that fills the list. Executor._removeDeviceResource then finds no name in it and releases every MANAGED device texture and buffer, so the cascaded shadow map was reallocated once per frame. Collect the names from the frame's render graph before the sweep instead.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Code Size Check Report
Interface Check ReportThis pull request does not change any public interfaces ! |
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.
Re: #19197
Changelog
Executor._removeDeviceResource().pipeline.resourceUsesis filled only byCompiler, which does not contribute in a release build, so everyMANAGEDdevice texture and buffer — the cascaded shadow map among them — was released at the start of each frame and reallocated during it.Where I put it, and why there
I looked for an existing per-frame traversal of the frame's resource names to fill the list from, and
did not find one — but I may well be missing something, and a better home for this is entirely
possible. What I checked:
Compilerfills the list atcompiler.ts:170, but that line sits afterif (validPass) return;, andweb-pipeline.ts:1648wraps the whole compiler inif (DEBUG).resourceUses.push()atexecutor.ts:156is in theResourceVisitorconstructor, and the visitor looks like a module-level singleton created once atexecutor.ts:754with the defaultresName = '', while theresNamesetter does not push. If that is right, the registration may have been intended to sit in the setter.DeviceRenderPassdoes iteraterasterPass.rasterViews, but instances appear to be cached by pass hash incontext.devicePassesand dropped only inrelease(), so that loop would not run per frame.If there is a more natural place for this, happy to move it.
Alternative worth considering
pipeline.resourceUseshas exactly one consumer — this method — and it is queried withArray.includes()in two loops below. A localSetbuilt here and queried withhas()would drop the linear scans and make the deduplication free, and would remove the need for the array to carry state between the compile and execute phases at all. That would make both existing writers dead code, so it is a call for the maintainers rather than something to slip into a bug fix; this PR keeps the public field and its semantics untouched and only deduplicates on insert.Verification
Web Mobile release build, Redmi 9C (Helio G35, PowerVR GE8320, 3 GB): 8 fps before, 24 after, output unchanged. Texture allocations over 150 frames drop from 300 (two 2048×2048 per frame) to 0. Tested on a scene with cascaded shadows and no post-processing;
ComputeandCopypasses were not exercised.Continuous Integration
This pull request:
Compatibility Check
This pull request: