GPU: mirror placed unordered texture views #1273

Manually merged
github merged 3 commits from gh-pr/1273/head into gh-pr/1273/base 2026-11-26 04:25:54 +00:00
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 16:59 UTC · original
fuzeofficlal:fix/placed-texture-uav → main · +686 −26 · 4 files · 3 commits · merged 2026-11-25 21:40 UTC

Fixes #921

Summary

descriptor/host.rs::placed_texture() previously matched only View::Placed(false, ...), causing all View::Placed(true, ...) placed texture UAVs to fall back to null descriptors (silently dropping shader writes and skipping UNORDERED_ACCESS state transitions in draw::readable()), while placed buffer UAVs (resource[0] == 1) already worked.

This change mirrors placed unordered texture views and guards the newly reachable D3D12 view/format combinations:

  1. Mirror placed unordered texture views (crates/victory-gpu/src/descriptor/host.rs, draw.rs):
    • Generalized placed_texture() to match View::Placed(unordered, resource, desc) and emit View::Unordered(texture as usize, 0, view_desc) when unordered is true (View::Shader when false).
    • Removed the obsolete "placed unordered texture view not mirrored" shortcut while retaining the resource[0] != BUFFER guard in make() when placed_texture() returns None.
    • With View::Unordered returned by placed_texture(), draw::readable() automatically transitions placed texture UAVs to D3D12_RESOURCE_STATE_UNORDERED_ACCESS and subsequent placed SRV reads back to SHADER_RESOURCE without CPU upload clobbering (!title_written).
  2. Typed UAV & view-format guards (crates/victory-gpu/src/descriptor/host.rs):
    • Added supports_typed_uav(device, format) querying D3D12_FEATURE_FORMAT_SUPPORT (D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW) and applied it in fits() for both DXGI_FORMAT_UNKNOWN (0) and concrete effective formats, preventing device removals on unsupported view formats (e.g. B8G8R8X8_TYPELESS -> B8G8R8X8_UNORM(_SRGB)).
    • Updated fits() to reject DEPTH_FORMATS on the requested view format as well as the underlying own resource format, and to reject (typeless && is_typeless(view)).
    • Resolved desc.Format == DXGI_FORMAT_UNKNOWN (0) via crate::resource::view_format(resource) in make() for View::Shader and View::Unordered before fits(), keeping R8G8B8A8_UNORM_SRGB / B8G8R8A8_UNORM_SRGB (29/91) + ALLOW_UNORDERED_ACCESS views working as linear UAVs (28/87).

Verification

  • Pre-fix reproduction on main (ffe310e): synthetic compute dispatch writing a placed texture UAV returned [0, 0, 0, 0] (UNORDERED_ACCESS transition also skipped).
  • Post-fix (62946e6, synthetic tests in descriptor/host.rs & draw.rs covering 16 placed UAV / 4 placed SRV descriptor cases, D3DCompile cs_5_1 per-texel placed texture + placed buffer UAV readback, and UNORDERED_ACCESS -> SHADER_RESOURCE state transitions):
    • cargo xtask policy: pass (154 files ok)
    • cargo clippy --workspace --all-targets --locked -- -D warnings (default & --all-features): 0 warnings
    • cargo test --workspace --locked (NVIDIA GeForce RTX 5090, solo): pass (victory-gpu: 53 passed, 0 failed, 1 ignored; all workspace crates pass)
    • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked: 56 passed, 0 failed, 1 ignored
    • VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1 cargo test -p victory-gpu --features diagnostics --locked (placed_uav & compute_dispatch_writes_placed_texture_and_buffer_uavs): 2 passed + 1 passed
    • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked (with & without VICTORY_D3D12_DEBUG=1): 56 passed, 0 failed, 1 ignored
  • Not directly run on AMD Radeon integrated graphics in this main-based checkout (upstream main does not yet have an adapter-selection env var).
