Repository navigation
d3d12/vulkan: predicate CopyResource, CopyTextureRegion, resolves, UAV clears and AtomicCopyBuffer - #3019
d3d12/vulkan: predicate CopyResource, CopyTextureRegion, resolves, UAV clears and AtomicCopyBuffer#3019LocranKing wants to merge 1 commit into
Conversation
…V clears and AtomicCopyBuffer
|
Tested
First NVIDIA coverage for the predicated |
|
Tested 4b9b367 on AMD Radeon RX 7600 (RDNA3), AMD 26.11.2 (LLPC), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8: pass.
AI-assisted (Claude Code, reviewed with Codex). No game files. |
Kam471
left a comment
There was a problem hiding this comment.
The embedded SPIR-V is byte-exact against glslang 16.6.0 (-V --target-env vulkan1.2 -Os; 591/591 and 632/632 words) and both modules validate. The contract mapping is correct: EQUAL_ZERO skips when the 64-bit value is zero, NOT_EQUAL_ZERO when it is not; the 8-byte read at an 8-aligned offset matches SO_STATISTICS.NumPrimitivesWritten and the binary-occlusion 0/1; snapshot-at-SetPredication matches the GPU snapping the value. The Vulkan conditional-rendering gating premise is sound.
But this is unproven at runtime here: I could not build or run d3d12_predicated_ops_test (the only configured build points at another checkout and has Vulkan_INCLUDE_DIR-NOTFOUND), so the 203/203 WARP claim was not reproduced. Also, AtomicCopyBufferUINT/AtomicCopyBufferUINT64 and ResolveSubresourceRegion are absent from D3D12's documented predicated set (Draw*, Dispatch, Copy{TextureRegion,BufferRegion,Resource,Tiles}, ResolveSubresource, Clear*View, ExecuteIndirect), so those two rest on one RTX 3060 Ti/WARP measurement and are untested on AMD/Intel.
Please either narrow predication to the documented set or document the measurement for those two and provide a configured build/run with validation enabled. Note also that predicated copy command lists still return unsupported (kind_ == QueueKind::copy, pre-existing), and predicated MSAA texture copies are documented unsupported.
|
Tested 4b9b367 on Windows 11, RTX 5080 (driver 616.92) and AMD Radeon iGPU gfx1036 (driver 26.10.1):
AI-assisted. |
|
Tested 4b9b367 on NVIDIA RTX 5060 Ti (Blackwell), subgroup 32, NVIDIA 621.01 (Vulkan 1.4.357), Windows 11, VS Build Tools 2022 (MSVC) + Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0: pass.
AI-assisted (Qoder): I built the full runtime with MSVC and ran ctest. |
|
Tested
Not checked: the diff was read only in part (about 3,000 lines). Two things noticed while reading, not measured: |
|
Tested 4b9b367 (merged onto main 1628210) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass
This adds an NVIDIA (Ada) result alongside the RTX 3060 Ti and WARP numbers in the PR body. AI-assisted (Claude). |
|
Tested 4b9b367 on Sapphire RX 9070 XT Nitro+ (AMD 26.11.2 LLPC, driverVersion 2.0.416), Windows 11 26200, MSVC: pass. The runtime builds. Full |
|
A heads-up on merge order with #2928 (not a review of the predication logic itself). #2928 moves a copy's prepared data out of This PR adds copy-only fields to
They belong in Whichever of the two lands second, I'm glad to do that move. If this one goes first, I'll fold these fields into AI-assisted (Claude Code). |
|
Tested on AMD Radeon RX 6600 (RDNA2, gfx1032), Windows 11, Adrenalin 26.11.2 (Vulkan driver 32.0.21045.29003). PR head
No failures on this hardware. |
|
Tested 4b9b367 on Tiger Lake (Xe-LP) iGPU 0x9a78, driver 32.0.101.7088, Windows 11, MSVC 14.44: pass Full The PR's own area, all green on Intel: AI-assisted (GLM, operated by the account owner). |
AI-assisted. No game files.
Follow-up to D3D-18 / #1277 (
docs/d3d12_vulkan.md§4.7Open), claimed in #2516 (comment).Summary
Extends
SetPredicationsupport beyondCopyBufferRegionto cover the remaining D3D12 copy, resolve, UAV-clear, and atomic-copy commands that Vulkan'sVK_EXT_conditional_renderingdoes not cover natively:CopyResource:PredicatedBufferCopier.src -> src_scratch,dst -> dst_scratch, conditionalPredicatedBufferCopiersrc_scratch -> dst_scratch,dst_scratch -> dst).samples > 1) returnReplayResult::unsupported, as Vulkan forbidsvkCmdCopyImageToBuffer/vkCmdCopyBufferToImageon multisampled images.CopyTextureRegion:RowPitch/slice_pitch, partial boxes, BC, depth/stencil, and 3D volumes) routed through a new byte-granular 3D strided compute helper (PredicatedOps/predicated_strided_copy.comp), leaving skipped destinations and inter-row readback padding untouched.depth24_as_floatandrgb96uploads convert intodepth24.scratchunconditionally and select viaPredicatedBufferCopier; readbacks stage unconditionally intodepth24.scratchand rundepth24_runinside active conditional rendering.PredicatedBufferCopierpath above.ResolveSubresource/ResolveSubresourceRegion:MIN/MAX/AVERAGE, whole and partial rect, preservingkeep_around_resolve's surrounding bands) save the destination rect, run the resolve unconditionally, capture the resolved rect, select via conditionalPredicatedBufferCopier, and write back.ClearUnorderedAccessViewUint/ClearUnorderedAccessViewFloat:<4-byte unaligned ranges) routed to a new byte-granular repeating-element compute fill helper (PredicatedOps/predicated_fill.comp).predicated_fill.comp(2D color-attachment views keepvkCmdClearAttachments).AtomicCopyBufferUINT/AtomicCopyBufferUINT64:621.01) and WARP; routed toPredicatedBufferCopier.Synchronization, Lifetime & Statistics Isolation
runtime/src/vulkan_scratch.h): addedVK_BUFFER_USAGE_STORAGE_BUFFER_BITso existing timeline-retired scratch chunks bind directly to predicated compute passes.vkCmdCopyImageToBuffer,vkCmdCopyBufferToImage,vkCmdResolveImage, depth/stencil resolve rendering scope, anddepth24/rgb96upload conversion) suspendVK_EXT_conditional_renderingvia an RAIISuspendPredicateguard and re-enter it around the predicated compute dispatch.VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BITatTRANSFER_BIT | COMPUTE_SHADER_BIT→TRANSFER_READ_BITatTRANSFER_BIT, keeping both predicate-true and predicate-false paths hazard-free. Also adds aTRANSFER_WRITE -> TRANSFER_WRITEbarrier before unpredicatedCopyTextureRegionreadback into aCOPY_DESTbuffer.PIPELINE_STATISTICSisolation (D3D-162):plan_statistics_segmentssplits once per command aroundpredicated_strided,predicated_fill,predicated_copy, andhas_depth24dispatches.CopyResource,CopyTextureRegionreadback, bufferClearUnorderedAccessView*, andAtomicCopyBuffer*reportVK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT.predicated_strided_copy.compandpredicated_fill.compcompiled with Glslang11:16.6.0(-V --target-env vulkan1.2 -Os), validated withspirv-val --target-env vulkan1.2(StorageBuffer8BitAccessonly, noInt8)./bigobjongta6rt_d3d12_com(MSVC COFF COMDAT section count ond3d12_vulkan_device.cpp.objcrossed 32,767 sections).Verification
621.01/32.0.16.2101, Vulkan1.4.357, Vulkan SDK1.4.363.0, MSVC14.44.35207). All Vulkan runs usedVK_LOADER_LAYERS_DISABLE=~implicit~andLEONIDA_VK_VALIDATION=1(0 validation errors).origin/main16282101, head4b9b3674.vulkan_replay.hchanges):d3d12_predicated_ops_test --warp-onlypassed on WARP while unpatched Vulkan failed immediately on predicatedCopyResourcebuffer (EQUAL_ZEROwith0overwrote destination).4b9b3674):d3d12_predicated_ops_test: 203/203 exact differential cases vs WARP (includingPIPELINE_STATISTICSisolation across all operations), 0 validation errors (--warp-only: 199/199 PASS).ctest --output-on-failure -j4: 115/115 run tests passed (100%, 7 skipped game-data/optional, 1 disabledgameinput).vk_predicated_copy_test(with new forced-windowPredicatedOpsstrided + 16-byte phase-fill stress),vk_command_replay_test, andvk_predicate_capture_test: all PASS, 0 validation errors.predicated_copy_testandreplay_query_predication_testPASS.