Skip to content

Skip the pass-hazard scan of every sampled texture. - #416

Merged
shayderrr merged 2 commits into
NotRexed:mainfrom
SkippySteve:fix/replay-lookups
Nov 8, 2026
Merged

shayderrr merged 2 commits into
NotRexed:mainfrom
SkippySteve:fix/replay-lookups

Conversation

@SkippySteve

@SkippySteve SkippySteve commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem

draw_hazards walks 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 in begin_pass together with pass.sampled.

Testing

python -I -B tests/test_pass_hazard.py
python -I -B tests/test_ub_memo.py
python -I -B tests/test_ub_gap.py
python -I -B tests/test_bind_memo.py
python -I -B tests/test_vertex_bind.py
python -I -B tests/test_same_draw.py

All passed on current main plus this change. With vk_draw.cpp restored and the new test kept, test_pass_hazard.py fails because the scan of pass.sampled is still there.

No renderer rebuild, and no Kokiri fps measurement, for this change.

Scope

Left out: the AMD vkQueueSubmit stalls (#312), the movie upscale threshold (#336), and skipping a repeated vkCmdBindIndexBuffer. The exposure flicker (#371) is already on main.

Happy to rename the mask if another name fits the file better.

SkippySteve added 2 commits November 7, 2026 19:20
A read-only bind is remembered until its pool changes. Uniform words that sit outside an inline update keep the gap around them, and the word memo stays. A pass keeps a mask of the targets earlier draws sampled.
The read-only bind memo and the uniform gap are on main now. This keeps the pass-hazard mask.
@SkippySteve SkippySteve changed the title Skip repeated buffer, uniform, and pass-hazard lookups. Skip the pass-hazard scan of every sampled texture. Nov 8, 2026
@shayderrr

Copy link
Copy Markdown
Collaborator

Thanks!

@shayderrr
shayderrr merged commit e40306e into NotRexed:main Nov 8, 2026
4 checks passed
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.

2 participants