GPU: keep the view-stride table once per list, not per draw stage #1825

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

@⁠slatefield on GitHub · 2026-11-24 23:03 UTC · original
slatefield:gpu/keep-stride-table-once → main · +18 −1 · 1 files · 1 commits · open

the view-stride table was kept on every stage of every draw: COM QueryInterface, deferred mutex, Vec push, and a Release per entry when the list resets. at the world's draw counts that's thousands of them per list for one heap-owned table that the list only has to hold once.

pipeline + root signature right above it already do the compare-then-keep thing, so the table does it now too: keep it when the pointer changes (State is reset with the host list, so the cache empties when kept does).

typechecked for windows target, plain and diagnostics.

**@⁠slatefield** on GitHub · 2026-11-24 23:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825) `slatefield:gpu/keep-stride-table-once` → `main` · +18 −1 · 1 files · 1 commits · open the view-stride table was kept on every stage of every draw: COM QueryInterface, deferred mutex, Vec push, and a Release per entry when the list resets. at the world's draw counts that's thousands of them per list for one heap-owned table that the list only has to hold once. pipeline + root signature right above it already do the compare-then-keep thing, so the table does it now too: keep it when the pointer changes (State is reset with the host list, so the cache empties when kept does). typechecked for windows target, plain and diagnostics.
Every draw of a pipeline whose shader reads the view-stride table kept the
table again: a QueryInterface on the host resource, the deferred lock, a
push into the list's kept objects, and a Release for each of them when the
list resets. The pipeline and root signature beside it are already kept
only when the binding changed.

A list cut into a fresh host list after a wait forgot its kept objects but
not the remembered table, so the next segment skipped the keep and could
name a table nothing holds. host_state_lost() forgets it too, with a test.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:45:48 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 23:06 UTC · original

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

**@⁠DesertGamer** on GitHub · 2026-11-24 23:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7147022880) ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 23:12 UTC · original

NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, 3a3f9a2 (on main 70564ae). cargo test -p victory-gpu --locked: 76 passed, 2 failed, 1 ignored. The 2 are the capped-heap failures main has on NVIDIA (#1744: dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views), so there are no new failures.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 23:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7147139293) NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `3a3f9a2` (on `main` `70564ae`). `cargo test -p victory-gpu --locked`: 76 passed, 2 failed, 1 ignored. The 2 are the capped-heap failures `main` has on NVIDIA (#1744: `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`), so there are no new failures. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:31 UTC · original · edited 2026-11-25 20:20 UTC

Automated triage for the maintainers.

Needs work. This makes State::bind (crates/victory-gpu/src/draw.rs) call list.keep(table) for the view-stride table only when the table pointer differs from State::stride_table.

Reply to the author: putting the reset in host_state_lost is the right place, but the pushed head c65f14b does not contain it. Its only changes are the new stride_table field and the compare-then-keep in bind. host_state_lost still resets only host_pipeline, host_roots and host_heaps, and there is no a_lost_host_state_forgets_the_kept_stride_table test on the branch. So the problem from the last review is still there. After State::cut starts a new HostList, the next draw sees the same pointer and skips keep, and the table can be released while that segment is in flight. Please push the commit that has the host_state_lost change and the test. With that, this can be reviewed as a merge candidate.

CI: no check runs on the head commit.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7154883817) · edited 2026-11-25 20:20 UTC <!-- victory-triage v1 head=c65f14b93a5a9a48c2869b2b63bc68d647ed432a verdict=needs-work at=2026-11-25T20:18:54Z --> Automated triage for the maintainers. **Needs work.** This makes `State::bind` (`crates/victory-gpu/src/draw.rs`) call `list.keep(table)` for the view-stride table only when the table pointer differs from `State::stride_table`. Reply to the author: putting the reset in `host_state_lost` is the right place, but the pushed head `c65f14b` does not contain it. Its only changes are the new `stride_table` field and the compare-then-keep in `bind`. `host_state_lost` still resets only `host_pipeline`, `host_roots` and `host_heaps`, and there is no `a_lost_host_state_forgets_the_kept_stride_table` test on the branch. So the problem from the last review is still there. After `State::cut` starts a new `HostList`, the next draw sees the same pointer and skips `keep`, and the table can be released while that segment is in flight. Please push the commit that has the `host_state_lost` change and the test. With that, this can be reviewed as a merge candidate. CI: no check runs on the head commit. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠slatefield on GitHub · 2026-11-25 17:17 UTC · original

Rebased onto current main (13f91ca) and force-pushed, since main moved under it in draw.rs: the conflict was only that State grew a fixed: Fixed field for the list-cut work, so both fields are kept (stride_table from here, then fixed). No other change.

Windows-target clippy --all-targets --all-features and without: clean. The rebased head merges cleanly, so the triage can re-run. The earlier merge-candidate verdict still describes the change itself.

**@⁠slatefield** on GitHub · 2026-11-25 17:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7169291439) Rebased onto current `main` (`13f91ca`) and force-pushed, since `main` moved under it in `draw.rs`: the conflict was only that `State` grew a `fixed: Fixed` field for the list-cut work, so both fields are kept (`stride_table` from here, then `fixed`). No other change. Windows-target clippy `--all-targets --all-features` and without: clean. The rebased head merges cleanly, so the triage can re-run. The earlier merge-candidate verdict still describes the change itself.
Author
Owner

