GPU: initialise new page tables to their null view pair #3117

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/3119 into main
fuzeofficlal commented 2026-11-26 08:50:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T08:50:10Z.


Summary

Split out from #3106 per triage feedback.

Shared::new allocates the title-memory page table buffer and reserves a null descriptor pair (heap.pair()), but previously left the table buffer zeroed until the first Shared::rewrite. If a command list executes with that table before rewrite has ever run (for example when its view heap is released before its first prepare), every level-1 lookup resolves to block 0 and every block-0 entry has e.x == 0, causing translated shaders to index descriptor slot 0 instead of self.null.

Changes

  • crates/victory-gpu/src/memory.rs:
    • In Shared::new, point every level-1 entry at block 0 and fill all BLOCK entries of block 0 with [null, 0], matching write_table for an empty table.
    • Add memory::tests::new_table_routes_all_lookups_to_null_before_first_rewrite, verifying both the initial table contents and a SOURCE compute dispatch against an un-rewritten table with a non-zero buffer bound at slot 0.

Testing

  • Verified the new test fails on main (63bcca43) before the fix.
  • cargo test -p victory-gpu --locked --lib memory::tests -- --skip lists_share_a_table_and_copies_keep_their_views (RTX 5090): 8 passed, 0 failed.
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --locked --features diagnostics (WARP): 247 passed, 0 failed, 1 ignored.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and --all-features: clean.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: passed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6622947639 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3119). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T08:50:10Z. --- ## Summary Split out from #3106 per triage feedback. `Shared::new` allocates the title-memory page table buffer and reserves a `null` descriptor pair (`heap.pair()`), but previously left the table buffer zeroed until the first `Shared::rewrite`. If a command list executes with that table before `rewrite` has ever run (for example when its view heap is released before its first `prepare`), every level-1 lookup resolves to block 0 and every block-0 entry has `e.x == 0`, causing translated shaders to index descriptor slot 0 instead of `self.null`. ## Changes - `crates/victory-gpu/src/memory.rs`: - In `Shared::new`, point every level-1 entry at block 0 and fill all `BLOCK` entries of block 0 with `[null, 0]`, matching `write_table` for an empty table. - Add `memory::tests::new_table_routes_all_lookups_to_null_before_first_rewrite`, verifying both the initial table contents and a `SOURCE` compute dispatch against an un-rewritten table with a non-zero buffer bound at slot 0. ## Testing - Verified the new test fails on `main` (`63bcca43`) before the fix. - `cargo test -p victory-gpu --locked --lib memory::tests -- --skip lists_share_a_table_and_copies_keep_their_views` (RTX 5090): 8 passed, 0 failed. - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --locked --features diagnostics` (WARP): 247 passed, 0 failed, 1 ignored. - `cargo clippy --workspace --all-targets --locked -- -D warnings` and `--all-features`: clean. - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: passed.
Dukestar69 commented 2026-11-26 10:04:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T09:09:25Z.

Review: APPROVED


Verified on RTX 5090 & WARP against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib memory:: -- --test-threads=1 --skip lists_share_a_table_and_copies_keep_their_views: 8/8 passed on RTX 5090 and WARP (including new_table_routes_all_lookups_to_null_before_first_rewrite).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly initializes new page tables to the null view pair before their first rewrite.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6071245641 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3119#pullrequestreview-6071245641). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T09:09:25Z. **Review:** APPROVED --- Verified on RTX 5090 & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib memory:: -- --test-threads=1 --skip lists_share_a_table_and_copies_keep_their_views`: 8/8 passed on RTX 5090 and WARP (including `new_table_routes_all_lookups_to_null_before_first_rewrite`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly initializes new page tables to the null view pair before their first rewrite. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-26 10:05:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T09:20:38Z.


Automated triage for the maintainers.

Merge candidate. Shared::new (crates/victory-gpu/src/memory.rs) now writes level 1 and block 0 of a new page table so that every lookup resolves to the null pair, the same result write_table gives for a table with no copies. The case can happen. Lists keep their host heap alive (list.keep in draw.rs), but memory::release drops the Shared entry when the title heap is dropped. A list recorded before that release then runs with a table prepare never rewrote, and every lookup lands on descriptor slot 0. The fill is 12,288 dwords once per table, so it costs little. new_table_routes_all_lookups_to_null_before_first_rewrite checks both the table contents and a dispatch against the un-rewritten table. It does not overlap #3122, and the two can both land.

CI: check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7187819832 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3119#issuecomment-7187819832). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T09:20:38Z. --- <!-- victory-triage v1 head=fe530463ae293e5b082b516c0506804db31e0e7b verdict=merge-candidate at=2026-11-26T09:22:00Z --> Automated triage for the maintainers. **Merge candidate.** `Shared::new` (`crates/victory-gpu/src/memory.rs`) now writes level 1 and block 0 of a new page table so that every lookup resolves to the null pair, the same result `write_table` gives for a table with no copies. The case can happen. Lists keep their host heap alive (`list.keep` in `draw.rs`), but `memory::release` drops the `Shared` entry when the title heap is dropped. A list recorded before that release then runs with a table `prepare` never rewrote, and every lookup lands on descriptor slot 0. The fill is 12,288 dwords once per table, so it costs little. `new_table_routes_all_lookups_to_null_before_first_rewrite` checks both the table contents and a dispatch against the un-rewritten table. It does not overlap #3122, and the two can both land. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3119:upstream-pr/3119'
git switch 'upstream-pr/3119'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3119'
git switch 'upstream-pr/3119'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3119'
git switch 'upstream-pr/3119'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3119'
git switch 'main'
git merge --squash 'upstream-pr/3119'
git switch 'main'
git merge --ff-only 'upstream-pr/3119'
git switch 'main'
git merge 'upstream-pr/3119'
git push origin 'main'
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!3117
No description provided.