Skip to content

Runtime: copy whole resources across partial BC mip edges - #7068

Open
mrb-eel wants to merge 1 commit into
ItsNotRexed:mainfrom
mrb-eel:fix/copy-resource-bc-tail
Open

mrb-eel wants to merge 1 commit into
ItsNotRexed:mainfrom
mrb-eel:fix/copy-resource-bc-tail

Conversation

@mrb-eel

@mrb-eel mrb-eel commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What changes

A whole-resource copy from uncompressed texels to block-compressed texture blocks failed when any destination mip ended inside a BC block. Native D3D12 WARP accepts these copies. This follows merged #3477, which fixed the region-copy case. Coordination claim.

Replay keeps aligned mips on vkCmdCopyImage. For each mip that reaches a partial BC block, it uses transfer scratch with matching byte strides and a write extent clipped to the logical mip size. Scratch offsets account for every layer and depth slice. Copies with more source blocks than destination blocks remain invalid.

Validation

  • Before the patch, three synthetic WARP-accepted whole-resource copies left Leonida's readback untouched. The aligned control already matched. After the patch, the three copies and the control match WARP.
  • d3d12_copy_xfmt checks 88 bytes across three mips with a partial tail and 176 bytes across three partial mips in two array layers, against independent upload bytes and WARP.
  • d3d12_copy_xfmt, d3d12_subresource_copy, d3d12_stencil_copy, replay_copy_offset, and vk_bc_zero_init passed on an RTX 4070 SUPER with Vulkan validation and synchronization validation enabled.

AI-assisted. No game files were used.

Coordination

#6178 validates calls at recording time. I checked that it merges cleanly with this branch. #3019 changes conditional execution and already conflicts with current main in replay. This PR changes cross-format mip geometry. When combining the two, keep the clipped per-mip extents here and route both the aligned and clipped regions through #3019's conditional path for a predicated copy.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested d94a4dbc on Windows 11 with AMD Radeon(TM) Graphics (driver 32.0.21043.5001) and NVIDIA GeForce RTX 4090 (driver 32.0.16.2101): pass.

On each adapter, the three-mip BC1 copy matches all 88 upload bytes. The two-layer copy matches all 176 upload bytes. The test reports 48 comparisons and zero differences on each adapter with Vulkan validation enabled.

I built the same test against parent 9f0ebbb3. On both adapters, the two copies return the expected byte counts, but the contents differ from the upload. The parent test exits 1. The head test exits 0.

cmake --build E:/Leonida-review-work-build --config RelWithDebInfo --target d3d12_copy_xfmt_test --parallel 4
$env:LEONIDA_VK_VALIDATION = '1'
foreach ($mask in @('*nv*', '*amd*')) {
    $env:VK_LOADER_DRIVERS_DISABLE = $mask
    & E:/Leonida-review-work-build/RelWithDebInfo/d3d12_copy_xfmt_test.exe
}

I checked both device names in the test output. This result covers the cross-format copy test.

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants