runtime: stage CopyResource into partial BC mip tails #2167

Closed
timbot103 wants to merge 1 commit from upstream-pr/2167 into main
timbot103 commented 2026-11-26 01:08:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-26T01:08:34Z.


Claimed in the coordination issue as: D3D-COPYRESOURCE-BC-MIP-TAIL

What and why

Native D3D12 WARP accepts a four-mip CopyResource from an 8×1 R32G32_UINT texture into a 32×4 BC1_UNORM texture. At mip 1, the destination is only two texels high and the source still supplies a complete BC block. Vulkan replay previously rejected the whole command as invalid_copy.

Replay now checks that all source blocks fit before choosing how to copy. If any write reaches a partial BC edge, it stages every mip and array layer through one transfer buffer. The read and write use their own physical extents. Fully fitting copies keep the direct vkCmdCopyImage path, and a lower mip may still leave destination blocks untouched.

Tested

  • d3d12_copy_xfmt_test compared BC1 and BC7, both orientations, four mips, and one or two array layers. Each GPU matched native WARP and the synthetic upload in all eight cases, across 48 subresources and 2,160 payload bytes per run. On the original runtime, both GPUs returned invalid_copy for all eight while WARP matched every payload.
  • replay_copy_offset_test checks the actual transfer regions, scratch offsets, write-to-read barrier, allocation failures, overflow, direct copies, oversized reverse copies, and existing image-copy predication behavior.
  • 20 copy and replay test executables passed on each adapter with Khronos validation and synchronization validation off and on. Across 80 invocations there were zero Vulkan validation errors. The clean MSVC build linked gta6rt and introduced zero warnings over the baseline.

GPUs tested: NVIDIA GeForce RTX 5080 (616.64) and AMD Radeon(TM) Graphics (25.10.30.02), Windows 11 Pro build 26200. Native reference: Microsoft Basic Render Driver (retail WARP).

AI-assisted: yes (Gemini, Codex)

Checklist

  • Based on current main (f1afede5e) and merges cleanly.
  • One topic.
  • No game data, keys or decryption. The changed-file and full tracked-tree scans passed.
  • Translator contract table — not applicable to this runtime change.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5502056736 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2167). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-26T01:08:34Z. --- Claimed in the coordination issue as: [D3D-COPYRESOURCE-BC-MIP-TAIL](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7179120159) ### What and why Native D3D12 WARP accepts a four-mip `CopyResource` from an 8×1 `R32G32_UINT` texture into a 32×4 `BC1_UNORM` texture. At mip 1, the destination is only two texels high and the source still supplies a complete BC block. Vulkan replay previously rejected the whole command as `invalid_copy`. Replay now checks that all source blocks fit before choosing how to copy. If any write reaches a partial BC edge, it stages every mip and array layer through one transfer buffer. The read and write use their own physical extents. Fully fitting copies keep the direct `vkCmdCopyImage` path, and a lower mip may still leave destination blocks untouched. ### Tested - `d3d12_copy_xfmt_test` compared BC1 and BC7, both orientations, four mips, and one or two array layers. Each GPU matched native WARP and the synthetic upload in all eight cases, across 48 subresources and 2,160 payload bytes per run. On the original runtime, both GPUs returned `invalid_copy` for all eight while WARP matched every payload. - `replay_copy_offset_test` checks the actual transfer regions, scratch offsets, write-to-read barrier, allocation failures, overflow, direct copies, oversized reverse copies, and existing image-copy predication behavior. - 20 copy and replay test executables passed on each adapter with Khronos validation and synchronization validation off and on. Across 80 invocations there were zero Vulkan validation errors. The clean MSVC build linked `gta6rt` and introduced zero warnings over the baseline. GPUs tested: NVIDIA GeForce RTX 5080 (616.64) and AMD Radeon(TM) Graphics (25.10.30.02), Windows 11 Pro build 26200. Native reference: Microsoft Basic Render Driver (retail WARP). AI-assisted: yes (Gemini, Codex) ### Checklist - [x] Based on current `main` (`f1afede5e`) and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. The changed-file and full tracked-tree scans passed. - [x] Translator contract table — not applicable to this runtime change.
moffington commented 2026-11-26 01:31:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by moffington on 2026-11-26T01:31:03Z.


Checked dddf9ad7 on Linux (AMD Ryzen 5 5600X3D, g++ 16.2.1) and Windows/Wine (clang-cl 23.1.3 + xwin SDK 10.0.26100):

  • replay_copy_offset_test passes on Linux (RelWithDebInfo and ASan+UBSan) and under Wine. Against base (f1afede5), all 13 new BC mip-tail staging/validation assertions fail.
  • d3d12_copy_xfmt_test.exe compiles cleanly with clang-cl + xwin and skips as expected under Wine (exit 77, host_is_wine()), so the live GPU WARP comparison was not run on this host.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7179849572 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2167#issuecomment-7179849572). Originally posted by [moffington](https://github.com/moffington) on 2026-11-26T01:31:03Z. --- Checked `dddf9ad7` on Linux (AMD Ryzen 5 5600X3D, `g++ 16.2.1`) and Windows/Wine (`clang-cl 23.1.3` + `xwin` SDK 10.0.26100): - `replay_copy_offset_test` passes on Linux (`RelWithDebInfo` and ASan+UBSan) and under Wine. Against base (`f1afede5`), all 13 new BC mip-tail staging/validation assertions fail. - `d3d12_copy_xfmt_test.exe` compiles cleanly with `clang-cl` + `xwin` and skips as expected under Wine (`exit 77`, `host_is_wine()`), so the live GPU WARP comparison was not run on this host. AI-assisted.

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
ProjectLeonida/mandy!2167
No description provided.