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

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

@⁠LouisRiverstone on GitHub · 2026-11-29 17:07 UTC · original
LouisRiverstone:perf/depth-reads-and-held-flag → main · +93 −5 · 3 files · 1 commits · open

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

**@⁠LouisRiverstone** on GitHub · 2026-11-29 17:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2770) `LouisRiverstone:perf/depth-reads-and-held-flag` → `main` · +93 −5 · 3 files · 1 commits · open ## 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).
Every draw with a depth target counted as writing it, also when it only
tested, so a depth texture that shaders also write had its colour twin
marked behind after each such draw and copied whole at its next use.
A draw now writes depth only when its view is not read-only and its
pipeline's depth-stencil state can write (depth test on with the write
mask all, or the stencil test on with a write mask). The host pipeline
takes the title's state unchanged, so this is what the card does.

The texture queue's due scan looked each not-yet-due slot up in `held`
with the queue's lock held; `held` fills when the card is full. A
FLAG_HELD bit on the entry, set by `hold` and cleared by `room` (a new
write puts flags 0), stands for that lookup.

Tests: writes_depth over depth and stencil states; the queue's invariant
test checks the bit against `held` at every step, with a slot written
again while held.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 17:11:21 +00:00
Author
Owner

@⁠dyshay on GitHub · 2026-11-29 17:49 UTC · original

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.

**@⁠dyshay** on GitHub · 2026-11-29 17:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2770#issuecomment-7259987067) 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 has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2770/head:github-bot/gh-2770'
git switch 'github-bot/gh-2770'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2770'
git switch 'github-bot/gh-2770'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2770'
git switch 'github-bot/gh-2770'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2770'
git switch 'main'
git merge --squash 'github-bot/gh-2770'
git switch 'main'
git merge --ff-only 'github-bot/gh-2770'
git switch 'main'
git merge 'github-bot/gh-2770'
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/trustno1-coder--VIctory-NVIDIA!2770
No description provided.