GPU: a read slot is resolved once, not twice #3213

Open
borosf wants to merge 2 commits from upstream-pr/3215 into main
borosf commented 2026-11-26 13:21:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-26T13:21:29Z.


Summary

descriptor::make_read resolved every read slot twice: first HostHeap::mirror — the made-keys lock, the global views lock, a clone of the view, plus the kept lock when a texture view needs remaking — and then stamp_read, which looked the same slot up again through the same two locks and a second clone, only to stamp the HostTexture the view holds.

mirror already has the view in hand and returns it, so the stamp now takes the view: stamp_read_view(&view). stamp_read had no other caller, so it is deleted rather than left as a second way to do the same thing.

  • No behaviour change in what gets stamped. The slots mirror refuses are exactly the ones stamp_read found no made key for and returned on (its key != 0 guard), so the set of stamped textures is identical.
  • Per read slot: one resolution instead of two — one made-keys lock, one global views lock, one view clone. These run once per submission over the slots the title's lists read (descriptor.rs, make_read), against the world's 1,300–14,400 written slots a frame quoted in that file's own comment.
  • View is Clone but not Copy, so the placed-texture upgrade clones rather than moves; that is the only new clone, and it replaces a dropped one.

Verification

Intel Arc B580, Windows 11:

  • cargo test -p victory-gpu --lib --locked -- --test-threads=1 → 229 passed, 2 failed, 1 ignored. The two failures are the known Intel heap-cap pair (descriptor::host::tests::dynamic_slots_are_held_until_released, memory::tests::lists_share_a_table_and_copies_keep_their_views — #1744/#1829) that pristine main 63bcca4 also fails on this card.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings clean with and without the diagnostics feature.

No game data used; synthetic tests only.

Stacked on nothing: branched from main 63bcca4, two files, +13/−10. The magnitude is modelled from the slot rate × the two lock pairs and clone it removes, not measured — that needs a world frame with the title.

claiming: GPU: descriptor::make_read resolves every read slot twice (mirror, then stamp_read, each taking the made lock and the global VIEWS lock and cloning the view) — resolve once per slot and pass the view to the stamp, with a ReadSlots counter so the frame line can price it

<!-- greyfinch-sync:Marvisak/VIctory:issue:5510798786 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3215). Originally posted by [borosf](https://github.com/borosf) on 2026-11-26T13:21:29Z. --- ## Summary `descriptor::make_read` resolved every read slot **twice**: first `HostHeap::mirror` — the made-keys lock, the global views lock, a clone of the view, plus the kept lock when a texture view needs remaking — and then `stamp_read`, which looked the same slot up again through the same two locks and a second clone, only to stamp the `HostTexture` the view holds. `mirror` already has the view in hand and returns it, so the stamp now takes the view: `stamp_read_view(&view)`. `stamp_read` had no other caller, so it is deleted rather than left as a second way to do the same thing. - **No behaviour change in what gets stamped.** The slots `mirror` refuses are exactly the ones `stamp_read` found no made key for and returned on (its `key != 0` guard), so the set of stamped textures is identical. - **Per read slot:** one resolution instead of two — one made-keys lock, one global views lock, one view clone. These run once per submission over the slots the title's lists read (`descriptor.rs`, `make_read`), against the world's 1,300–14,400 written slots a frame quoted in that file's own comment. - `View` is `Clone` but not `Copy`, so the placed-texture upgrade clones rather than moves; that is the only new clone, and it replaces a dropped one. ## Verification Intel Arc B580, Windows 11: - `cargo test -p victory-gpu --lib --locked -- --test-threads=1` → **229 passed, 2 failed, 1 ignored**. The two failures are the known Intel heap-cap pair (`descriptor::host::tests::dynamic_slots_are_held_until_released`, `memory::tests::lists_share_a_table_and_copies_keep_their_views` — #1744/#1829) that pristine `main` `63bcca4` also fails on this card. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` clean with and without the `diagnostics` feature. No game data used; synthetic tests only. Stacked on nothing: branched from `main` `63bcca4`, two files, +13/−10. The magnitude is modelled from the slot rate × the two lock pairs and clone it removes, not measured — that needs a world frame with the title. claiming: GPU: descriptor::make_read resolves every read slot twice (mirror, then stamp_read, each taking the made lock and the global VIEWS lock and cloning the view) — resolve once per slot and pass the view to the stamp, with a ReadSlots counter so the frame line can price it
Dukestar69 commented 2026-11-26 13:27:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T13:27:48Z.

Review: APPROVED


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

  • cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 14/14 passed.
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly avoids resolving each read slot twice.

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6074943126 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3215#pullrequestreview-6074943126). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T13:27:48Z. **Review:** APPROVED --- Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released`: 14/14 passed. - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 20/20 passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly avoids resolving each read slot twice. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Jackster commented 2026-11-26 22:29:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:29:01Z.


Windows 11, 63bcca4 + this PR, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010):

  • cargo test -p victory-gpu --lib: 231 passed / 0 failed / 1 ignored (same as main).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.

