GPU: preserve compatible read states for read-only depth targets #485

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

@⁠fuzeofficlal on GitHub · 2026-11-24 03:57 UTC · original
fuzeofficlal:fix/read-only-depth-state → main · +264 −21 · 1 files · 1 commits · open

A graphics draw can read a depth texture through a read-only DSV and an SRV at the same time. The host table path requests shader-resource state, then draw preparation requests DEPTH_WRITE and replaces it. This change preserves DEPTH_READ and adds the shader-resource bits when the same draw references the depth texture through an SRV table. Unsampled read-only depth uses DEPTH_READ alone. A depth/stencil view with a writable plane keeps the existing whole-resource behavior.

The synthetic D32 test uses an actual read-only DSV and an R32_FLOAT SRV on the same texture. On d2a4bae, table preparation recorded 0xc0 instead of 0xe0. On 5805f73, the test observes 0x20 before sampling and 0xe0 after table and depth preparation. The writable DSV control ends in DEPTH_WRITE. These checks cover recorded resource states through the ordinary descriptor table; pixel output and mixed depth/stencil planes are outside the fixture.

Windows 11 Pro build 26200, Rust 1.98.1 MSVC. With VICTORY_D3D12_DEBUG=1, cargo test --locked --offline -p victory-gpu --features diagnostics -- --test-threads=1 passed with 46 tests and one ignored benchmark. The focused shader_table_keeps_read_only_depth_state test also passed with VICTORY_D3D12_WARP=1. The staged asset policy check passed.

D3D12 resource states

**@⁠fuzeofficlal** on GitHub · 2026-11-24 03:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/485) `fuzeofficlal:fix/read-only-depth-state` → `main` · +264 −21 · 1 files · 1 commits · open A graphics draw can read a depth texture through a read-only DSV and an SRV at the same time. The host table path requests shader-resource state, then draw preparation requests DEPTH_WRITE and replaces it. This change preserves DEPTH_READ and adds the shader-resource bits when the same draw references the depth texture through an SRV table. Unsampled read-only depth uses DEPTH_READ alone. A depth/stencil view with a writable plane keeps the existing whole-resource behavior. The synthetic D32 test uses an actual read-only DSV and an R32_FLOAT SRV on the same texture. On `d2a4bae`, table preparation recorded `0xc0` instead of `0xe0`. On `5805f73`, the test observes `0x20` before sampling and `0xe0` after table and depth preparation. The writable DSV control ends in DEPTH_WRITE. These checks cover recorded resource states through the ordinary descriptor table; pixel output and mixed depth/stencil planes are outside the fixture. Windows 11 Pro build 26200, Rust 1.98.1 MSVC. With `VICTORY_D3D12_DEBUG=1`, `cargo test --locked --offline -p victory-gpu --features diagnostics -- --test-threads=1` passed with 46 tests and one ignored benchmark. The focused `shader_table_keeps_read_only_depth_state` test also passed with `VICTORY_D3D12_WARP=1`. The staged asset policy check passed. [D3D12 resource states](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_states)
Prepare fully read-only depth views in DEPTH_READ and combine shader-resource states only when the same draw reads the depth texture through an SRV table. Test both table preparation and final depth binding with synthetic descriptors.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:05:44 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 04:02 UTC · original

Verified 5805f73 on Arch Linux x86_64, Windows MSVC release build under Wine 11.22 (victory-gpu, --test-threads=1): 44 passed, 0 failed, 1 ignored (one more than main, presumably the new read-state case).

Not covered: read-only depth targets in the title's world passes (no game data here).

**@⁠DaviTostes** on GitHub · 2026-11-24 04:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/485#issuecomment-7121658479) Verified `5805f73` on **Arch Linux x86_64**, Windows MSVC release build under **Wine 11.22** (`victory-gpu`, `--test-threads=1`): **44 passed, 0 failed, 1 ignored** (one more than `main`, presumably the new read-state case). Not covered: read-only depth targets in the title's world passes (no game data here).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 04:04 UTC · original

Pixel readback follow-up for 5805f73 on Windows 11 build 26200, Rust 1.98.1 MSVC. The same synthetic 4×4 D32 texture was bound through VIctory's read-only DSV and R32_FLOAT SRV table paths. A native test PSO draws through the recorded state, with depth initially cleared to 0.25.

  • RTX 5090 (10de:2b85) and Microsoft WARP (1414:008c) both passed. With LESS, 8 of 16 pixels received the sampled color and 8 kept the clear color. The ALWAYS control colored all 16 pixels. All 16 depth values remained exactly 0.25 in both modes.
  • On the RTX 5090, forcing the old final DEPTH_WRITE state made the debug layer report at SetGraphicsRootDescriptorTable that the SRV required PIXEL_SHADER_RESOURCE. The negative draw was left unsubmitted.

The local synthetic extension ran with VICTORY_D3D12_DEBUG=1 and cargo test --locked --offline -p victory-gpu --features diagnostics shader_table_keeps_read_only_depth_state -- --nocapture --test-threads=1. WARP used VICTORY_D3D12_WARP=1. Coverage is the host raster path with VIctory's target and descriptor state preparation.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 04:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/485#issuecomment-7121688885) Pixel readback follow-up for `5805f73` on Windows 11 build 26200, Rust 1.98.1 MSVC. The same synthetic 4×4 D32 texture was bound through VIctory's read-only DSV and R32_FLOAT SRV table paths. A native test PSO draws through the recorded state, with depth initially cleared to 0.25. - RTX 5090 (10de:2b85) and Microsoft WARP (1414:008c) both passed. With LESS, 8 of 16 pixels received the sampled color and 8 kept the clear color. The ALWAYS control colored all 16 pixels. All 16 depth values remained exactly 0.25 in both modes. - On the RTX 5090, forcing the old final DEPTH_WRITE state made the debug layer report at SetGraphicsRootDescriptorTable that the SRV required PIXEL_SHADER_RESOURCE. The negative draw was left unsubmitted. The local synthetic extension ran with `VICTORY_D3D12_DEBUG=1` and `cargo test --locked --offline -p victory-gpu --features diagnostics shader_table_keeps_read_only_depth_state -- --nocapture --test-threads=1`. WARP used `VICTORY_D3D12_WARP=1`. Coverage is the host raster path with VIctory's target and descriptor state preparation.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:20 UTC · original · edited 2026-11-26 01:23 UTC

Automated triage for the maintainers.

Merge candidate (re-reviewed after the push). The new head d2052d5 is a rebase of the earlier 782b7af onto 842b0cb. The range-diff shows only context changes (the new depth_bounds field, the alias_source copy in readable), and the PR merges cleanly. The logic in crates/victory-gpu/src/draw.rs is the same. set_targets records the read-only DSV state (depth_state, which also needs the stencil plane read-only for stencil formats). readable_for_draw and ensure_depth_state request DEPTH_READ | shader-resource when the same draw samples that texture, and depth_sampled is reset per draw and per target change. Writable DSVs and compute keep the old behaviour.

CI: passing (check).

Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/485#issuecomment-7148407919) · edited 2026-11-26 01:23 UTC <!-- victory-triage v1 head=d2052d56b0d77ffe1065b4a266ceb6569db0f563 verdict=merge-candidate at=2026-11-26T01:23:01Z --> Automated triage for the maintainers. **Merge candidate (re-reviewed after the push).** The new head `d2052d5` is a rebase of the earlier `782b7af` onto `842b0cb`. The range-diff shows only context changes (the new `depth_bounds` field, the `alias_source` copy in `readable`), and the PR merges cleanly. The logic in `crates/victory-gpu/src/draw.rs` is the same. `set_targets` records the read-only DSV state (`depth_state`, which also needs the stencil plane read-only for stencil formats). `readable_for_draw` and `ensure_depth_state` request `DEPTH_READ | shader-resource` when the same draw samples that texture, and `depth_sampled` is reset per draw and per target change. Writable DSVs and compute keep the old behaviour. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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