gpu: depth-test-only draws leave the depth twin alone; held texture slots by a flag bit #2770

Open
LouisRiverstone wants to merge 1 commit from upstream-pr/2770 into main
LouisRiverstone commented 2026-11-29 17:07:35 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by LouisRiverstone on 2026-11-29T17:07:35Z.


Why

Two costs that leave the picture unchanged and land hardest on smaller cards.

Depth twins copied after depth-test-only draws. draw.rs called twin_use(depth, false, true) for every draw with a depth target. The twin_use comment names this shortcut: "every depth target bound for a draw counts as written (also when the draw only tests)". For a depth texture that shaders also write, each such draw marked the colour twin as behind, and its next use copied the whole texture again. Transparent surfaces and decals are the usual case: they test depth and do not write it.

A hash lookup per queued slot under the texture queue's lock. TextureQueue::collect_due_and_census called self.held.get(&e.index) for every slot that was not yet due, with the queue's lock held. held fills when the card has no room left, which is the normal state on 8 GB cards. findings.md (RTX 5090 D) names this lock as the most contended one.

What changed

  • pipeline/host.rs: HostPipeline::writes_depth, computed from the title's depth-stencil state. It is true when the depth test is on with the write mask set to all, or when the stencil test is on with a non-zero write mask. The host PSO takes g.depth unchanged (DepthStencilState: g.depth), so the field matches what the card does. Compute pipelines get false.
  • draw.rs: a draw counts as writing depth only when its view is not read-only (depth_state != DEPTH_READ) and p.writes_depth is true.
  • descriptor/host.rs: a new entry flag, FLAG_HELD. hold sets it and room clears it. A new write already puts a fresh entry with flags 0, so the bit stands for "held maps this slot to this entry's write", and the due scan tests the bit instead of the map.

Tests

  • New: a_pipeline_writes_depth_only_when_its_state_can covers seven depth/stencil combinations.
  • dense_texture_queue_invariants_and_cold_maps now checks at every step that the bit matches held. It also covers a slot written again while it is held.
  • cargo test -p victory-gpu --lib: 913-915 passed. One to three failures per run, and which ones changes between runs (card_steps, menu, uav_pool, watch); none is in a file this PR touches.
    • The uav_pool and watch failures pass on their own, three runs in a row.
    • Unchanged main fails in the same group (menu, card_steps).

CI

main does not pass clippy at the moment:

  • the default build stops in victory-shader on unused imports (emit/lower/analysis.rs:6, emit/lower.rs:594);
  • the --all-features build does not compile, with errors in host.rs and copystat.rs.

This PR does not touch those, so CI will fail on them. Running clippy without -D warnings, the only warning in the touched files is mirror_for_pass never used (descriptor/host.rs:4598), which was there before.

Not verified

Neither change has been run in game or measured. To check them in a diag build:

  • GPU copy time with depth-tested transparent passes on screen;
  • "the texture queue's lock" wait in the log with VRAM full (an 8 GB card, or a low VICTORY_VRAM_BUDGET_MB).

The depth change should be checked against screenshots of scenes with depth-read passes (water, decals, particles).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5553055079 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2770). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-11-29T17:07:35Z. --- ## Why Two costs that leave the picture unchanged and land hardest on smaller cards. **Depth twins copied after depth-test-only draws.** `draw.rs` called `twin_use(depth, false, true)` for every draw with a depth target. The `twin_use` comment names this shortcut: "every depth target bound for a draw counts as written (also when the draw only tests)". For a depth texture that shaders also write, each such draw marked the colour twin as behind, and its next use copied the whole texture again. Transparent surfaces and decals are the usual case: they test depth and do not write it. **A hash lookup per queued slot under the texture queue's lock.** `TextureQueue::collect_due_and_census` called `self.held.get(&e.index)` for every slot that was not yet due, with the queue's lock held. `held` fills when the card has no room left, which is the normal state on 8 GB cards. `findings.md` (RTX 5090 D) names this lock as the most contended one. ## What changed - `pipeline/host.rs`: `HostPipeline::writes_depth`, computed from the title's depth-stencil state. It is true when the depth test is on with the write mask set to all, or when the stencil test is on with a non-zero write mask. The host PSO takes `g.depth` unchanged (`DepthStencilState: g.depth`), so the field matches what the card does. Compute pipelines get `false`. - `draw.rs`: a draw counts as writing depth only when its view is not read-only (`depth_state != DEPTH_READ`) and `p.writes_depth` is true. - `descriptor/host.rs`: a new entry flag, `FLAG_HELD`. `hold` sets it and `room` clears it. A new write already puts a fresh entry with flags 0, so the bit stands for "`held` maps this slot to this entry's write", and the due scan tests the bit instead of the map. ## Tests - New: `a_pipeline_writes_depth_only_when_its_state_can` covers seven depth/stencil combinations. - `dense_texture_queue_invariants_and_cold_maps` now checks at every step that the bit matches `held`. It also covers a slot written again while it is held. - `cargo test -p victory-gpu --lib`: 913-915 passed. One to three failures per run, and which ones changes between runs (`card_steps`, `menu`, `uav_pool`, `watch`); none is in a file this PR touches. - The `uav_pool` and `watch` failures pass on their own, three runs in a row. - Unchanged `main` fails in the same group (`menu`, `card_steps`). ## CI `main` does not pass clippy at the moment: - the default build stops in `victory-shader` on unused imports (`emit/lower/analysis.rs:6`, `emit/lower.rs:594`); - the `--all-features` build does not compile, with errors in `host.rs` and `copystat.rs`. This PR does not touch those, so CI will fail on them. Running clippy without `-D warnings`, the only warning in the touched files is `mirror_for_pass` never used (`descriptor/host.rs:4598`), which was there before. ## Not verified Neither change has been run in game or measured. To check them in a `diag` build: - GPU copy time with depth-tested transparent passes on screen; - "the texture queue's lock" wait in the log with VRAM full (an 8 GB card, or a low `VICTORY_VRAM_BUDGET_MB`). The depth change should be checked against screenshots of scenes with depth-read passes (water, decals, particles).
dyshay commented 2026-11-29 17:49:04 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-29T17:49:04Z.


Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series S with ray tracing, and Series X, DLSS Quality). Frame times will follow here.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7259987067 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2770#issuecomment-7259987067). Originally posted by [dyshay](https://github.com/dyshay) on 2026-11-29T17:49:04Z. --- Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series S with ray tracing, and Series X, DLSS Quality). Frame times will follow here.
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/2770:upstream-pr/2770'
git switch 'upstream-pr/2770'

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/2770'
git switch 'upstream-pr/2770'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2770'
git switch 'upstream-pr/2770'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2770'
git switch 'main'
git merge --squash 'upstream-pr/2770'
git switch 'main'
git merge --ff-only 'upstream-pr/2770'
git switch 'main'
git merge 'upstream-pr/2770'
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
trustno1-coder/VIctory-NVIDIA!2770
No description provided.