Hoisted clamps: draws whose shaders store don't end the run, and each cut piece gets a fresh budget (no measured effect, see correction) #209

Open
opened 2026-11-26 03:38:00 +00:00 by github-bot · 2 comments
Owner

@⁠Marukooh on GitHub · 2026-11-25 23:11 UTC · original

Hi! I ported the hoisted clamps of ccab973 to fxceless/victory-fork and measured them on an RTX 5070 Ti (Proton, vkd3d-proton, prologue). Two of its rules did not hold there, and the current main still seems to have both, so here is what I found.

1. Draws whose shaders store do not end the run

count_write is called for dispatches and copies. A draw whose shaders store to buffers does not end the run, so the clamps of the draws after it are recorded before it ran. When such a draw writes arguments, counts or data that later work reads, that work sees what was there before the run.

On our side this showed up as the indirect compute 982f3cccd5c04294 going from about 12 ms to about 166 ms a call. The frame went from 208 to 342 ms, GPU 102 to 216 ms. Ending the run after any draw whose pipeline has a stage with translated().stores, the rule the indirect windows already use, fixed it. With that rule the hoisted clamps gave GPU 95.5 -> 57.8 ms and frame 187.6 -> 160.0 ms against inline clamps, on the same build and scene.

2. Each piece gets a fresh budget

bound_before charges clamps.budget(), the budget of the clamp list. Each list cut for hoisting has its own budget of 2^27, which is zeroed per list. A title list that used to share one budget now has one per piece. Work that the shared budget would have emptied can then run, for example garbage records after a run, or a dispatch after the run's draws. In my port all pieces of a title list charge the first piece's budget (the card copy handed on COMMON -> UAV -> COMMON). That alone did not change the timing above, but it keeps the cap where it was.

Not checked

I have not run your build. The 166 ms case may depend on the scene, the driver or the wave size. Radeon/Windows could behave differently.

The adapted change, with both rules and two WARP tests: https://github.com/fxceless/victory-fork/pull/1184

**@⁠Marukooh** on GitHub · 2026-11-25 23:11 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/209) Hi! I ported the hoisted clamps of ccab973 to fxceless/victory-fork and measured them on an RTX 5070 Ti (Proton, vkd3d-proton, prologue). Two of its rules did not hold there, and the current `main` still seems to have both, so here is what I found. ## 1. Draws whose shaders store do not end the run `count_write` is called for dispatches and copies. A draw whose shaders store to buffers does not end the run, so the clamps of the draws after it are recorded before it ran. When such a draw writes arguments, counts or data that later work reads, that work sees what was there before the run. On our side this showed up as the indirect compute `982f3cccd5c04294` going from about 12 ms to about **166 ms a call**. The frame went from 208 to 342 ms, GPU 102 to 216 ms. Ending the run after any draw whose pipeline has a stage with `translated().stores`, the rule the indirect windows already use, fixed it. With that rule the hoisted clamps gave GPU 95.5 -> 57.8 ms and frame 187.6 -> 160.0 ms against inline clamps, on the same build and scene. ## 2. Each piece gets a fresh budget `bound_before` charges `clamps.budget()`, the budget of the clamp list. Each list cut for hoisting has its own budget of 2^27, which is zeroed per list. A title list that used to share one budget now has one per piece. Work that the shared budget would have emptied can then run, for example garbage records after a run, or a dispatch after the run's draws. In my port all pieces of a title list charge the first piece's budget (the card copy handed on `COMMON -> UAV -> COMMON`). That alone did not change the timing above, but it keeps the cap where it was. ## Not checked I have not run your build. The 166 ms case may depend on the scene, the driver or the wave size. Radeon/Windows could behave differently. The adapted change, with both rules and two WARP tests: https://github.com/fxceless/victory-fork/pull/1184
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:38:00 +00:00
Author
Owner

@⁠Marukooh on GitHub · 2026-11-25 23:44 UTC · original

Correction to point 1: I was wrong about the cause.

The jump of 982f3cccd5c04294 from about 12 ms to about 166 ms a call was not the hoisted clamps. Later runs showed the same 160-169 ms with hoisting off. Over 13 runs it lined up exactly with the card budget the system reports instead. When the budget dropped from ~12.4 to ~10.5 GB near frame 725, 982f took ~12 ms. When it stayed at ~12.4 GB, the texture queue overfilled the card, memory went out to the PC's, and 982f took 160-170 ms. So my "stores rule fixed it" was a coincidence of which budget state each run landed in. Details are in fxceless/victory-fork#1184.

With the budget held at 10.5 GB on both sides, hoisted clamps still help on this RTX 5070 Ti (frame 179.8 -> 151.8 ms, title lists 127 -> 107 ms), and 982f stays at ~12 ms either way.

What is left of this issue:

  • Point 1: a draw whose shaders store does not end a run. That is still possible in principle, but I have no measurement showing it matters.
  • Point 2: each cut piece gets a fresh budget. That is a semantic change, and its effect was not measured either.

Sorry for the noise. Feel free to close this if neither concerns you.

**@⁠Marukooh** on GitHub · 2026-11-25 23:44 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/209#issuecomment-7177973224) Correction to point 1: I was wrong about the cause. The jump of `982f3cccd5c04294` from about 12 ms to about 166 ms a call was not the hoisted clamps. Later runs showed the same 160-169 ms with hoisting **off**. Over 13 runs it lined up exactly with the card budget the system reports instead. When the budget dropped from ~12.4 to ~10.5 GB near frame 725, `982f` took ~12 ms. When it stayed at ~12.4 GB, the texture queue overfilled the card, memory went out to the PC's, and `982f` took 160-170 ms. So my "stores rule fixed it" was a coincidence of which budget state each run landed in. Details are in fxceless/victory-fork#1184. With the budget held at 10.5 GB on both sides, hoisted clamps still help on this RTX 5070 Ti (frame 179.8 -> 151.8 ms, title lists 127 -> 107 ms), and `982f` stays at ~12 ms either way. What is left of this issue: - **Point 1:** a draw whose shaders store does not end a run. That is still possible in principle, but I have no measurement showing it matters. - **Point 2:** each cut piece gets a fresh budget. That is a semantic change, and its effect was not measured either. Sorry for the noise. Feel free to close this if neither concerns you.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 04:58 UTC · original

Both rules are in Belobug now as #227: draws whose shaders may write memory end the run, and the pieces of a cut list charge the first piece's budget. Each rule has a test on the host device that fails without it. Your correction is noted there, so it makes no timing claim. Thanks for the clear write-up and fxceless#1184, which it is adapted from.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-26 04:58 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/209#issuecomment-7183073033) Both rules are in Belobug now as #227: draws whose shaders may write memory end the run, and the pieces of a cut list charge the first piece's budget. Each rule has a test on the host device that fails without it. Your correction is noted there, so it makes no timing claim. Thanks for the clear write-up and fxceless#1184, which it is adapted from. AI-assisted (Claude Code); no game data.
This discussion has been locked. Commenting is limited to contributors.
No description provided.