Restore bindless plan invalidation for writes #220

Open
github-bot wants to merge 1 commit from github-bot/gh-220 into main AGit
Owner

@⁠KernelSmoker on GitHub · 2026-11-26 02:22 UTC · original
KernelSmoker:codex/fix-issue143-bindless-writes → main · +3 −7 · 1 files · 1 commits · open

Summary

Restore write-range changes as a reason to rebuild the bindless plan. This covers both a slot changing its written range and a written slot disappearing, matching the pre-705a2d0 invalidation behavior implicated by the bisect in #143.

Validation

  • cargo check --locked --offline --target x86_64-pc-windows-gnu -p victory-gpu --lib — passed (Windows GNU library compile check; compile evidence only).
  • git diff --check — passed.
  • No runtime or GPU benchmark was run.
**@⁠KernelSmoker** on GitHub · 2026-11-26 02:22 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/220) `KernelSmoker:codex/fix-issue143-bindless-writes` → `main` · +3 −7 · 1 files · 1 commits · open ## Summary Restore write-range changes as a reason to rebuild the bindless plan. This covers both a slot changing its written range and a written slot disappearing, matching the pre-`705a2d0` invalidation behavior implicated by the bisect in #143. ## Validation - `cargo check --locked --offline --target x86_64-pc-windows-gnu -p victory-gpu --lib` — passed (Windows GNU library compile check; compile evidence only). - `git diff --check` — passed. - No runtime or GPU benchmark was run.
Assisted-by: Codex (GPT-6 Luna)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:38:10 +00:00
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 19:53 UTC · original

Tested on Windows 11 with an RX 7900 XT (RDNA3, driver 32.0.32029.2010), native build. Head 078c6b1, base 4f62c2a. Other jobs were running on the machine, so timings are noisy. The game is not installed here, so this says nothing about whether #143 is fixed.

What the change is:

  • It is an exact revert of the host.rs hunk of 705a2d0. It leaves out the other two files of 705a2d0:
    • xgamesave.rs: an older save version that cannot be removed is now logged and skipped instead of failing current().
    • ambient.rs: off unless VICTORY_AMBIENT_SKY or the live file is set.
  • In a release build nothing reads plan.writes. The only reader is Batch::prepare_bindless (src/host.rs:2953), behind if writes && cfg!(test). So in game this PR only changes when the plan is rebuilt.
  • A UAV slot's write range is its read range (use_slot, up to WRITE_CAP). So base already rebuilds when a slot moves outside the plan's merged reads. The gated cases are:
    • a move inside the merged reads (same host copy)
    • a written slot that goes away
  • In those cases base keeps the old ranges, reads and held resources in the plan until a whole build. The 8-frame loose rebuild only runs on a later call that has some other slot change to process.
  • In test builds base and PR behave the same. Both gates are true under cfg!(test), and remake has || cfg!(test) (descriptor/host.rs:1989). So no ordinary test can tell them apart.

Lib tests (cargo test -p victory-gpu --lib, debug, 20 interleaved runs each):

  • No difference I can attribute to the PR. Base: 18 ok, 1 crash (exit 139), 1 bindless_plan_is_remade_only_when_slots_change failure (first.reads.len() was 0). PR: 15 ok, 5 single watch::tests failures. As said above, the two test binaries behave the same.
  • descriptor:: alone: 16/16 in 10 runs on each side.

Local test (not pushed): I made the cfg!(test) sites in bindless_plan() switchable to release behaviour, with the same patch on both sides.

  • A written slot moves to a range inside the merged reads. Base keeps the old write range for all 20 frames. The PR has the new one on the first frame.
  • The only written slot's resource is released. Base keeps its write range for all 20 frames. The PR drops it on the first frame.
  • In both tests no other slot changed, so base did no whole build in those 20 frames.
  • Both fail on base and pass on the PR, in 3/3 debug and 6/6 release runs.

Cost, same patch, release, 6 interleaved runs. Setup: 60,000 CBV slots plus 64 UAV slots inside the read memory. 4 UAV slots switch range every frame, for 64 frames.

  • Base: 8 whole-plan builds (the 8-frame loose rebuild), 65-79 ms in total. 32 of the 64 plans lack slot 0's current write range.
  • PR: 64 builds (one per frame), 517-557 ms in total, 8.0-8.8 ms median per call. All 64 plans are current.

This is a synthetic setup, not a game measurement. For comparison, the 705a2d0 message reports 13-22 ms vs 2.4-5.4 ms a frame in game.

