gpu: widen unsupported 16-bit render targets and UAVs to R8G8B8A8_UNORM #2767

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

@⁠narishaa on GitHub · 2026-11-25 20:07 UTC · original
narishaa:fix/nvidia-packed-16bit-targets → main · +327 −17 · 5 files · 1 commits · open

Summary

Rebased adaptation onto main (13f91ca) of #89 (by @⁠HenriqueSBueno, currently marked triage: needs rebase), addressing the DXGI_ERROR_INVALID_CALL (0x887A0001) device removal on NVIDIA GPUs reported in #2725 and #1753.

On NVIDIA (tested on RTX 3050, driver 32.0.16.2101), B4G4R4A4_UNORM (115) fails render-target creation and B5G5R5A1_UNORM (86) fails typed UAV creation/allocation queries:

  • CreateCommittedResource3 / CreateCommittedResource: D3D12_CLEAR_VALUE::Format / D3D12_RESOURCE_DESC::Format is B4G4R4A4_UNORM (id=817, id=599)
  • GetResourceAllocationInfo / CreateUnorderedAccessView: B5G5R5A1_UNORM (0x56) does not support typed UAVs (id=599, id=342)

Changes

  • Query CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT) once per packed 16-bit format (86, 115) via resource::target_format, widening render-target and unordered-access textures (and their clear values, RTVs, pipeline RT formats, and ResolveSubresource formats) to R8G8B8A8_UNORM (28) when unsupported. Sampled-only textures keep their native format.
  • Re-apply target_format in shared_texture after merging flags from aliased title textures at the same address so a sampled texture promoted to RENDER_TARGET/UNORDERED does not keep format 115/86.
  • Update descriptor::host::fits and resource::view_format so views of widened targets resolve to R8G8B8A8_UNORM.
  • Widen packed 16-bit buffer-to-texture CopyTextureRegion uploads in prepare_footprint_upload (while preserving list.defer_fill for unchanged footprints) and skip mixed packed/widened GPU-to-GPU copies/resolves.
  • Add unit tests for B5G5R5A1_UNORM / B4G4R4A4_UNORM row expansion.

Verification

