GPU: clear ALLOW_RENDER_TARGET alongside ALLOW_UNORDERED_ACCESS on host depth resources #2143

Closed
fuzeofficlal wants to merge 1 commit from upstream-pr/2145 into main
fuzeofficlal commented 2026-11-25 06:01:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T06:01:03Z.


Problem

Console D3D12 allows depth-stencil textures to carry ALLOW_RENDER_TARGET (0x1) and ALLOW_UNORDERED_ACCESS (0x4) alongside ALLOW_DEPTH_STENCIL (0x2), whereas PC D3D12 rejects CreateCommittedResource whenever D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL is combined with D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET. Currently host_desc (crates/victory-gpu/src/resource.rs) strips UNORDERED on DEPTH resources while leaving RENDER_TARGET set.

Changes

  • Clear RENDER_TARGET (0x1) together with UNORDERED (0x4) in host_desc when d.flags & DEPTH != 0 so committed, placed, and address-backed depth resources create and share HostTexture copies cleanly (and strip any initial RENDER_TARGET resource state via legal_for).
  • Add resource::tests::depth_resources_drop_render_target_and_unordered_flags covering D32_FLOAT, D16_UNORM, and D32_FLOAT_S8X24_UINT with 0x3 / 0x7 / 0xb flags across create_committed, create_at_address (verifying HostTexture sharing), and texture_at, plus GPU ClearDepthStencilView readback under VICTORY_D3D12_DEBUG=1 across RTX 5090, AMD Radeon Graphics, and D3D12 WARP.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6598285880 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2145). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T06:01:03Z. --- ### Problem Console D3D12 allows depth-stencil textures to carry `ALLOW_RENDER_TARGET` (`0x1`) and `ALLOW_UNORDERED_ACCESS` (`0x4`) alongside `ALLOW_DEPTH_STENCIL` (`0x2`), whereas PC D3D12 rejects `CreateCommittedResource` whenever `D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL` is combined with `D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET`. Currently `host_desc` (`crates/victory-gpu/src/resource.rs`) strips `UNORDERED` on `DEPTH` resources while leaving `RENDER_TARGET` set. ### Changes - Clear `RENDER_TARGET` (`0x1`) together with `UNORDERED` (`0x4`) in `host_desc` when `d.flags & DEPTH != 0` so committed, placed, and address-backed depth resources create and share `HostTexture` copies cleanly (and strip any initial `RENDER_TARGET` resource state via `legal_for`). - Add `resource::tests::depth_resources_drop_render_target_and_unordered_flags` covering `D32_FLOAT`, `D16_UNORM`, and `D32_FLOAT_S8X24_UINT` with `0x3` / `0x7` / `0xb` flags across `create_committed`, `create_at_address` (verifying `HostTexture` sharing), and `texture_at`, plus GPU `ClearDepthStencilView` readback under `VICTORY_D3D12_DEBUG=1` across RTX 5090, AMD Radeon Graphics, and D3D12 WARP.
DenRakEiw commented 2026-11-25 07:02:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T06:24:05Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib depth_resources_drop_render_target_and_unordered_flags — passed on RTX 5090
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean clearing of ALLOW_RENDER_TARGET alongside ALLOW_UNORDERED_ACCESS on host depth resources. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6052795000 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2145#pullrequestreview-6052795000). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T06:24:05Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib depth_resources_drop_render_target_and_unordered_flags` — passed on RTX 5090 - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean clearing of `ALLOW_RENDER_TARGET` alongside `ALLOW_UNORDERED_ACCESS` on host depth resources. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 07:02:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T06:33:06Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

ALLOW_RENDER_TARGET cleared alongside ALLOW_UNORDERED_ACCESS — usage-flag hygiene fix; prevents invalid combos reaching D3D12.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052889266 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2145#pullrequestreview-6052889266). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T06:33:06Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. ALLOW_RENDER_TARGET cleared alongside ALLOW_UNORDERED_ACCESS — usage-flag hygiene fix; prevents invalid combos reaching D3D12.
upstream-sync closed this pull request 2026-11-25 12:03:01 +00:00
Marvisak commented 2026-11-25 12:03:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T11:25:50Z.


Automated triage for the maintainers.

Needs work.