Overlap with #199 (head 3469dd5):

  • It conflicts textually in descriptor/host.rs (#199 re-indents the same block).
  • #199's default incremental path decides rebuilds in plan_dirty(). That function has its own (cfg!(test) && self.writes_dirty) (host.rs:854). With this PR's lines applied on #199, only the VICTORY_PLAN_REUSE=0 path changes.
  • The same local test on #199, and on #199 plus these lines (one debug run each), gives the same result:
    • Both cases above pass. I did not trace why.
    • In the 60k case there are 0 plan builds, and 32 of 64 plans lack the new write range.
  • With the plan_dirty() gate removed as well: 64 plan builds, all plans current, 136 us median per call in debug. For comparison, this PR alone is about 67 ms per call in debug.

On #143: rx9070xt (81ebb7b) shares no history with main. Its crates/ has no BindlessPlan or bindless_plan code, and its history never had any. So this block was not rewritten there; it never existed on that branch.

Not tested: in game, RDNA4, the D3D12 debug layer, WARP, clippy. I can share the local test patch.

**@⁠adrianmjim** on GitHub · 2026-11-26 19:53 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/220#issuecomment-7202071743) Tested on Windows 11 with an RX 7900 XT (RDNA3, driver 32.0.32029.2010), native build. Head 078c6b1, base 4f62c2a. Other jobs were running on the machine, so timings are noisy. The game is not installed here, so this says nothing about whether #143 is fixed. What the change is: - It is an exact revert of the host.rs hunk of 705a2d0. It leaves out the other two files of 705a2d0: - xgamesave.rs: an older save version that cannot be removed is now logged and skipped instead of failing `current()`. - ambient.rs: off unless `VICTORY_AMBIENT_SKY` or the live file is set. - In a release build nothing reads `plan.writes`. The only reader is `Batch::prepare_bindless` (src/host.rs:2953), behind `if writes && cfg!(test)`. So in game this PR only changes when the plan is rebuilt. - A UAV slot's write range is its read range (`use_slot`, up to `WRITE_CAP`). So base already rebuilds when a slot moves outside the plan's merged reads. The gated cases are: - a move inside the merged reads (same host copy) - a written slot that goes away - In those cases base keeps the old ranges, reads and held resources in the plan until a whole build. The 8-frame loose rebuild only runs on a later call that has some other slot change to process. - In test builds base and PR behave the same. Both gates are true under `cfg!(test)`, and `remake` has `|| cfg!(test)` (descriptor/host.rs:1989). So no ordinary test can tell them apart. Lib tests (`cargo test -p victory-gpu --lib`, debug, 20 interleaved runs each): - No difference I can attribute to the PR. Base: 18 ok, 1 crash (exit 139), 1 `bindless_plan_is_remade_only_when_slots_change` failure (`first.reads.len()` was 0). PR: 15 ok, 5 single `watch::tests` failures. As said above, the two test binaries behave the same. - `descriptor::` alone: 16/16 in 10 runs on each side. Local test (not pushed): I made the `cfg!(test)` sites in `bindless_plan()` switchable to release behaviour, with the same patch on both sides. - A written slot moves to a range inside the merged reads. Base keeps the old write range for all 20 frames. The PR has the new one on the first frame. - The only written slot's resource is released. Base keeps its write range for all 20 frames. The PR drops it on the first frame. - In both tests no other slot changed, so base did no whole build in those 20 frames. - Both fail on base and pass on the PR, in 3/3 debug and 6/6 release runs. Cost, same patch, release, 6 interleaved runs. Setup: 60,000 CBV slots plus 64 UAV slots inside the read memory. 4 UAV slots switch range every frame, for 64 frames. - Base: 8 whole-plan builds (the 8-frame loose rebuild), 65-79 ms in total. 32 of the 64 plans lack slot 0's current write range. - PR: 64 builds (one per frame), 517-557 ms in total, 8.0-8.8 ms median per call. All 64 plans are current. This is a synthetic setup, not a game measurement. For comparison, the 705a2d0 message reports 13-22 ms vs 2.4-5.4 ms a frame in game. Overlap with #199 (head 3469dd5): - It conflicts textually in descriptor/host.rs (#199 re-indents the same block). - #199's default incremental path decides rebuilds in `plan_dirty()`. That function has its own `(cfg!(test) && self.writes_dirty)` (host.rs:854). With this PR's lines applied on #199, only the `VICTORY_PLAN_REUSE=0` path changes. - The same local test on #199, and on #199 plus these lines (one debug run each), gives the same result: - Both cases above pass. I did not trace why. - In the 60k case there are 0 plan builds, and 32 of 64 plans lack the new write range. - With the `plan_dirty()` gate removed as well: 64 plan builds, all plans current, 136 us median per call in debug. For comparison, this PR alone is about 67 ms per call in debug. On #143: `rx9070xt` (81ebb7b) shares no history with main. Its crates/ has no `BindlessPlan` or `bindless_plan` code, and its history never had any. So this block was not rewritten there; it never existed on that branch. Not tested: in game, RDNA4, the D3D12 debug layer, WARP, clippy. I can share the local test patch.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/220/head:github-bot/gh-220'
git switch 'github-bot/gh-220'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-220'
git switch 'github-bot/gh-220'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-220'
git switch 'github-bot/gh-220'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-220'
git switch 'main'
git merge --squash 'github-bot/gh-220'
git switch 'main'
git merge --ff-only 'github-bot/gh-220'
git switch 'main'
git merge 'github-bot/gh-220'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.