Repository navigation
d3d12: depth and stencil copies with a buffer on a COPY or COMPUTE family without graphics need maintenance10 (RT-784) - #8871
Conversation
…TE family cannot run (RT-784)
Enable VK_KHR_maintenance10 on 1.3 devices and allow such copies only where
the format has the *_COPY_ON_{TRANSFER,COMPUTE}_QUEUE feature. Covers
footprint copies, the D24 conversion's copy and staged depth<->colour copies.
New d3d12_copy_queue_depth_test (layer vs native D3D12).
AI-assisted (Claude Code).
|
Native Windows COPY and COMPUTE verification of cf6a571f on an RTX 3080 Ti (621.35), MSVC 19.44, and Vulkan SDK 1.4.363.
Both runs had zero skips or Vulkan core or synchronization validation messages. The runtime was unchanged. This covers |
|
Independent Windows verification of #8871 at cf6a571 on main 867d922. Windows 11 build 26200, MSVC 19.51, native x64 Release, Vulkan Headers 1.4.363, Khronos validation layer 1.4.357 and LEONIDA_VK_VALIDATION=1. Synthetic test inputs. AI-assisted. I ran the original COPY fixture and added a local COMPUTE mode that executes the same five cases on the layer's non-graphics compute queue. For expected refusals the local test requires the shim to return ReplayResult::unsupported.
Zero Vulkan validation errors in all 12 patched probe runs. The Windows D3D12 oracle selected the RTX 5090 in every run and matched all five cases on both queue types. The control used separately built main replay/device code and identical probe source. The test target and default-false feature field were carried over to compile the probe. All four control runs attempted the buffer-dependent copies and reported the buffer/image queue VUIDs, including 07739 and 10216. The readbacks happened to match on these two GPUs. Five focused CTests passed per GPU: d3d12_copy_queue_depth, d3d12_stencil_copy, d3d12_typeless_depth, vk_command_replay and d3d12_vulkan_device. I applied #7125 (703fc03) for the last test so it completed the new feature check after the existing slot-78 assertion. |
|
Tested
|
…E (RT-784) The expected outcome of each queue comes from the Vulkan family the layer runs it on (transfer-only, compute without graphics, or one with graphics). Both reviewers of ItsNotRexed#8871 had to add a COMPUTE mode locally. AI-assisted (Claude Code).
Claimed in the coordination issue as: RT-784 (#8186 (comment))
What and why
When the GPU has a transfer-only (DMA) family, the layer puts COPY queues there, and COMPUTE queues go on an async-compute family. Neither family has graphics. On such a family Vulkan allows a copy between a buffer and a depth or stencil aspect only with
VK_KHR_maintenance10and the format's*_COPY_ON_{TRANSFER,COMPUTE}_QUEUEfeature (VUID-vkCmdCopyBufferToImage-commandBuffer-07739and-11781,VUID-vkCmdCopyImageToBuffer-commandBuffer-10216). The layer checked neither, so every footprint upload or readback of a depth texture on a COPY queue was invalid usage. On an RTX 4070 SUPER it also gave a wrong result: a D32S8 stencil-plane upload on the transfer family is left unwritten, both with and without validation (texel (1,0) reads 0, wrote 1). Native D3D12 accepts and runs the same copy.runtime/shims/d3d12_vulkan_device.cpp: enablesVK_KHR_maintenance10with its feature on a Vulkan 1.3 device (the format features are read withVkFormatProperties3, core in 1.3), the same way asmaintenance8.register_off_graphics_familiestakes the COPY and COMPUTE families without graphics and records, once, which depth and stencil aspects each depth/stencil format may copy there. The queue families are now enumerated once in the constructor and shared with the transfer-only, predication, timestamp and sparse checks.runtime/src/vulkan_replay.h:OffGraphicsCopies(a fixed table: format → aspects) andReplayFunctions::off_graphics, null on a family with graphics.detail::buffer_aspect_copy_allowedchecks the three places the layer copies between a buffer and a depth or stencil aspect: footprint copies, the copy that ends the D24-as-D32 conversion (its pass also runs on an async-compute family), and both halves of a staged depth ↔ colour copy. A copy the family cannot run returnsReplayResult::unsupported, the same way D24/RGB96 conversions are already kept off a transfer-only queue. Image-to-image depth copies (vkCmdCopyImage) have no such rule and are unchanged.runtime/src/vulkan_backend.h:VulkanContext::set_off_graphics_family. Each queue points its replay at its family's table: no allocation or copy perExecuteCommandLists.docs/d3d12_vulkan.md: theID3D12CommandQueuerow describes the rule and what was measured.Refusing drops the whole batch, as for the other refusals on these queues. Running such a copy on a graphics-family queue with a semaphore handoff instead would keep it working on GPUs without the feature (or for the D32S8 stencil on NVIDIA). That is a larger change and could be a follow-up.
Tested
Windows 11 Pro (10.0.26300), NVIDIA GeForce RTX 4070 SUPER, driver 32.0.16.1742, Vulkan SDK 1.4.363.0, MSVC 14.44 (VS Build Tools 2022), RelWithDebInfo,
LEONIDA_VK_VALIDATION=1(synchronization validation on). On this GPU the COPY queues land on family 1 (TRANSFER | SPARSE_BINDING), the driver exposesVK_KHR_maintenance10, and the transfer-queue copy feature is set for the depth aspect of every depth format but not for the D32S8 stencil aspect.New
d3d12_copy_queue_depth_test(synthetic, no game files). It runs five copies on a COPY queue, with explicit COMMON ↔ copy-state barriers, on the layer and on native D3D12, and compares each with the expected outcome for this GPU (from the queue family's flags and the format features the driver reports: run, or refused):vkCmdCopyImage)Validation errors: 8 before the change, 0 with it.
d3d12_vulkan_device_testgains a check thatmaintenance10is enabled exactly when the GPU offers it on a 1.3 device, like the one formaintenance8. On this machine the test already fails earlier, at line 6574 (tiles == 1), the same as onmain, so the new check did not run here.Full
ctest --test-dir runtime/build -C RelWithDebInfowith validation, rebased onmain867d922: 261 of 266 pass. The 5 that fail (vk_queue,d3d12_vulkan_device,d3d12_depth_resolve,d3d12_indirect_rt,d3d12_mesh) also failed on unmodifiedmain(dde82f2) on this machine, built separately, with the same errors: buffer-copy WRITE_AFTER_WRITE hazards, mesh-shader pipeline statistics, ray query, tiling.Not covered: a GPU without
maintenance10(every such copy refused), an async-compute family (only the COPY family was exercised here), and a Vulkan 1.2 device.python -I scripts/check_no_game_data.pyon every changed file: clean.AI-assisted: yes (Claude Code).
Checklist
Item: RT-784. Touches
runtime/shims/d3d12_vulkan_device.cppnext to #8440 (different functions; whichever lands second may need a rebase).