No test added. stamp_read has no callers left (the crate builds), and the read-mark, eviction and descriptor-host tests that go through mirror pass. The new signature takes the view mirror already resolved, so the made-key lock and the global view lock are not taken a second time per read slot. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204718127 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3215#issuecomment-7204718127). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T22:29:01Z. --- Windows 11, `63bcca4` + this PR, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010): - `cargo test -p victory-gpu --lib`: 231 passed / 0 failed / 1 ignored (same as main). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. No test added. `stamp_read` has no callers left (the crate builds), and the read-mark, eviction and descriptor-host tests that go through `mirror` pass. The new signature takes the view `mirror` already resolved, so the made-key lock and the global view lock are not taken a second time per read slot. Synthetic only. AI-assisted.
fuzeofficlal commented 2026-11-27 00:28:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:28:29Z.

Review: APPROVED


Reviewed and tested 904b34804d48d4a60b84f76aa6443ee2f0a63876 on both RTX 5090 and WARP (VICTORY_D3D12_DEBUG=1).

Checked every return path of HostHeap::mirror (crates/victory-gpu/src/descriptor/host.rs:722-833): out-of-range and empty/released slots return None, while the fast path, concurrent-rewrite retry path, and freshly mirrored/remade path all return Some(view). Passing that view straight into stamp_read_view(&view) preserves exact behavior (including placed_texture resolution) while cutting out a redundant made lock, global VIEWS lock, and view_at lookup per read slot.

Checks run:

  • cargo xtask policy — pass
  • cargo clippy --tests -p victory-gpu -- -D warnings (default and --features diagnostics) — clean
  • RTX 5090 (VICTORY_D3D12_DEBUG=1): descriptor:: (21/21 excluding the pre-existing dynamic_slots_are_held_until_released baseline failure) and host::tests::textures_read_every_frame_stay_and_title_lists_stamp_theirs — pass with 0 Debug Layer errors
  • WARP (VICTORY_D3D12_WARP=1, VICTORY_D3D12_DEBUG=1): descriptor:: (22/22) and host::tests::textures_read_every_frame_stay_and_title_lists_stamp_theirs — pass with 0 Debug Layer errors.

LGTM!

