[PR #2167] runtime: stage CopyResource into partial BC mip tails #2172

Open
opened 2026-11-26 21:20:17 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2167
Author: @timbot103
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: d3d-copyresource-bc-mip-tail


📝 Commits (1)

  • dddf9ad runtime: stage CopyResource into partial BC mip tails

📊 Changes

4 files changed (+297 additions, -29 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+3 -0)
📝 runtime/src/vulkan_replay.h (+51 -12)
📝 runtime/test/d3d12_copy_xfmt_test.cpp (+105 -17)
📝 runtime/test/replay_copy_offset_test.cpp (+138 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2167 **Author:** [@timbot103](https://github.com/timbot103) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `d3d-copyresource-bc-mip-tail` --- ### 📝 Commits (1) - [`dddf9ad`](https://github.com/ubiquitarianism/leonida/commit/dddf9ad7cb2badc77383ad98ddea685ebd000f12) runtime: stage CopyResource into partial BC mip tails ### 📊 Changes **4 files changed** (+297 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+3 -0) 📝 `runtime/src/vulkan_replay.h` (+51 -12) 📝 `runtime/test/d3d12_copy_xfmt_test.cpp` (+105 -17) 📝 `runtime/test/replay_copy_offset_test.cpp` (+138 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#2172
No description provided.