GPU: a readable texture does not share a host texture denied to shaders #2187

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

@⁠fuzeofficlal on GitHub · 2026-11-25 07:19 UTC · original
fuzeofficlal:fix/gpu-shared-texture-deny-srv → main · +72 −0 · 2 files · 1 commits · open

Problem

A depth texture created with D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE keeps that flag and its typed depth format (D32_FLOAT, D16_UNORM, ...) on the host. takes only compared render target / depth / unordered uses (USES = 0x7) and the format family, so a later texture or placed view of the same memory (same MemoryKey, which does not include 0x8) that shaders read reused the denied host texture. fits() then refused its shader view, the slot became a null view, and shaders read zeros. Both title textures shared one host texture, so alias_source / texture::alias_copy never ran either.

Changes

  • takes also requires serves_reads: a host texture made without shader access (denied, or a typed depth format) only serves descriptions that deny shader access too. A readable description gets a new host texture through the existing replacement path in shared_texture, and a placed view reads what the GPU wrote through the old one via the existing alias_source + texture::alias_copy.
  • New test a_depth_texture_denied_to_shaders_reads_through_a_placed_view: clears a D32_FLOAT | DEPTH | DENY_SHADER_RESOURCE texture to 0.75 and reads it back through a placed R32_FLOAT view of the same memory in a compute shader. Tests that make alias copies now take a shared lock, since one of them counts ALIAS_COPIES.

Verification

  • The new test fails before the change (the placed view's slot cannot be made) and passes after, including with VICTORY_D3D12_DEBUG=1 (no debug layer messages).
  • cargo test -p victory-gpu --locked on hardware: only the two failures already on main (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views). With VICTORY_D3D12_WARP=1 and diagnostics: all victory-gpu tests pass.
  • clippy -D warnings (default and diagnostics), rustfmt on the changed hunks, and cargo xtask policy pass.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 07:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2187) `fuzeofficlal:fix/gpu-shared-texture-deny-srv` → `main` · +72 −0 · 2 files · 1 commits · open ### Problem A depth texture created with `D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE` keeps that flag and its typed depth format (`D32_FLOAT`, `D16_UNORM`, ...) on the host. `takes` only compared render target / depth / unordered uses (`USES = 0x7`) and the format family, so a later texture or placed view of the same memory (same `MemoryKey`, which does not include `0x8`) that shaders read reused the denied host texture. `fits()` then refused its shader view, the slot became a null view, and shaders read zeros. Both title textures shared one host texture, so `alias_source` / `texture::alias_copy` never ran either. ### Changes - `takes` also requires `serves_reads`: a host texture made without shader access (denied, or a typed depth format) only serves descriptions that deny shader access too. A readable description gets a new host texture through the existing replacement path in `shared_texture`, and a placed view reads what the GPU wrote through the old one via the existing `alias_source` + `texture::alias_copy`. - New test `a_depth_texture_denied_to_shaders_reads_through_a_placed_view`: clears a `D32_FLOAT | DEPTH | DENY_SHADER_RESOURCE` texture to 0.75 and reads it back through a placed `R32_FLOAT` view of the same memory in a compute shader. Tests that make alias copies now take a shared lock, since one of them counts `ALIAS_COPIES`. ### Verification - The new test fails before the change (the placed view's slot cannot be made) and passes after, including with `VICTORY_D3D12_DEBUG=1` (no debug layer messages). - `cargo test -p victory-gpu --locked` on hardware: only the two failures already on main (`dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`). With `VICTORY_D3D12_WARP=1` and `diagnostics`: all `victory-gpu` tests pass. - clippy `-D warnings` (default and `diagnostics`), rustfmt on the changed hunks, and `cargo xtask policy` pass.
Title textures of one memory share a host texture when it has their
uses and a view format of their family. A depth texture made with
D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE keeps the flag and its typed
depth format (D32_FLOAT, D16_UNORM) on the host, and the uses checked
leave the flag out: a later texture or placed view of the same memory
that shaders read took that host texture, the host refused its shader
view, and the read saw zeros. Both shared one host texture, so no
alias copy ran either.

A host texture made without shader access (denied, or typed depth)
now only serves descriptions that deny shader access too. A readable
one gets a new host texture, which becomes the memory's; a placed view
reads what the GPU wrote through the old one by the existing alias
copy.

A test clears a D32_FLOAT depth texture that denies shader access and
reads the depth back through a placed view of its memory. The tests
that make alias copies now run one at a time, as one counts them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:52 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 07:58 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head df71bd02 into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 702 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). One thing to know: in the first full run a test that this PR does not touch, bindless::tests::heap_views_follow_writes_through_another_mapping (bindless.rs:612, "round 0, dword 0, left 0, right 1064"), failed once; the second full run and 6 further runs of cargo test -p victory-gpu --lib on the same tree all passed (144 passed each), so I could not reproduce it and cannot say whether it comes from this PR or from the test itself. The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 07:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2187#issuecomment-7156452594) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `df71bd02` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 702 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). One thing to know: in the first full run a test that this PR does not touch, `bindless::tests::heap_views_follow_writes_through_another_mapping` (`bindless.rs:612`, "round 0, dword 0, left 0, right 1064"), failed once; the second full run and 6 further runs of `cargo test -p victory-gpu --lib` on the same tree all passed (144 passed each), so I could not reproduce it and cannot say whether it comes from this PR or from the test itself. The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 08:52 UTC · original

Follow-up to my report above: the one failure I mentioned, bindless::tests::heap_views_follow_writes_through_another_mapping at bindless.rs:612, is not from this PR. The same assertion ("round 0, dword 0, left 0, right 1064") failed on main 940d32f alone in a later full run on the same machine, in the test bindless::tests::heap_views_are_current; I have opened an issue with the numbers (#2252).

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 08:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2187#issuecomment-7157576902) Follow-up to my report above: the one failure I mentioned, `bindless::tests::heap_views_follow_writes_through_another_mapping` at `bindless.rs:612`, is not from this PR. The same assertion ("round 0, dword 0, left 0, right 1064") failed on `main` `940d32f` alone in a later full run on the same machine, in the test `bindless::tests::heap_views_are_current`; I have opened an issue with the numbers (#2252). AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 12:38 UTC · original · edited 2026-11-26 01:21 UTC

Automated triage for the maintainers.

Merge candidate (unchanged). The push since the last triage (df71bd0 to 9ceb7c4) is a rebase onto current main. The diff is identical line for line, and it still merges cleanly. takes in crates/victory-gpu/src/resource.rs gains serves_reads, so a title texture that shaders read no longer shares a host texture made without shader access (a denied texture or a typed depth format). It gets its own host texture through the existing replacement path, with the contents copied over through alias_source. The new test in draw.rs reads a cleared denied D32_FLOAT texture through an R32_FLOAT placed view. The tests that count alias copies share the ALIASED lock.

CI: passing (check).

Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 12:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2187#issuecomment-7162662999) · edited 2026-11-26 01:21 UTC <!-- victory-triage v1 head=9ceb7c42d6dc5ddbfa8dc7ac242db5f43926240e verdict=merge-candidate at=2026-11-26T01:21:54Z --> Automated triage for the maintainers. **Merge candidate (unchanged).** The push since the last triage (`df71bd0` to `9ceb7c4`) is a rebase onto current `main`. The diff is identical line for line, and it still merges cleanly. `takes` in `crates/victory-gpu/src/resource.rs` gains `serves_reads`, so a title texture that shaders read no longer shares a host texture made without shader access (a denied texture or a typed depth format). It gets its own host texture through the existing replacement path, with the contents copied over through `alias_source`. The new test in `draw.rs` reads a cleared denied `D32_FLOAT` texture through an `R32_FLOAT` placed view. The tests that count alias copies share the `ALIASED` lock. 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/2187/head:github-bot/gh-2187'
git switch 'github-bot/gh-2187'

Merge

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