Repository navigation
Runtime: depth <-> colour copies through a scratch buffer - #1324
Conversation
|
Windows results on I also tested
All four copy directions passed on every backend. Khronos validation reported zero errors on both Vulkan GPUs (NVIDIA 616.92, AMD 26.10.1). The native D3D12 debug layer was unavailable on this host. |
|
Tested 487f993 on NVIDIA GeForce RTX 3090 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass. This is the Windows run against WARP and a native driver you asked for. The PR's diff applied cleanly to
|
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): pass. |
|
MSVC 19.44 on One nit: |
|
One integration detail for #521 and this PR, @NWX10. I merged I tested Locally adding the three formats to the existing 16-bit branch of |
|
Tested 487f993 on RTX 4090 (driver 621.14), Windows 11 26200, MSVC 19.44: pass (no regression against main).
The |
|
Tested
Code read of
All of this looks right to me. AI-assisted (Claude Code). |
|
Windows + native GPU check (the run this description asks for), built at
|
CopyResource and CopyTextureRegion between D32_FLOAT and R32_FLOAT/UINT/SINT, and between D16_UNORM and R16_FLOAT/UNORM, were refused at execution because vkCmdCopyImage cannot mix a depth and a colour aspect. Host D3D12 and WARP copy the bits, and ItsNotRexed#1134 listed these as not covered. The replay now stages each such region image -> scratch buffer -> image. The scratch comes from a new ScratchBuffers pool (vulkan_scratch.h): device-local chunks handed out while a list is prepared and retired with the submission's timeline value, like the depth24 converter's scratch, but enabled on every GPU. Without it the copy is refused as unsupported before anything is written. Still refused: depth with stencil (two planes), D24 stored as D32, and multisampled textures. Tests: d3d12_copy_xfmt gains five depth <-> colour cases (R16 -> D16 both ways, D32 -> R32_UINT, three mips, and a D32 -> R16 negative control), and a depth <-> colour mismatch now fails it. vk_command_replay_test part H runs a D32 -> R32 -> D32 round trip through the replay, and checks that a list is refused with no scratch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
487f993 to
e1b3fca
Compare
|
Rebased onto
Retested on an RX 9060 XT (RADV, Mesa, Linux; and clang-cl under Wine 11.22): AI-assisted (Claude Code). |
|
Tested
|
Claimed in the coordination issue as: new D3D item, depth ↔ colour copies (claim; no item ID yet)
What and why
CopyResourceandCopyTextureRegionbetween a depth format and a colour format of the same typeless family were refused at execution:vkCmdCopyImagecan't mix a depth and a colour aspect. Host D3D12 and WARP copy the bits, and #1134 lists these as "not covered". Games often do this, for example copying the depth buffer into anR32_FLOATtexture for SSAO or a hierarchical-Z pass.runtime/src/vulkan_replay.h):depth_colour_pairacceptsD32_FLOAT↔R32_FLOAT/UINT/SINT(R32_TYPELESS) andD16_UNORM↔R16_FLOAT/UNORM(R16_TYPELESS; the other R16 formats have no copy layout inblock_formatyet). Only single-sampled, single-plane depth, and not a D24 stored as D32. The texture-region and whole-resource paths build theirVkImageCopyregions as before, with each side's own aspect.preparethen turns them into a pair of buffer-image copies over one scratch allocation: image → scratch, a transfer barrier, scratch → image. Without scratch the list is refused asunsupportedbefore anything is written.runtime/src/vulkan_scratch.h, new):ScratchBuffers, device-local chunks handed out while a list is prepared, retired with the submission's timeline value, and reused once the GPU is past it. It follows the depth24 converter's scratch life cycle, but it's enabled on every GPU: that one only exists on GPUs without D24, and also manages descriptor pools.VulkanQueue::executewires it asReplayFunctions::copy_scratch, with the same lazy tracker lock and retire-on-every-exit guard as the depth24 path.d3d12_vulkan_device.cppenables it with device-local memory.docs/d3d12_vulkan.mdsection 3.2 describes the path and what's still refused.Still refused: depth with stencil (two planes), D24 stored as D32 (it would need the depth24 conversion as well), and multisampled textures. Not modelled: a float outside [0, 1] written into a
D32_SFLOATimage is undefined in Vulkan withoutVK_EXT_depth_range_unrestricted, where D3D12 keeps the bits. The test uses values in [0, 1).Tested
AMD Radeon RX 9060 XT (RDNA4, gfx1200), Mesa 27.0.0-devel RADV, Fedora 44. Windows runtime cross-compiled with clang-cl 22.1.8 + xwin (SDK 10.0.26100) and run under Wine 11.22 (Staging). Native Linux build with GCC 16.2.1.
d3d12_copy_xfmt(under Wine; the host comparison there is vkd3d, not Microsoft's runtime): all 16 depth ↔ colour comparisons match (8 cases × default adapter and WARP), against 0 of 8 on main. New cases:R16_UNORM -> D16_UNORM,D32_FLOAT -> R32_UINT(CopyTextureRegion),R16_UNORM -> D16_UNORM(CopyTextureRegion),D32_FLOAT -> R32_FLOATwith 3 mips, and aD32_FLOAT -> R16_UNORMnegative control, which the layer refuses. A depth ↔ colour difference now fails the test; before, it was only counted. Under Wine the test still exits 1 because vkd3d accepts the negative controls that the PC runtime refuses (the four old ones too, same as on main). A run on Windows against WARP and a native driver would be welcome.vk_command_replay_testpart H (new, native):D32_FLOATuploaded from floats →CopyResourceintoR32_SFLOAT→CopyTextureRegioninto a secondD32_SFLOAT, both read back bit for bit. It first checks the same list is refused asunsupportedwithoutcopy_scratchand leaves the layout tracker alone. Passes withLEONIDA_VK_VALIDATION=1, no validation errors, on RADV (RX 9060 XT) and llvmpipe (LLVM 22.1.8).c0ac5fdbuilt the same way: this branch fails 12, main 13, and every failure on this branch also fails on main (host comparisons against vkd3d,d3d12_predicated_copy, andfsr_dispatch/bvh_builder/d3d12_descriptor, which don't build with clang-cl 22: BUILD-356 and TEST-189).unimplemented_policyis the 13th on main and is flaky under Wine.Checklist
docs/design.md, with how it was confirmed. (n/a: no translator change)AI-assisted (Claude Code).
🤖 Generated with Claude Code