Tested on Windows 10 (build 26200), Intel Core i7-9700KF, NVIDIA GeForce RTX 3050 (driver 32.0.16.2101), diagnostics build with VICTORY_D3D12_DEBUG=1:

  • Before (13f91ca): host GPU device removed (0x887A0001) ~12 s after the heap loop at frame ~52 with the 4 D3D12 errors above.
  • After: Both formats log packed 16-bit render targets are R8G8B8A8_UNORM on this GPU; title boots and runs past frame 1,024 at ~30 fps with zero no host texture or RemoveDevice errors.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: pass
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass
  • cargo xtask policy: pass (184 files ok)
  • cargo test -p victory-gpu --locked: 194 passed, 2 failed (the pre-existing NVIDIA 1,000,000-view heap-cap assertions dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views from #1835), 1 ignored.

Related: #2725, #1753, #89.

**@⁠narishaa** on GitHub · 2026-11-25 20:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/2767) `narishaa:fix/nvidia-packed-16bit-targets` → `main` · +327 −17 · 5 files · 1 commits · open ## Summary Rebased adaptation onto `main` (`13f91ca`) of #89 (by @⁠HenriqueSBueno, currently marked `triage: needs rebase`), addressing the `DXGI_ERROR_INVALID_CALL` (`0x887A0001`) device removal on NVIDIA GPUs reported in #2725 and #1753. On NVIDIA (tested on RTX 3050, driver `32.0.16.2101`), `B4G4R4A4_UNORM` (115) fails render-target creation and `B5G5R5A1_UNORM` (86) fails typed UAV creation/allocation queries: - `CreateCommittedResource3` / `CreateCommittedResource`: `D3D12_CLEAR_VALUE::Format` / `D3D12_RESOURCE_DESC::Format is B4G4R4A4_UNORM` (`id=817`, `id=599`) - `GetResourceAllocationInfo` / `CreateUnorderedAccessView`: `B5G5R5A1_UNORM` (`0x56`) does not support typed UAVs (`id=599`, `id=342`) ## Changes - Query `CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT)` once per packed 16-bit format (`86`, `115`) via `resource::target_format`, widening render-target and unordered-access textures (and their clear values, RTVs, pipeline RT formats, and `ResolveSubresource` formats) to `R8G8B8A8_UNORM` (28) when unsupported. Sampled-only textures keep their native format. - Re-apply `target_format` in `shared_texture` after merging flags from aliased title textures at the same address so a sampled texture promoted to `RENDER_TARGET`/`UNORDERED` does not keep format `115`/`86`. - Update `descriptor::host::fits` and `resource::view_format` so views of widened targets resolve to `R8G8B8A8_UNORM`. - Widen packed 16-bit buffer-to-texture `CopyTextureRegion` uploads in `prepare_footprint_upload` (while preserving `list.defer_fill` for unchanged footprints) and skip mixed packed/widened GPU-to-GPU copies/resolves. - Add unit tests for `B5G5R5A1_UNORM` / `B4G4R4A4_UNORM` row expansion. ## Verification Tested on Windows 10 (build 26200), Intel Core i7-9700KF, NVIDIA GeForce RTX 3050 (driver `32.0.16.2101`), diagnostics build with `VICTORY_D3D12_DEBUG=1`: - **Before (`13f91ca`):** `host GPU device removed` (`0x887A0001`) ~12 s after the heap loop at frame ~52 with the 4 D3D12 errors above. - **After:** Both formats log `packed 16-bit render targets are R8G8B8A8_UNORM on this GPU`; title boots and runs past frame 1,024 at ~30 fps with zero `no host texture` or `RemoveDevice` errors. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: pass - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: pass - `cargo xtask policy`: pass (184 files ok) - `cargo test -p victory-gpu --locked`: 194 passed, 2 failed (the pre-existing NVIDIA 1,000,000-view heap-cap assertions `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views` from #1835), 1 ignored. Related: #2725, #1753, #89.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:13:46 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 20:27 UTC · original

Reviewed and tested f307c7fc on Windows 11 + NVIDIA GeForce RTX 5090 + WARP against main (13f91ca).

Hardware check & code review

On RTX 5090, B5G5R5A1_UNORM (86) reports RT = true, UAV = false and B4G4R4A4_UNORM (115) reports RT = false, UAV = false, so both hit the widening path to R8G8B8A8_UNORM (28) when RENDER_TARGET | UNORDERED is set (prepare_footprint_upload, expand_packed16_rows, descriptor::host::fits, RtvRecord, PSO RTFormats, clear values, and ResolveSubresource format all line up cleanly).

