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

Closed
slatefield wants to merge 1 commit from upstream-pr/1825 into main
slatefield commented 2026-11-24 23:03:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by slatefield on 2026-11-24T23:03:01Z.


Closing on the strength of KainanP's measurement, with thanks. Their list_bench (#2586, perf/list-call-bench branch) puts this PR within noise at 1 thread (main 2506/2557 ns per draw vs 2520/2547 here) and unresolvable at 5 threads, which is what the change is worth: one QueryInterface, one AddRef and one push per stage that the list usually already holds. Their point that #3379 covers the same ground more generally is right: HostList::keep skipping objects a list already holds removes the same work for the marks table and everything else, and measured -3 to -6% on the stack where this one cannot be separated from zero.

The correctness work in here is worth keeping in the record: the State::cut hazard the triage caught (a cut list keeps the same State and records into a fresh HostList) was real, and clearing stride_table in host_state_lost plus a_lost_host_state_forgets_the_kept_stride_table covers it, as KainanP re-checked (230 passed, the two #1744 failures). If #3379 ever needs a hand or the cut path loses its reset, that test is a decent starting point.

Branch slatefield:gpu/keep-stride-table-once stays up for reference.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5481802236 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825). Originally posted by [slatefield](https://github.com/slatefield) on 2026-11-24T23:03:01Z. --- Closing on the strength of KainanP's measurement, with thanks. Their `list_bench` (#2586, `perf/list-call-bench` branch) puts this PR within noise at 1 thread (main 2506/2557 ns per draw vs 2520/2547 here) and unresolvable at 5 threads, which is what the change is worth: one `QueryInterface`, one `AddRef` and one push per stage that the list usually already holds. Their point that #3379 covers the same ground more generally is right: `HostList::keep` skipping objects a list already holds removes the same work for the marks table and everything else, and measured -3 to -6% on the stack where this one cannot be separated from zero. The correctness work in here is worth keeping in the record: the `State::cut` hazard the triage caught (a cut list keeps the same `State` and records into a fresh `HostList`) was real, and clearing `stride_table` in `host_state_lost` plus `a_lost_host_state_forgets_the_kept_stride_table` covers it, as KainanP re-checked (230 passed, the two #1744 failures). If #3379 ever needs a hand or the cut path loses its reset, that test is a decent starting point. Branch `slatefield:gpu/keep-stride-table-once` stays up for reference.
Melow-code commented 2026-11-24 23:05:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Melow-code on 2026-11-24T23:05:35Z.

Review: APPROVED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048823625 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#pullrequestreview-6048823625). Originally posted by [Melow-code](https://github.com/Melow-code) on 2026-11-24T23:05:35Z. **Review:** APPROVED --- 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.
catminou4 commented 2026-11-24 23:47:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:47:33Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6049280802 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#pullrequestreview-6049280802). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:47:33Z. **Review:** COMMENTED --- 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.
DesertGamer commented 2026-11-25 00:06:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-24T23:06:33Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147022880 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7147022880). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-24T23:06:33Z. --- ### 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.*
upipibi commented 2026-11-25 00:06:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T23:12:34Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147139293 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7147139293). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T23:12:34Z. --- 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.
mercuryVM commented 2026-11-25 05:41:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-25T05:41:14Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6052415769 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#pullrequestreview-6052415769). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-25T05:41:14Z. **Review:** APPROVED --- 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).
Marvisak commented 2026-11-25 07:03:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:31:46Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154883817 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7154883817). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:31:46Z. --- <!-- 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)_
slatefield commented 2026-11-25 18:02:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by slatefield on 2026-11-25T17:17:41Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169291439 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7169291439). Originally posted by [slatefield](https://github.com/slatefield) on 2026-11-25T17:17:41Z. --- 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 commented 2026-11-25 19:06:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by slatefield on 2026-11-25T18:29:07Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170971003 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7170971003). Originally posted by [slatefield](https://github.com/slatefield) on 2026-11-25T18:29:07Z. --- 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 commented 2026-11-26 12:05:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by slatefield on 2026-11-26T11:04:20Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7190225224 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7190225224). Originally posted by [slatefield](https://github.com/slatefield) on 2026-11-26T11:04:20Z. --- 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.
Desamodeth commented 2026-11-26 21:42:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-26T21:42:30Z.

Review: COMMENTED


Verified fdf1ef9 merged locally onto main@63bcca43. The cut path calls host_state_lost() and clears stride_table. Removing just that assignment made the PR's regression test fail (4096 vs 0). Restoring it passed. Strict Clippy passed for victory-gpu --all-targets with default features and diagnostics.

CPU-only A/B on a Ryzen 7 9800X3D using two Windows COM memory streams and the same pointer check, QueryInterface, mutex and kept-vector operations. For 8,192 consecutive binds of one table, retained references fell from 8,192 to 1, vector capacity from 64 KiB to 32 B, record time from 116.1 to 2.2 µs and reset time from 35.1 to 0.04 µs per segment. Alternating tables every bind retained 8,192 in both versions (115.3 vs 116.1 µs to record). With two overlapping segments holding the same table, retiring the first preserved the second's reference.

Release build, medians of 12 batches of 48 segments per variant, alternating A/B order. These timings cover CPU reference management only. AI-assisted with Codex Astra 6.2 High.

<!-- greyfinch-sync:Marvisak/VIctory:review:6080782805 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#pullrequestreview-6080782805). Originally posted by [Desamodeth](https://github.com/Desamodeth) on 2026-11-26T21:42:30Z. **Review:** COMMENTED --- Verified `fdf1ef9` merged locally onto `main@63bcca43`. The cut path calls `host_state_lost()` and clears `stride_table`. Removing just that assignment made the PR's regression test fail (4096 vs 0). Restoring it passed. Strict Clippy passed for `victory-gpu --all-targets` with default features and diagnostics. CPU-only A/B on a Ryzen 7 9800X3D using two Windows COM memory streams and the same pointer check, QueryInterface, mutex and kept-vector operations. For 8,192 consecutive binds of one table, retained references fell from 8,192 to 1, vector capacity from 64 KiB to 32 B, record time from 116.1 to 2.2 µs and reset time from 35.1 to 0.04 µs per segment. Alternating tables every bind retained 8,192 in both versions (115.3 vs 116.1 µs to record). With two overlapping segments holding the same table, retiring the first preserved the second's reference. Release build, medians of 12 batches of 48 segments per variant, alternating A/B order. These timings cover CPU reference management only. AI-assisted with Codex Astra 6.2 High.
KainanP commented 2026-11-27 12:02:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-27T12:02:15Z.


List-call numbers for this PR (head fdf1ef9), ns per draw:

main main + #1825 stack stack + #1825
1 thread 2506 / 2557 2520 / 2547 1110 / 1114 1132 / 1124
5 threads 8959 / 9047 8749 / 8978 1488 / 1460 1482 / 1492

Method. pipeline::list_bench from #2586 (fork branch perf/list-call-bench) with VICTORY_LIST_BENCH_SCALING=1: the draw sequence (root CBV, 4 root constants, index buffer, indexed draw that reads 6 textures through a table and 3 root CBVs). Each thread records its own list, best of 5 × 20,000 draws. Each row is the median of 7 interleaved runs, and there were two separate batches of 7 in opposite config order (shown as batch 1 / batch 2). Release --lib test build, RTX 4060 Laptop, Windows 11. Nothing else heavy was running (an editor and a browser, CPU 7–41 % between rounds, no game). The 5-thread row on main is noisy (single runs from 7.4 to 12.8 µs), so deltas under ~5 % there are not resolvable.

Bases. main = 63bcca4 + bench commits. Stack = main + #1978 + #2821 + #3258 + #3274 + #3275 + rebased #1356 + #3405 (the stack in #2586).

Reading it. Within noise in both batches, on both bases. A keep the list already has costs a QueryInterface, an AddRef and a push, which is too small to separate from this bench's noise at one per stage. #3379 makes HostList::keep skip any object the list already holds, which covers this table and the marks table. With #3379 alone on the stack, both rows go down (−3 to −6 %), so the two PRs overlap and #3379 is the more general one.

Correctness. cargo test -p victory-gpu --lib (release) on the RTX: 230 passed, 2 failed. The failures are the #1744 heap-cap pair, also failing on main here. a_lost_host_state_forgets_the_kept_stride_table passes. On the stack: 238 passed, 3 failed, the same 3 as the stack without this PR (the stack itself fails 3: the #1744 pair, plus a_list_lends_a_read_copy_only_while_it_is_the_textures in the stack's port of #3405. That test passes on #3405's own head, 232/2 here). Clearing stride_table in host_state_lost covers cut and external::record, and a title Reset goes through State::reset.

Not measured. Any game frame.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7217763419 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1825#issuecomment-7217763419). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-27T12:02:15Z. --- List-call numbers for this PR (head `fdf1ef9`), ns per draw: | | main | main + #1825 | stack | stack + #1825 | |---|---|---|---|---| | 1 thread | 2506 / 2557 | 2520 / 2547 | 1110 / 1114 | 1132 / 1124 | | 5 threads | 8959 / 9047 | 8749 / 8978 | 1488 / 1460 | 1482 / 1492 | **Method.** `pipeline::list_bench` from #2586 (fork branch `perf/list-call-bench`) with `VICTORY_LIST_BENCH_SCALING=1`: the draw sequence (root CBV, 4 root constants, index buffer, indexed draw that reads 6 textures through a table and 3 root CBVs). Each thread records its own list, best of 5 × 20,000 draws. Each row is the median of 7 interleaved runs, and there were two separate batches of 7 in opposite config order (shown as batch 1 / batch 2). Release `--lib` test build, RTX 4060 Laptop, Windows 11. Nothing else heavy was running (an editor and a browser, CPU 7–41 % between rounds, no game). The 5-thread row on `main` is noisy (single runs from 7.4 to 12.8 µs), so deltas under ~5 % there are not resolvable. **Bases.** `main` = `63bcca4` + bench commits. Stack = `main` + #1978 + #2821 + #3258 + #3274 + #3275 + rebased #1356 + #3405 (the stack in #2586). **Reading it.** Within noise in both batches, on both bases. A `keep` the list already has costs a `QueryInterface`, an `AddRef` and a push, which is too small to separate from this bench's noise at one per stage. #3379 makes `HostList::keep` skip any object the list already holds, which covers this table and the marks table. With #3379 alone on the stack, both rows go down (−3 to −6 %), so the two PRs overlap and #3379 is the more general one. **Correctness.** `cargo test -p victory-gpu --lib` (release) on the RTX: 230 passed, 2 failed. The failures are the #1744 heap-cap pair, also failing on `main` here. `a_lost_host_state_forgets_the_kept_stride_table` passes. On the stack: 238 passed, 3 failed, the same 3 as the stack without this PR (the stack itself fails 3: the #1744 pair, plus `a_list_lends_a_read_copy_only_while_it_is_the_textures` in the stack's port of #3405. That test passes on #3405's own head, 232/2 here). Clearing `stride_table` in `host_state_lost` covers `cut` and `external::record`, and a title `Reset` goes through `State::reset`. **Not measured.** Any game frame. _AI use: Claude Code (Claude Opus 5.5)._

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1823
No description provided.