**@⁠fuzeofficlal** on GitHub · 2026-11-24 16:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1273) `fuzeofficlal:fix/placed-texture-uav` → `main` · +686 −26 · 4 files · 3 commits · merged 2026-11-25 21:40 UTC Fixes #921 ### Summary `descriptor/host.rs::placed_texture()` previously matched only `View::Placed(false, ...)`, causing all `View::Placed(true, ...)` placed texture UAVs to fall back to null descriptors (silently dropping shader writes and skipping `UNORDERED_ACCESS` state transitions in `draw::readable()`), while placed buffer UAVs (`resource[0] == 1`) already worked. This change mirrors placed unordered texture views and guards the newly reachable D3D12 view/format combinations: 1. **Mirror placed unordered texture views (`crates/victory-gpu/src/descriptor/host.rs`, `draw.rs`)**: - Generalized `placed_texture()` to match `View::Placed(unordered, resource, desc)` and emit `View::Unordered(texture as usize, 0, view_desc)` when `unordered` is true (`View::Shader` when false). - Removed the obsolete `"placed unordered texture view not mirrored"` shortcut while retaining the `resource[0] != BUFFER` guard in `make()` when `placed_texture()` returns `None`. - With `View::Unordered` returned by `placed_texture()`, `draw::readable()` automatically transitions placed texture UAVs to `D3D12_RESOURCE_STATE_UNORDERED_ACCESS` and subsequent placed SRV reads back to `SHADER_RESOURCE` without CPU upload clobbering (`!title_written`). 2. **Typed UAV & view-format guards (`crates/victory-gpu/src/descriptor/host.rs`)**: - Added `supports_typed_uav(device, format)` querying `D3D12_FEATURE_FORMAT_SUPPORT` (`D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW`) and applied it in `fits()` for both `DXGI_FORMAT_UNKNOWN` (`0`) and concrete effective formats, preventing device removals on unsupported view formats (e.g. `B8G8R8X8_TYPELESS` -> `B8G8R8X8_UNORM(_SRGB)`). - Updated `fits()` to reject `DEPTH_FORMATS` on the requested `view` format as well as the underlying `own` resource format, and to reject `(typeless && is_typeless(view))`. - Resolved `desc.Format == DXGI_FORMAT_UNKNOWN` (`0`) via `crate::resource::view_format(resource)` in `make()` for `View::Shader` and `View::Unordered` before `fits()`, keeping `R8G8B8A8_UNORM_SRGB` / `B8G8R8A8_UNORM_SRGB` (`29`/`91`) + `ALLOW_UNORDERED_ACCESS` views working as linear UAVs (`28`/`87`). ### Verification - Pre-fix reproduction on `main` (`ffe310e`): synthetic compute dispatch writing a placed texture UAV returned `[0, 0, 0, 0]` (`UNORDERED_ACCESS` transition also skipped). - Post-fix (`62946e6`, synthetic tests in `descriptor/host.rs` & `draw.rs` covering 16 placed UAV / 4 placed SRV descriptor cases, `D3DCompile` `cs_5_1` per-texel placed texture + placed buffer UAV readback, and `UNORDERED_ACCESS` -> `SHADER_RESOURCE` state transitions): - `cargo xtask policy`: pass (`154 files ok`) - `cargo clippy --workspace --all-targets --locked -- -D warnings` (default & `--all-features`): 0 warnings - `cargo test --workspace --locked` (NVIDIA GeForce RTX 5090, solo): pass (`victory-gpu`: `53 passed, 0 failed, 1 ignored`; all workspace crates pass) - `VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked`: `56 passed, 0 failed, 1 ignored` - `VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1 cargo test -p victory-gpu --features diagnostics --locked` (`placed_uav` & `compute_dispatch_writes_placed_texture_and_buffer_uavs`): `2 passed` + `1 passed` - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked` (with & without `VICTORY_D3D12_DEBUG=1`): `56 passed, 0 failed, 1 ignored` - Not directly run on AMD Radeon integrated graphics in this `main`-based checkout (upstream `main` does not yet have an adapter-selection env var).
Resolve `View::Placed(true, ...)` texture descriptors through
`placed_texture` to `View::Unordered` on the shared host texture for
that memory so placed unordered texture views bind real D3D12 UAVs and
transition to `UNORDERED_ACCESS` instead of falling back to null UAVs.

Refresh an already-mirrored placed texture slot when a later unordered
or renderable view upgrades that memory's `HostTexture`, and apply
`alias_source` copies to explicit SRVs superseded in `MEMORY` as well
as placed SRVs so compute writes at one guest address stay visible
regardless of view creation order.