Three remaining gaps worth noting on mixed widened/native paths:

  1. read_back (list.rs:941-980): copying from a widened R8G8B8A8_UNORM target back to a 115/86 (2-byte/texel) FOOTPRINT buffer still issues a direct CopyTextureRegion with mismatched texture/footprint formats (28 vs 115/86), which D3D12 rejects.
  2. alias_copy (texture.rs:253-332): alias_source (resource.rs:1974) compares guest r.desc element sizes (both (2, 1)), so copying between a widened target (28, 4B/texel) and a native 16-bit sampled alias (115/86, 2B/texel) copies through a 2B/texel footprint and corrupts data/dimensions.
  3. Mixed texture copies/resolves (skip_mixed_packed_copy) & B5G5R5A1 RT-only: CopyResource / CopyTextureRegion / ResolveSubresource between a native 16-bit sampled texture and a widened 28 target are silently dropped; and because host_lacks_target requires both RENDER_TARGET and TYPED_UNORDERED_ACCESS_VIEW, even RT-only B5G5R5A1 textures are widened on RTX 5090 despite native RT support (compare #89 for companion/compute conversion on mixed copies).

Verification (Windows 11, RTX 5090 + WARP)

  • RTX 5090 (--features diagnostics): resource::tests 18/18 passed (including packed_16_expansion_matches_dxgi_layout); full --test-threads=1 197 passed, 2 failed (only the 2 pre-existing RTX 5090 >1M heap-cap baselines).
  • WARP (VICTORY_D3D12_WARP=1, --features diagnostics --test-threads=1): 199 passed, 0 failed, 1 ignored.
  • cargo clippy (default & diagnostics): 0 warnings; cargo xtask policy: 184 files ok.
  • Merge-tree: clean vs 13f91ca and #2773 (semantically mutually exclusive); conflicts with #89 and #2679.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 20:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2767#issuecomment-7173702407) Reviewed and tested `f307c7fc` on Windows 11 + NVIDIA GeForce RTX 5090 + WARP against `main` (`13f91ca`). ### Hardware check & code review On RTX 5090, `B5G5R5A1_UNORM (86)` reports `RT = true, UAV = false` and `B4G4R4A4_UNORM (115)` reports `RT = false, UAV = false`, so both hit the widening path to `R8G8B8A8_UNORM (28)` when `RENDER_TARGET | UNORDERED` is set (`prepare_footprint_upload`, `expand_packed16_rows`, `descriptor::host::fits`, `RtvRecord`, PSO `RTFormats`, clear values, and `ResolveSubresource` format all line up cleanly). Three remaining gaps worth noting on mixed widened/native paths: 1. **`read_back` (`list.rs:941-980`)**: copying from a widened `R8G8B8A8_UNORM` target back to a `115`/`86` (2-byte/texel) `FOOTPRINT` buffer still issues a direct `CopyTextureRegion` with mismatched texture/footprint formats (`28` vs `115`/`86`), which D3D12 rejects. 2. **`alias_copy` (`texture.rs:253-332`)**: `alias_source` (`resource.rs:1974`) compares guest `r.desc` element sizes (both `(2, 1)`), so copying between a widened target (`28`, 4B/texel) and a native 16-bit sampled alias (`115`/`86`, 2B/texel) copies through a 2B/texel footprint and corrupts data/dimensions. 3. **Mixed texture copies/resolves (`skip_mixed_packed_copy`) & `B5G5R5A1` RT-only**: `CopyResource` / `CopyTextureRegion` / `ResolveSubresource` between a native 16-bit sampled texture and a widened `28` target are silently dropped; and because `host_lacks_target` requires both `RENDER_TARGET` and `TYPED_UNORDERED_ACCESS_VIEW`, even RT-only `B5G5R5A1` textures are widened on RTX 5090 despite native RT support (compare `#89` for companion/compute conversion on mixed copies). ### Verification (Windows 11, RTX 5090 + WARP) - **RTX 5090 (`--features diagnostics`)**: `resource::tests` **18/18 passed** (including `packed_16_expansion_matches_dxgi_layout`); full `--test-threads=1` **197 passed, 2 failed** (only the 2 pre-existing RTX 5090 >1M heap-cap baselines). - **WARP (`VICTORY_D3D12_WARP=1`, `--features diagnostics --test-threads=1`)**: **199 passed, 0 failed, 1 ignored**. - `cargo clippy` (default & `diagnostics`): **0 warnings**; `cargo xtask policy`: **184 files ok**. - Merge-tree: clean vs `13f91ca` and `#2773` (semantically mutually exclusive); conflicts with `#89` and `#2679`.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 20:38 UTC · original

Correct bit-replication expansion (5->8 as v<<3|v>>2, 4->8 as v<<4|v, A1 -> 0/255) and the widening is applied at every seam that names a format: RTV record, view fits(), resolve formats, and both copy entry points guarded by skip_mixed_packed_copy for cross-element cases. Relates to #2442 (which drops UNORDERED on unviewable formats): this widens 86/115 to RGBA8 so the views become legal - complementary, and once both land the flag survives where it can.

**@⁠kotekompotek** on GitHub · 2026-11-25 20:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2767#issuecomment-7173970128) Correct bit-replication expansion (5->8 as v<<3|v>>2, 4->8 as v<<4|v, A1 -> 0/255) and the widening is applied at every seam that names a format: RTV record, view fits(), resolve formats, and both copy entry points guarded by skip_mixed_packed_copy for cross-element cases. Relates to #2442 (which drops UNORDERED on unviewable formats): this widens 86/115 to RGBA8 so the views become legal - complementary, and once both land the flag survives where it can.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 20:58 UTC · original

Independent WARP/CPU verification of f307c7fc (#2767).

Review: Packed 16-bit render targets and UAVs become R8G8B8A8_UNORM only where the host lacks support (host_lacks_target, queried once per format). The change is applied consistently in host_desc, shared_texture, clear values, RTVs, pipeline RT formats, view-format checks, and resolve. Copies mixing a native packed texture with a widened one are skipped with a once-only warning. Buffer-to-texture footprint copies expand texels on the CPU into a widened upload buffer with a 256-byte pitch. The bit replication for B5G5R5A1 and B4G4R4A4 is right (hand-checked 0xffff and the mixed value). Two notes, neither blocking:

  • A source comment in resource.rs names the specific title. #1633 rule 7 is about files, dumps, shader names and hashes, so this is probably fine, but you may prefer a generic wording.
  • The tests only cover the CPU expansion. Nothing exercises the widened upload path, the format-selection logic or the mixed-copy skip. On this WARP setup I did not confirm that host_lacks_target ever returns true, so the GPU-side behaviour is unverified here and needs a GPU that lacks the formats.

Results (WARP/CPU):

  • origin/main: cargo test -p victory-gpu --lib: 195 passed, 0 failed.
  • PR: 196 passed, 0 failed.
  • cargo clippy --locked -p victory-gpu --all-targets [--all-features] -- -D warnings: clean. cargo test -p xtask (policy): 6 passed.

Negative control (mutating the PR head): removing the bit replication for the 5-bit channels, or the alpha replication in the 4-bit format, makes packed_16_expansion_matches_dxgi_layout fail. The expansion test catches those.

Method: no physical GPU. VICTORY_WARP=1, VICTORY_D3D12_WARP=1, Windows SDK 10.0.26100 dxil.dll on PATH, Windows 11, rustc 1.98.1 MSVC, --locked. Compared origin/main (13f91ca) with the PR head. The PR merges cleanly onto that main. No game files, dumps, shader names or retail hashes were used or are needed.

AI disclosure: this verification was done by Claude Code / Claude Sonnet 5.5.

**@⁠oni-swr** on GitHub · 2026-11-25 20:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2767#issuecomment-7174433347) Independent WARP/CPU verification of `f307c7fc` (#2767). **Review:** Packed 16-bit render targets and UAVs become R8G8B8A8_UNORM only where the host lacks support (`host_lacks_target`, queried once per format). The change is applied consistently in `host_desc`, `shared_texture`, clear values, RTVs, pipeline RT formats, view-format checks, and resolve. Copies mixing a native packed texture with a widened one are skipped with a once-only warning. Buffer-to-texture footprint copies expand texels on the CPU into a widened upload buffer with a 256-byte pitch. The bit replication for B5G5R5A1 and B4G4R4A4 is right (hand-checked 0xffff and the mixed value). Two notes, neither blocking: - A source comment in `resource.rs` names the specific title. #1633 rule 7 is about files, dumps, shader names and hashes, so this is probably fine, but you may prefer a generic wording. - The tests only cover the CPU expansion. Nothing exercises the widened upload path, the format-selection logic or the mixed-copy skip. On this WARP setup I did not confirm that `host_lacks_target` ever returns true, so the GPU-side behaviour is unverified here and needs a GPU that lacks the formats. **Results (WARP/CPU):** - `origin/main`: `cargo test -p victory-gpu --lib`: 195 passed, 0 failed. - PR: 196 passed, 0 failed. - `cargo clippy --locked -p victory-gpu --all-targets [--all-features] -- -D warnings`: clean. `cargo test -p xtask` (policy): 6 passed. **Negative control (mutating the PR head):** removing the bit replication for the 5-bit channels, or the alpha replication in the 4-bit format, makes `packed_16_expansion_matches_dxgi_layout` fail. The expansion test catches those. Method: no physical GPU. `VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`, Windows SDK 10.0.26100 `dxil.dll` on `PATH`, Windows 11, rustc 1.98.1 MSVC, `--locked`. Compared `origin/main` (`13f91ca`) with the PR head. The PR merges cleanly onto that main. No game files, dumps, shader names or retail hashes were used or are needed. AI disclosure: this verification was done by Claude Code / Claude Sonnet 5.5.
Author
Owner

@⁠artor410 on GitHub · 2026-11-25 21:53 UTC · original

Tested on RTX 3070 Ti, driver 610.88, Windows 11 26300, rustc 1.98.1. main 13f91ca. Head f307c7f (fast-forward on main).

  • cargo test -p victory-gpu (main: 193 passed, 2 failed: the known heap-cap pair dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views). With this PR: 194 passed, same 2 failed. New packed_16_expansion_matches_dxgi_layout passes.
  • Probe (temporary test, not committed): 256x256 texture via create_placed with the UAV and/or RT flag, then descriptor::host::make_view(View::Unordered(..)) and Host::rtv(texture, None), then GetDeviceRemovedReason, one process per case. On main: UAV view of 86 or 115 crashes the test process (0xc0000005 inside the driver); RTV of 115 removes the device (0x887A0001); 115 with RT|UAV gets no host texture. CheckFeatureSupport here: 86 RT yes, typed UAV no; 115 RT no, typed UAV no.
  • With this PR: every case safe and the views are made. 86 and 115 textures become R8G8B8A8 (28); UAV views made for 86 (UAV, RT|UAV) and 115 (RT|UAV); RTVs of 115 made; device not removed.

Covers both formats and both uses, and keeps the writes. Same approach as #89 and as the VItoriaBr fork, which reaches the world on an RTX 5060 Ti. Probe calls Host::rtv directly, not set_targets; untested in-game here.

(Claude Code, Claude Opus 5.5.)

**@⁠artor410** on GitHub · 2026-11-25 21:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2767#issuecomment-7175665893) Tested on RTX 3070 Ti, driver 610.88, Windows 11 26300, rustc 1.98.1. main 13f91ca. Head f307c7f (fast-forward on main). - `cargo test -p victory-gpu` (main: 193 passed, 2 failed: the known heap-cap pair `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`). With this PR: 194 passed, same 2 failed. New `packed_16_expansion_matches_dxgi_layout` passes. - Probe (temporary test, not committed): 256x256 texture via `create_placed` with the UAV and/or RT flag, then `descriptor::host::make_view(View::Unordered(..))` and `Host::rtv(texture, None)`, then `GetDeviceRemovedReason`, one process per case. On main: UAV view of 86 or 115 crashes the test process (0xc0000005 inside the driver); RTV of 115 removes the device (0x887A0001); 115 with RT|UAV gets no host texture. `CheckFeatureSupport` here: 86 RT yes, typed UAV no; 115 RT no, typed UAV no. - With this PR: every case safe and the views are made. 86 and 115 textures become R8G8B8A8 (28); UAV views made for 86 (UAV, RT|UAV) and 115 (RT|UAV); RTVs of 115 made; device not removed. Covers both formats and both uses, and keeps the writes. Same approach as #89 and as the VItoriaBr fork, which reaches the world on an RTX 5060 Ti. Probe calls `Host::rtv` directly, not `set_targets`; untested in-game here. (Claude Code, Claude Opus 5.5.)
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:21 UTC · original

Automated triage for the maintainers.

The approach is sound and well evidenced (debug-layer errors and CheckFeatureSupport results on NVIDIA, plus hardware reports in the thread): resource::target_format widens B5G5R5A1/B4G4R4A4 render-target and UAV textures to R8G8B8A8_UNORM where the GPU lacks the support, and the format is applied consistently in host_desc, shared_texture, clear values, RtvRecord::host_desc, pipeline RT formats, descriptor::host::fits and resolve. Buffer-to-texture copies are expanded in list.rs prepare_footprint_upload, and the bit replication in unpack_16 is right. Some paths that now reach a widened texture still assume 2 bytes per texel:

  • list.rs read_back: a texture-to-footprint copy from a widened texture into a B5G5R5A1/B4G4R4A4 footprint calls CopyTextureRegion with a 4-byte texture and a 2-byte footprint format. D3D12 rejects that, so it needs packing on the way back or a refusal.
  • texture.rs staging/upload: footprints come from the host description (RGBA8) while the detiled title memory is 2 bytes per texel, so a title-written widened texture would be uploaded with the wrong layout.
  • texture.rs alias_copy (via resource::alias_source) compares the guest element sizes, which are equal, so a widened target and a native sampled alias of the same memory are copied as if they had the same layout.
  • host_lacks_target widens when either support bit is missing, so on NVIDIA a B5G5R5A1 texture that is only a render target is widened even though the GPU renders to it natively. Checking only the support each texture's flags need would keep more textures native.

This also overlaps #89 (the original of this change, credited in the description) and takes a different approach from #2773 (drop the uses the device refuses). A maintainer should choose one direction. Minor: the host_lacks_target doc comment could describe the targets generically. CI (check) passes. Handling or explicitly refusing the three copy paths above would make this a merge candidate.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2767#issuecomment-7177445501) <!-- victory-triage v1 head=f307c7fcb82c8c972d3cc4f8c1de13361d342456 verdict=needs-work at=2026-11-25T23:21:06Z --> Automated triage for the maintainers. The approach is sound and well evidenced (debug-layer errors and `CheckFeatureSupport` results on NVIDIA, plus hardware reports in the thread): `resource::target_format` widens B5G5R5A1/B4G4R4A4 render-target and UAV textures to R8G8B8A8_UNORM where the GPU lacks the support, and the format is applied consistently in `host_desc`, `shared_texture`, clear values, `RtvRecord::host_desc`, pipeline RT formats, `descriptor::host::fits` and resolve. Buffer-to-texture copies are expanded in `list.rs` `prepare_footprint_upload`, and the bit replication in `unpack_16` is right. Some paths that now reach a widened texture still assume 2 bytes per texel: - `list.rs` `read_back`: a texture-to-footprint copy from a widened texture into a B5G5R5A1/B4G4R4A4 footprint calls `CopyTextureRegion` with a 4-byte texture and a 2-byte footprint format. D3D12 rejects that, so it needs packing on the way back or a refusal. - `texture.rs` `staging`/`upload`: footprints come from the host description (RGBA8) while the detiled title memory is 2 bytes per texel, so a title-written widened texture would be uploaded with the wrong layout. - `texture.rs` `alias_copy` (via `resource::alias_source`) compares the guest element sizes, which are equal, so a widened target and a native sampled alias of the same memory are copied as if they had the same layout. - `host_lacks_target` widens when either support bit is missing, so on NVIDIA a B5G5R5A1 texture that is only a render target is widened even though the GPU renders to it natively. Checking only the support each texture's flags need would keep more textures native. This also overlaps #89 (the original of this change, credited in the description) and takes a different approach from #2773 (drop the uses the device refuses). A maintainer should choose one direction. Minor: the `host_lacks_target` doc comment could describe the targets generically. CI (`check`) passes. Handling or explicitly refusing the three copy paths above would make this a merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠potatoe0100 on GitHub · 2026-11-26 14:45 UTC · original

RTX 4060 8 GB (Ada), driver 621.14, Windows 11 Pro 26300. Head f307c7f merged onto main 63bcca4 (clean).

cargo test -p victory-gpu --lib --locked -- --test-threads=1: 230 passed, 2 failed. The 2 failures are the heap-cap pair that also fails on main here (fixed by #2461). Nothing new fails.

The triage's first copy path (read_back) is a crash, not just a bad copy. I used a scratch test (below) that writes a 4x4 texture from a title buffer through our list, reads it back into a footprint of the texture's own format, then submits.

texture main + this PR
115 (B4G4R4A4), render target 4/4 rows round-trip process aborts (0xc0000409)
86 (B5G5R5A1), unordered access 4/4 rows round-trip process aborts (0xc0000409)
86, render target only 4/4 rows round-trip process aborts (0xc0000409)

The upload half alone (prepare_footprint_upload) records, closes and runs fine with this PR. Adding the texture-to-footprint copy makes the process abort when the list is closed. That's because read_back records CopyTextureRegion from the widened R8G8B8A8 texture into a footprint that still names 86 or 115. A title that reads one of these targets back would then crash the process, where it used to work.

So read_back needs one of two things: a widened read (an R8G8B8A8 footprint, then packing the texels back into 2 bytes on the CPU when the readback is copied to the title), or a refusal with a warning, like the mixed GPU copies. The last row also shows the triage's fourth point. On this card 86 is widened even when it's only a render target, because host_lacks_target asks for both supports at once.

Scratch test (in resource.rs tests, next to a_texture_read_back_reaches_the_title_buffer)
#[cfg(windows)]
fn packed_round_trip(format: u32, flags: u32) {
    let Some(host) = crate::host::host() else { return };
    let null = std::ptr::null();
    let iid = &RESOURCE_IIDS[0];
    let created = |desc: &ResourceDesc, state, out: &mut This| {
        create_committed(null, &PROPERTIES, 0, desc, state, null.cast(), iid, out)
    };
    let (mut image, mut source, mut target) = (null, null, null);
    let mut d = texture(4, 4, format, 1);
    d.flags = flags; // 1 render target, 4 unordered access
    assert_eq!(created(&d, 0x400, &mut image), S_OK);
    assert_eq!(created(&buffer(1024), 0, &mut source), S_OK);
    assert_eq!(created(&buffer(4096), 0, &mut target), S_OK);
    let (data, _) = buffer_bytes(source).unwrap();
    let bytes = unsafe { std::slice::from_raw_parts_mut(data, 1024) };
    for (i, b) in bytes.iter_mut().enumerate() { *b = (i * 7 % 251) as u8; }
    let (out, _) = buffer_bytes(target).unwrap();
    unsafe { std::ptr::write_bytes(out, 0xEE, 4096) };
    // queue, allocator and list made as in a_texture_read_back_reaches_the_title_buffer
    let rows = PlacedFootprint { offset: 0, format, width: 4, height: 4, depth: 1, row_pitch: 256 };
    let image_at = Location { resource: image, kind: 0, footprint: rows };
    let from_source = Location { resource: source, kind: 1, footprint: rows };
    let into_target = Location { resource: target, kind: 1, footprint: PlacedFootprint { offset: 512, ..rows } };
    let copy = slot::<Copy>(list, 0x80);
    copy(list, &image_at, 0, 0, 0, &from_source, null.cast());
    copy(list, &into_target, 0, 0, 0, &image_at, null.cast()); // without this line it runs fine
    slot::<extern "system" fn(This) -> HRESULT>(list, 0x48)(list); // aborts here with the PR
    slot::<extern "system" fn(This, u32, *const This)>(queue, 0x50)(queue, 1, &list);
    assert!(unsafe { host.device.GetDeviceRemovedReason() }.is_ok());
    let read = unsafe { std::slice::from_raw_parts(out, 4096) };
    for row in 0..4 { assert_eq!(read[512 + row * 256..][..8], bytes[row * 256..][..8], "row {row}"); }
}

I didn't check the other two paths the triage names (texture.rs upload of title-written data, and alias_copy).

AI-assisted (Claude). Unit tests only, no game data.

**@⁠potatoe0100** on GitHub · 2026-11-26 14:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/2767#issuecomment-7195273877) RTX 4060 8 GB (Ada), driver 621.14, Windows 11 Pro 26300. Head `f307c7f` merged onto `main` `63bcca4` (clean). `cargo test -p victory-gpu --lib --locked -- --test-threads=1`: 230 passed, 2 failed. The 2 failures are the heap-cap pair that also fails on `main` here (fixed by #2461). Nothing new fails. **The triage's first copy path (`read_back`) is a crash, not just a bad copy.** I used a scratch test (below) that writes a 4x4 texture from a title buffer through our list, reads it back into a footprint of the texture's own format, then submits. | texture | `main` | + this PR | |---|---|---| | 115 (B4G4R4A4), render target | 4/4 rows round-trip | process aborts (`0xc0000409`) | | 86 (B5G5R5A1), unordered access | 4/4 rows round-trip | process aborts (`0xc0000409`) | | 86, render target only | 4/4 rows round-trip | process aborts (`0xc0000409`) | The upload half alone (`prepare_footprint_upload`) records, closes and runs fine with this PR. Adding the texture-to-footprint copy makes the process abort when the list is closed. That's because `read_back` records `CopyTextureRegion` from the widened R8G8B8A8 texture into a footprint that still names 86 or 115. A title that reads one of these targets back would then crash the process, where it used to work. So `read_back` needs one of two things: a widened read (an R8G8B8A8 footprint, then packing the texels back into 2 bytes on the CPU when the readback is copied to the title), or a refusal with a warning, like the mixed GPU copies. The last row also shows the triage's fourth point. On this card 86 is widened even when it's only a render target, because `host_lacks_target` asks for both supports at once. <details><summary>Scratch test (in <code>resource.rs</code> tests, next to <code>a_texture_read_back_reaches_the_title_buffer</code>)</summary> ```rust #[cfg(windows)] fn packed_round_trip(format: u32, flags: u32) { let Some(host) = crate::host::host() else { return }; let null = std::ptr::null(); let iid = &RESOURCE_IIDS[0]; let created = |desc: &ResourceDesc, state, out: &mut This| { create_committed(null, &PROPERTIES, 0, desc, state, null.cast(), iid, out) }; let (mut image, mut source, mut target) = (null, null, null); let mut d = texture(4, 4, format, 1); d.flags = flags; // 1 render target, 4 unordered access assert_eq!(created(&d, 0x400, &mut image), S_OK); assert_eq!(created(&buffer(1024), 0, &mut source), S_OK); assert_eq!(created(&buffer(4096), 0, &mut target), S_OK); let (data, _) = buffer_bytes(source).unwrap(); let bytes = unsafe { std::slice::from_raw_parts_mut(data, 1024) }; for (i, b) in bytes.iter_mut().enumerate() { *b = (i * 7 % 251) as u8; } let (out, _) = buffer_bytes(target).unwrap(); unsafe { std::ptr::write_bytes(out, 0xEE, 4096) }; // queue, allocator and list made as in a_texture_read_back_reaches_the_title_buffer let rows = PlacedFootprint { offset: 0, format, width: 4, height: 4, depth: 1, row_pitch: 256 }; let image_at = Location { resource: image, kind: 0, footprint: rows }; let from_source = Location { resource: source, kind: 1, footprint: rows }; let into_target = Location { resource: target, kind: 1, footprint: PlacedFootprint { offset: 512, ..rows } }; let copy = slot::<Copy>(list, 0x80); copy(list, &image_at, 0, 0, 0, &from_source, null.cast()); copy(list, &into_target, 0, 0, 0, &image_at, null.cast()); // without this line it runs fine slot::<extern "system" fn(This) -> HRESULT>(list, 0x48)(list); // aborts here with the PR slot::<extern "system" fn(This, u32, *const This)>(queue, 0x50)(queue, 1, &list); assert!(unsafe { host.device.GetDeviceRemovedReason() }.is_ok()); let read = unsafe { std::slice::from_raw_parts(out, 4096) }; for row in 0..4 { assert_eq!(read[512 + row * 256..][..8], bytes[row * 256..][..8], "row {row}"); } } ``` </details> I didn't check the other two paths the triage names (`texture.rs` upload of title-written data, and `alias_copy`). AI-assisted (Claude). Unit tests only, no game data.
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/2767/head:github-bot/gh-2767'
git switch 'github-bot/gh-2767'

Merge

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