@⁠slatefield on GitHub · 2026-11-25 18:29 UTC · original

Right on the cut path, and it is fixed in c65f14b. host_state_lost() now clears stride_table as well, so both the cut path and the other recorders that call it forget it, and the next draw keeps the table again in the fresh list. I put it there rather than in cut because that is the one both callers go through, and added a unit test for it (a_lost_host_state_forgets_the_kept_stride_table, no device needed).

Windows-target clippy --all-targets --all-features clean. The branch is rebased on 13f91ca, one commit, force-pushed.

**@⁠slatefield** on GitHub · 2026-11-25 18:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7170971003) Right on the cut path, and it is fixed in `c65f14b`. `host_state_lost()` now clears `stride_table` as well, so both the `cut` path and the other recorders that call it forget it, and the next draw keeps the table again in the fresh list. I put it there rather than in `cut` because that is the one both callers go through, and added a unit test for it (`a_lost_host_state_forgets_the_kept_stride_table`, no device needed). Windows-target clippy `--all-targets --all-features` clean. The branch is rebased on `13f91ca`, one commit, force-pushed.
github-bot force-pushed github-bot/gh-1825 from c65f14b93a to fdf1ef945b 2026-11-26 11:11:27 +00:00 Compare
Author
Owner

@⁠Melow-code on GitHub · 2026-11-24 23:05 UTC · original · approved these changes

The dedup with a pointer check matches how the pipeline and root signature are already cached in State. One QueryInterface + lock + Vec push per draw is real overhead for titles that set views often. +9/−1, clean.

**@⁠Melow-code** on GitHub · 2026-11-24 23:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825#pullrequestreview-6048823625) · **approved these changes** The dedup with a pointer check matches how the pipeline and root signature are already cached in State. One QueryInterface + lock + Vec push per draw is real overhead for titles that set views often. +9/−1, clean.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 23:47 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

View-stride table kept once per list instead of per draw: allocation/cache hygiene in host.rs path. Windows-only.

**@⁠catminou4** on GitHub · 2026-11-24 23:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825#pullrequestreview-6049280802) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. View-stride table kept once per list instead of per draw: allocation/cache hygiene in host.rs path. Windows-only.
Author
Owner

@⁠mercuryVM on GitHub · 2026-11-25 05:41 UTC · original · approved these changes

Tested 3a3f9a2 on Windows 11, RTX 5070, MSVC: builds, clippy -D warnings clean with and without --all-features, cargo test --workspace --no-fail-fast 730 passed on our fork main; the 9 failures are the ones that fail on that main without this PR (host validator and environment). I didn't measure the frame-time effect.

  • The cache is safe:
    • A title list reset (Reset, and ResetX through it) runs host.reset(), which drops the kept objects, together with state.reset(), which restores State::default(). So stride_table empties exactly when the list's holds do.
    • The other list.reset() calls are internal host lists that carry no title State.
  • A kept table can't be freed while kept, so an equal pointer always means the same live table, and skipping keep can't leave a bound table unheld.

Merged into our fork's main.

AI-assisted (Claude Code).

**@⁠mercuryVM** on GitHub · 2026-11-25 05:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825#pullrequestreview-6052415769) · **approved these changes** Tested 3a3f9a2 on Windows 11, RTX 5070, MSVC: builds, clippy `-D warnings` clean with and without `--all-features`, `cargo test --workspace --no-fail-fast` 730 passed on our fork main; the 9 failures are the ones that fail on that main without this PR (host validator and environment). I didn't measure the frame-time effect. - The cache is safe: - A title list reset (`Reset`, and `ResetX` through it) runs `host.reset()`, which drops the kept objects, together with `state.reset()`, which restores `State::default()`. So `stride_table` empties exactly when the list's holds do. - The other `list.reset()` calls are internal host lists that carry no title `State`. - A kept table can't be freed while kept, so an equal pointer always means the same live table, and skipping `keep` can't leave a bound table unheld. Merged into our fork's main. AI-assisted (Claude Code).
Author
Owner

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

You are right and the fault was mine: I amended the commit message without staging the file, so c65f14b only carried the original change. The real one is now pushed as fdf1ef9 (same message, force-pushed): host_state_lost() clears stride_table, and a_lost_host_state_forgets_the_kept_stride_table is in the test module. git show on it now has 18 insertions instead of 9, which is how you can tell it is there.

Windows-target clippy --all-targets --all-features clean on that tree. Sorry for the noise.

**@⁠slatefield** on GitHub · 2026-11-26 11:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7190225224) You are right and the fault was mine: I amended the commit message without staging the file, so `c65f14b` only carried the original change. The real one is now pushed as `fdf1ef9` (same message, force-pushed): `host_state_lost()` clears `stride_table`, and `a_lost_host_state_forgets_the_kept_stride_table` is in the test module. `git show` on it now has 18 insertions instead of 9, which is how you can tell it is there. Windows-target clippy `--all-targets --all-features` clean on that tree. Sorry for the noise.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1825/head:github-bot/gh-1825'
git switch 'github-bot/gh-1825'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1825'
git switch 'github-bot/gh-1825'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1825'
git switch 'github-bot/gh-1825'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1825'
git switch 'main'
git merge --squash 'github-bot/gh-1825'
git switch 'main'
git merge --ff-only 'github-bot/gh-1825'
git switch 'main'
git merge 'github-bot/gh-1825'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1825
No description provided.