Also resolve `DXGI_FORMAT_UNKNOWN` (`0`) view descriptions from
`resource::view_format` when the host copy is typeless or castable, and
check `typed_store` as well as typed-depth/typeless view exclusions in
`fits` before creating host SRVs/UAVs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:25:53 +00:00
github manually merged commit b5ea728110 into gh-pr/1273/base 2026-11-26 04:25:54 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 17:14 UTC · original

Independent check on 62946e6, RTX 4090 under Wine/GE 3.2. The authored compute-write and UAV-to-SRV transition tests passed. We also ran two guest compute dispatches in one list: the first writes a 2×2 RGBA8 texture, the second reads it through a placed SRV at the same guest address with the same resource description. We kept both resources live through readback.

First dispatch writes through What the second dispatch reads
A placed UAV [64, 0, 255, 255] at all four texels
A UAV on an explicitly created address-backed texture [0, 0, 0, 0] at all four texels

In the second case the fixture checked that the placed SRV resolved to a different host texture from the one the first dispatch wrote. A comparison build that resolves the placed SRV to the matching live object returned [64, 0, 255, 255] in both cases. This gives the explicit-object case its own regression target. Title use and address reuse remain open.

One separate portability result: the format matrix stopped at case 7 (B8G8R8X8_UNORM_SRGB, resource and view format 93). The mirrored slot retained a resource where the test expected none. The RGBA8 readbacks above used format 28. We did not dispatch through the format-93 view.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 17:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1273#issuecomment-7138895126) Independent check on `62946e6`, RTX 4090 under Wine/GE 3.2. The authored compute-write and UAV-to-SRV transition tests passed. We also ran two guest compute dispatches in one list: the first writes a 2×2 RGBA8 texture, the second reads it through a placed SRV at the same guest address with the same resource description. We kept both resources live through readback. | First dispatch writes through | What the second dispatch reads | | --- | --- | | A placed UAV | [64, 0, 255, 255] at all four texels | | A UAV on an explicitly created address-backed texture | [0, 0, 0, 0] at all four texels | In the second case the fixture checked that the placed SRV resolved to a different host texture from the one the first dispatch wrote. A comparison build that resolves the placed SRV to the matching live object returned [64, 0, 255, 255] in both cases. This gives the explicit-object case its own regression target. Title use and address reuse remain open. One separate portability result: the format matrix stopped at case 7 (`B8G8R8X8_UNORM_SRGB`, resource and view format 93). The mirrored slot retained a resource where the test expected none. The RGBA8 readbacks above used format 28. We did not dispatch through the format-93 view.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 17:26 UTC · original

@⁠fuzeofficlal The original placed-Hi-Z UAV comparator independently confirmed #921 on AMD, NVIDIA and WARP. Base binds a UINT null UAV for a FLOAT write and keeps the previous Hi-Z result even after the aliased input refreshes correctly. Your exact 62946e6 restores the updated Hi-Z value and reference indirect output on all three with full GPU validation. This isolates the separate placed-output defect.

**@⁠aycow** on GitHub · 2026-11-24 17:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1273#issuecomment-7139191811) @⁠fuzeofficlal The [original placed-Hi-Z UAV comparator](https://github.com/aycow/VIctory/blob/d2d80f682200302a2e3c97c4aa973fb1d16cbfa3/docs/placed-depth-hiz.md) independently confirmed #921 on AMD, NVIDIA and WARP. Base binds a UINT null UAV for a FLOAT write and keeps the previous Hi-Z result even after the aliased input refreshes correctly. Your exact `62946e6` restores the updated Hi-Z value and reference indirect output on all three with full GPU validation. This isolates the separate placed-output defect.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:20 UTC · original · edited 2026-11-25 16:17 UTC

Automated triage for the maintainers.

