Skip the pass-hazard scan of every sampled texture. #416
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!416
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/replay-lookups"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
draw_hazardswalks every texture the open pass has sampled, on every draw, to see whether this draw writes one of them. A dense Kokiri frame is about 1627 draws and the submit is about 12.7 ms (issue #384). The list grows through the pass, so the check is draws times textures sampled so far.The read-only bind memo and the uniform gap landed in #392 and #397 while this was being prepared. Those stay as they are.
Change
A pass keeps
sampled_targets(colour i is bit i, depth is bit 8). The bit is set when a sampled texture is first recorded, after the hazard check, so only earlier draws count. The second scan is that mask. A new pass clears it with the sampled list. The list itself stays, for the pass trace.A draw that samples a target it also writes is still left as it is. A draw that samples a target an earlier draw wrote still takes the first loop, over this draw's own samples.
Why this is safe
The bit uses the same slot as the old loop: colour target i, or depth as bit 8. It is recorded after
draw_hazards, which is when the old loop would have seen the texture on the next draw. Starting a pass clears the mask inbegin_passtogether withpass.sampled.Testing
All passed on current main plus this change. With
vk_draw.cpprestored and the new test kept,test_pass_hazard.pyfails because the scan ofpass.sampledis still there.No renderer rebuild, and no Kokiri fps measurement, for this change.
Scope
Left out: the AMD
vkQueueSubmitstalls (#312), the movie upscale threshold (#336), and skipping a repeatedvkCmdBindIndexBuffer. The exposure flicker (#371) is already on main.Happy to rename the mask if another name fits the file better.
Thanks!