<!-- greyfinch-sync:Marvisak/VIctory:review:6081962985 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3215#pullrequestreview-6081962985). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T00:28:29Z. **Review:** APPROVED --- Reviewed and tested `904b34804d48d4a60b84f76aa6443ee2f0a63876` on both RTX 5090 and WARP (`VICTORY_D3D12_DEBUG=1`). Checked every return path of `HostHeap::mirror` (`crates/victory-gpu/src/descriptor/host.rs:722-833`): out-of-range and empty/released slots return `None`, while the fast path, concurrent-rewrite retry path, and freshly mirrored/remade path all return `Some(view)`. Passing that view straight into `stamp_read_view(&view)` preserves exact behavior (including `placed_texture` resolution) while cutting out a redundant `made` lock, global `VIEWS` lock, and `view_at` lookup per read slot. Checks run: - `cargo xtask policy` — pass - `cargo clippy --tests -p victory-gpu -- -D warnings` (default and `--features diagnostics`) — clean - RTX 5090 (`VICTORY_D3D12_DEBUG=1`): `descriptor::` (21/21 excluding the pre-existing `dynamic_slots_are_held_until_released` baseline failure) and `host::tests::textures_read_every_frame_stay_and_title_lists_stamp_theirs` — pass with 0 Debug Layer errors - WARP (`VICTORY_D3D12_WARP=1`, `VICTORY_D3D12_DEBUG=1`): `descriptor::` (22/22) and `host::tests::textures_read_every_frame_stay_and_title_lists_stamp_theirs` — pass with 0 Debug Layer errors. LGTM!
borosf commented 2026-11-27 06:38:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T06:38:44Z.


Thank you — RX 7900 XTX, 63bcca4 + this PR: 231 passed / 0 failed / 1 ignored (same as main) and clippy clean in -D warnings is exactly the check I could not run on this card (Arc B580), so it is useful to have.

Agreed on the test: stamp_read has no callers left, and the change only removes a second lock-and-lookup for a view mirror already resolved, so the coverage that matters is the existing read-mark, eviction and descriptor-host tests, which you ran. Synthetic only, no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7211715592 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3215#issuecomment-7211715592). Originally posted by [borosf](https://github.com/borosf) on 2026-11-27T06:38:44Z. --- Thank you — RX 7900 XTX, `63bcca4` + this PR: 231 passed / 0 failed / 1 ignored (same as main) and clippy clean in `-D warnings` is exactly the check I could not run on this card (Arc B580), so it is useful to have. Agreed on the test: `stamp_read` has no callers left, and the change only removes a second lock-and-lookup for a view `mirror` already resolved, so the coverage that matters is the existing read-mark, eviction and descriptor-host tests, which you ran. Synthetic only, no game data.
neonbyte1 commented 2026-11-27 14:25:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-27T14:25:59Z.


Tested in game together with #3262 (both merged cleanly) on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton, GTA VI's opening prison yard, on main plus the unmerged PRs this setup needs (listed in #3425). 420 s runs, medians of the last 30 frame-rate lines, against three adjacent controls of the same base:

frame preparing (CPU)
controls (3 runs) 196.1 / 196.9 / 202.2 ms 75.8 / 75.8 / 78.5 ms
#3215 + #3262 197.6 ms 74.7 ms

No measurable change in frame or preparing time here: whatever the two save is below our run-to-run spread (a few ms). No crash, same pictures. Not a reason against either; the work they remove is real, just small on this scene.

AI-assisted (Claude); measured on my machine, no game data shared.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7220775488 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3215#issuecomment-7220775488). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-27T14:25:59Z. --- Tested in game together with #3262 (both merged cleanly) on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton, GTA VI's opening prison yard, on `main` plus the unmerged PRs this setup needs (listed in #3425). 420 s runs, medians of the last 30 frame-rate lines, against three adjacent controls of the same base: | | frame | preparing (CPU) | |---|---|---| | controls (3 runs) | 196.1 / 196.9 / 202.2 ms | 75.8 / 75.8 / 78.5 ms | | #3215 + #3262 | 197.6 ms | 74.7 ms | No measurable change in frame or preparing time here: whatever the two save is below our run-to-run spread (a few ms). No crash, same pictures. Not a reason against either; the work they remove is real, just small on this scene. _AI-assisted (Claude); measured on my machine, no game data shared._
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/3215:upstream-pr/3215'
git switch 'upstream-pr/3215'

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