Recommended for a maintainer's look (not an approval). Rebased onto current main, it now merges cleanly. descriptor/host.rs::placed_texture() now maps View::Placed(true, ..) texture views to View::Unordered instead of dropping them to null UAVs (#921), fits() rejects depth/typeless view formats and unordered views in formats the host cannot store, make() resolves DXGI_FORMAT_UNKNOWN through resource::view_format, and HostHeap::mirror re-mirrors placed slots whose memory's host texture was replaced. draw::readable() now runs alias_copy for every SRV-kind View::Shader, not only placed ones. I checked these against main's fits, view_format and readable. The tests include a translated guest image_store through a placed UAV with host readback, which independent reports say fails on main and passes here (hardware and WARP). CI (check): passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1273#issuecomment-7149451409) · edited 2026-11-25 16:17 UTC <!-- victory-triage v1 head=b5ea7281109225790a2ac390dda676276cfed680 verdict=merge-candidate at=2026-11-25T16:20:00Z --> Automated triage for the maintainers. Recommended for a maintainer's look (not an approval). Rebased onto current `main`, it now merges cleanly. `descriptor/host.rs::placed_texture()` now maps `View::Placed(true, ..)` texture views to `View::Unordered` instead of dropping them to null UAVs (#921), `fits()` rejects depth/typeless view formats and unordered views in formats the host cannot store, `make()` resolves `DXGI_FORMAT_UNKNOWN` through `resource::view_format`, and `HostHeap::mirror` re-mirrors placed slots whose memory's host texture was replaced. `draw::readable()` now runs `alias_copy` for every SRV-kind `View::Shader`, not only placed ones. I checked these against `main`'s `fits`, `view_format` and `readable`. The tests include a translated guest `image_store` through a placed UAV with host readback, which independent reports say fails on `main` and passes here (hardware and WARP). CI (`check`): passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 05:16 UTC · original

Thanks @⁠MichaelSmithAI for the two-dispatch empirical test and the Wine/GE report — pushed d7ac61dc on 940d32f addressing both:

  1. Explicit UAV + placed SRV at the same guest address: 62946e6 predated 13bbd6f (one host texture per texture memory). On 940d32f, both create_at_address and texture_at resolve through shared_texture (MEMORY). Auditing all creation-order permutations also caught two ordering edge cases when a read-only (flags = 0) view is created or mirrored before a later UAV (flags = 4) upgrades MEMORY's HostTexture:
    • HostHeap::mirror now checks whether kept[index] still points at the current host_copy (texture or twin planes) and re-mirrors stale placed slots when MEMORY upgrades the backing texture.
    • draw::readable now runs alias_source / alias_copy on (View::Shader(resource, _), ResourceType::Srv) before title_written / upload, covering superseded explicit SRVs as well as placed SRVs.
    • Added explicit_and_placed_rgba8_textures_at_one_address_share_compute_writes testing all 4 pairing/ordering cases with the two-dispatch 2×2 R8G8B8A8_UNORM [64, 0, 255, 255] pattern across RTX 5090, AMD Radeon Graphics, and WARP under VICTORY_D3D12_DEBUG=1.
  2. Wine/GE B8G8R8X8 UAV capability (cases 7–10): placed_uav_textures_create_real_host_uavs now asserts against typed_store(88) instead of hardcoding false, matching implementations like vkd3d-proton that expose typed UAV stores on DXGI_FORMAT_B8G8R8X8_UNORM.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 05:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1273#issuecomment-7153606506) Thanks @⁠MichaelSmithAI for the two-dispatch empirical test and the Wine/GE report — pushed `d7ac61dc` on `940d32f` addressing both: 1. **Explicit UAV + placed SRV at the same guest address**: `62946e6` predated `13bbd6f` (`one host texture per texture memory`). On `940d32f`, both `create_at_address` and `texture_at` resolve through `shared_texture` (`MEMORY`). Auditing all creation-order permutations also caught two ordering edge cases when a read-only (`flags = 0`) view is created or mirrored *before* a later UAV (`flags = 4`) upgrades `MEMORY`'s `HostTexture`: - `HostHeap::mirror` now checks whether `kept[index]` still points at the current `host_copy` (`texture` or `twin` planes) and re-mirrors stale placed slots when `MEMORY` upgrades the backing texture. - `draw::readable` now runs `alias_source` / `alias_copy` on `(View::Shader(resource, _), ResourceType::Srv)` before `title_written` / `upload`, covering superseded explicit SRVs as well as placed SRVs. - Added `explicit_and_placed_rgba8_textures_at_one_address_share_compute_writes` testing all 4 pairing/ordering cases with the two-dispatch `2×2` `R8G8B8A8_UNORM` `[64, 0, 255, 255]` pattern across RTX 5090, AMD Radeon Graphics, and WARP under `VICTORY_D3D12_DEBUG=1`. 2. **Wine/GE `B8G8R8X8` UAV capability (`cases 7–10`)**: `placed_uav_textures_create_real_host_uavs` now asserts against `typed_store(88)` instead of hardcoding `false`, matching implementations like `vkd3d-proton` that expose typed UAV stores on `DXGI_FORMAT_B8G8R8X8_UNORM`.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 06:17 UTC · original

Independent WARP check of d7ac61dc73d18a46828d7f83cf16c2408e95e849 against 940d32f69b. I added the same existing guest image_store regression to both local builds. It creates the placed UAV, records and submits through VIctory, then reads back two RGBA32_FLOAT texels. Main returned two zero texels. Your updated head returned [1, 0.5, -0.25, 2] in the target and kept its neighbor zero.

The full WARP GPU suite with the diagnostic fixture was 146 passed, 1 failed (that regression), 2 ignored on main and 150 passed, 0 failed, 2 ignored on your head. The four creation-order cases in explicit_and_placed_rgba8_textures_at_one_address_share_compute_writes also passed with GPU-based validation enabled.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 06:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1273#issuecomment-7154636170) Independent WARP check of d7ac61dc73d18a46828d7f83cf16c2408e95e849 against 940d32f69b22265690a0b5a15d6ded572ba33baf. I added the same existing [guest image_store regression](https://github.com/andrewpozdnakov7-jpg/VIctory/blob/3a6b7e05cd6c9a1fd340361a54e2789dc1c38953/crates/victory-gpu/src/pipeline/placed_uav_tests.rs) to both local builds. It creates the placed UAV, records and submits through VIctory, then reads back two RGBA32_FLOAT texels. Main returned two zero texels. Your updated head returned [1, 0.5, -0.25, 2] in the target and kept its neighbor zero. The full WARP GPU suite with the diagnostic fixture was 146 passed, 1 failed (that regression), 2 ignored on main and 150 passed, 0 failed, 2 ignored on your head. The four creation-order cases in explicit_and_placed_rgba8_textures_at_one_address_share_compute_writes also passed with GPU-based validation enabled.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 06:37 UTC · original

I packaged the independent guest image_store regression as one test-only commit directly on d7ac61dc73d18a46828d7f83cf16c2408e95e849. 7d1a491

This adds guest shader translation, placed UAV creation and State::dispatch before RGBA32_FLOAT texture readback. On WARP, 940d32f left the target texel zero. Your head wrote [1, 0.5, -0.25, 2] and kept its neighbor zero. The full GPU suite on your head plus this fixture passed 150 tests with two ignored. GPU Clippy with diagnostics and staged asset policy passed.

If you take the commit, please keep andrewpozdnakov7-jpg as its author. If you fold the test into another commit, please use:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 06:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1273#issuecomment-7154994088) I packaged the independent guest image_store regression as one test-only commit directly on d7ac61dc73d18a46828d7f83cf16c2408e95e849. [7d1a491](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/7d1a4919e901139e5926f520eec1cde871fcedf9) This adds guest shader translation, placed UAV creation and State::dispatch before RGBA32_FLOAT texture readback. On WARP, 940d32f left the target texel zero. Your head wrote [1, 0.5, -0.25, 2] and kept its neighbor zero. The full GPU suite on your head plus this fixture passed 150 tests with two ignored. GPU Clippy with diagnostics and staged asset policy passed. If you take the commit, please keep andrewpozdnakov7-jpg as its author. If you fold the test into another commit, please use: Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 08:22 UTC · original

Thanks @⁠andrewpozdnakov7-jpg — this is the end-to-end coverage #921 was missing: a translated guest shader writing through a placed texture UAV, read back on the host. It fails on main (the texel stays zero) and passes on this branch on hardware and WARP. Your commit 7d1a491 is on the branch unchanged with your authorship; the only follow-up (52d210c) moves the mod placed_uav_tests; declaration next to the other pipeline submodules.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 08:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/1273#issuecomment-7156942072) Thanks @⁠andrewpozdnakov7-jpg — this is the end-to-end coverage #921 was missing: a translated guest shader writing through a placed texture UAV, read back on the host. It fails on main (the texel stays zero) and passes on this branch on hardware and WARP. Your commit 7d1a491 is on the branch unchanged with your authorship; the only follow-up (52d210c) moves the `mod placed_uav_tests;` declaration next to the other pipeline submodules.
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!1273
No description provided.