The PR makes host_desc (crates/victory-gpu/src/resource.rs) clear ALLOW_RENDER_TARGET as well as ALLOW_UNORDERED_ACCESS on depth textures, so that D3D12 accepts their host copies. The premise is plausible: the PC API does not take depth-stencil together with render-target or unordered access on one resource. legal_for already drops the render-target state bit once the flag is gone. CI: passing (check).

What it needs:

  • Evidence the title asks for it. The edited comment now says the title's shadow maps and material depth ask for render target on depth textures. Please back that with a log line from a run, such as a refused host resource for a depth texture with flags 0x3/0x7, or drop the claim. The new test (about 330 lines) checks that the flags are cleared after the change. It does not show a failure on main that this fixes.
  • Render target views of such textures. The UAV case has a fallback: unordered views write a twin (crate::twin). Render targets have nothing like that. Today a depth+RT texture has no host copy, so State::set_targets (draw.rs) and clear_rtv (list.rs) skip it. After this change they call Host::rtv → CreateRenderTargetView on a host resource that lacks ALLOW_RENDER_TARGET, which D3D12 treats as invalid. Please handle that case in those two paths (skip it with a once! warning, or give it a twin) and cover it in the test. Alternatively, show that the title never makes an RTV on these textures.
  • Smaller: the test's flag checks use bare 0x1/0x2/0x4/0x8. The named constants (DEPTH, UNORDERED, or a shared RENDER_TARGET) would read better than the new local const RENDER_TARGET in host_desc.

Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161036304 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2145#issuecomment-7161036304). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T11:25:50Z. --- <!-- victory-triage v1 head=ddefbcc5fcfcecca05036050644b57b488061c45 verdict=needs-work at=2026-11-25T11:25:50Z --> Automated triage for the maintainers. **Needs work.** The PR makes `host_desc` (`crates/victory-gpu/src/resource.rs`) clear `ALLOW_RENDER_TARGET` as well as `ALLOW_UNORDERED_ACCESS` on depth textures, so that D3D12 accepts their host copies. The premise is plausible: the PC API does not take depth-stencil together with render-target or unordered access on one resource. `legal_for` already drops the render-target state bit once the flag is gone. CI: passing (`check`). What it needs: - **Evidence the title asks for it.** The edited comment now says the title's shadow maps and material depth ask for render target on depth textures. Please back that with a log line from a run, such as a refused host resource for a depth texture with flags `0x3`/`0x7`, or drop the claim. The new test (about 330 lines) checks that the flags are cleared after the change. It does not show a failure on `main` that this fixes. - **Render target views of such textures.** The UAV case has a fallback: unordered views write a twin (`crate::twin`). Render targets have nothing like that. Today a depth+RT texture has no host copy, so `State::set_targets` (`draw.rs`) and `clear_rtv` (`list.rs`) skip it. After this change they call `Host::rtv` → `CreateRenderTargetView` on a host resource that lacks `ALLOW_RENDER_TARGET`, which D3D12 treats as invalid. Please handle that case in those two paths (skip it with a `once!` warning, or give it a twin) and cover it in the test. Alternatively, show that the title never makes an RTV on these textures. - **Smaller:** the test's flag checks use bare `0x1`/`0x2`/`0x4`/`0x8`. The named constants (`DEPTH`, `UNORDERED`, or a shared `RENDER_TARGET`) would read better than the new local `const RENDER_TARGET` in `host_desc`. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-25 12:03:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T11:53:22Z.


Good catch in the triage review — checking across reported title runs confirms this came from a synthetic resource-flag probe rather than an actual title resource request (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET and D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL are mutually exclusive in Direct3D 12 as well), and stripping ALLOW_RENDER_TARGET without an RTV twin would leave set_targets / clear_rtv calling CreateRenderTargetView on a non-RT host resource.

Closing this PR so we only carry fixes backed by real title behavior.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161638889 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2145#issuecomment-7161638889). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T11:53:22Z. --- Good catch in the triage review — checking across reported title runs confirms this came from a synthetic resource-flag probe rather than an actual title resource request (`D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET` and `D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL` are mutually exclusive in Direct3D 12 as well), and stripping `ALLOW_RENDER_TARGET` without an RTV twin would leave `set_targets` / `clear_rtv` calling `CreateRenderTargetView` on a non-RT host resource. Closing this PR so we only carry fixes backed by real title behavior.

Pull request closed

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!2143
No description provided.