Repository navigation
Runtime: stage block-compressed copies one vkCmdCopyImage cannot express - #860
Conversation
|
The requested validation run found two synchronization errors at I ran the individual mixed-mip cases on both RTX 5080 and Radeon Graphics. Each adapter reported one error for BC1 and one for BC7 on the same-resource copy mip 3 (3×3) → mip 2 (6×6), destination (4,4). The reported destination extent was 2×2. The mip 0 box 4×4 → mip 3 control produced zero errors for both formats. The unmodified Radeon stock executable stops earlier at its OPTIONS19 comparison, so the Radeon results are from the isolated cases. A one-line local trial adding I also tested whether the positions outside a 3×3 logical mip survive a round trip. Two BC1 copies in one command list took a patterned 4×4 block from an 8×8 image into a second texture's 3×3 mip, then copied it back to (4,4) of the first image. The public head's Vulkan path on both GPUs and native D3D12 on RTX, Radeon and WARP matched all 64 expected RGBA texels, including all seven positions in the block's last row or column. Omitting only the return copy changed precisely 16/64 texels, including those seven, on every path. AI-assisted independent verification with source-built fixtures. |
|
Tested
A minor point, not blocking: each staged copy gets its own AI-assisted (Claude Code). |
…tion write The barrier between the two halves of a staged block-compressed copy only made the buffer's write visible to its read. Synchronization validation reported a write-after-write on vkCmdCopyBufferToImage for the 3x3 mip into the 6x6 mip at (4, 4), BC1 and BC7, on an RTX 5080 and a Radeon iGPU. With TRANSFER_WRITE on the destination side the second command is ordered after every earlier transfer write, and the reports go away on both GPUs. Found and checked by @Vonsek on ItsNotRexed#860. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @Vonsek, that's exactly the validation run I couldn't do here (no Vulkan SDK on this machine). Taken as you tested it: fc60aa6 adds Re-run at fc60aa6 without the validation layer (I still can't run it): A validation run at fc60aa6 on either of your GPUs would confirm it from the real head. |
|
Confirmed at the published The full unmodified RTX |
quackottu
left a comment
There was a problem hiding this comment.
Tested fc60aa6 on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass
ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 32d3d12_state_map_test(changed here): exit=0 validation=0 | state map, enhanced barriers, subresource decoding, layout tracking and BAR detection OK- 33 test programs in the build pass with 0 validation errors
d3d12_clear_testfails (R8G8B8A8_UNORM/SNORM 0.5 ties and a D16 clear byte differ from WARP) exactly as onmain4a36bb1 here, so not from this PR; #521 addresses it
Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.
CopyTextureRegion between two block-compressed textures copies whole blocks on the PC runtime. When a mip edge falls inside a block on one side only (a 4x4 box into a 3x3 mip, a 6x6 mip into a 12x12 one), no single Vulkan extent is a block multiple or reaches the edge of both images, so the layer refused the copy with invalid_copy (docs/d3d12_vulkan.md, section 3.2 known gaps). Such a copy now goes through the transfer scratch that depth <-> colour copies already use (vulkan_scratch.h): vkCmdCopyImageToBuffer with the source's own cut extent into whole blocks, then vkCmdCopyBufferToImage with the destination's. The box fits the source's padded mip, so the scratch holds every block the destination reads. The staged emit path calls the destination's copy_layout after the scratch write, so every earlier transfer write is ordered before the destination's (the write-after-write @Vonsek found under synchronization validation in the first version of ItsNotRexed#860). - d3d12_copy_compare: the 8 BC mixed-mip cases that were printed as known differences must now match the host; two more shapes (a source edge inside the block, a destination offset to the edge). - d3d12_state_map_test checks the staged regions on the CPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fc60aa6 to
cde85e2
Compare
|
Rebased onto round 39 (
Same tests: 0 of 75 copy differences (18/18 BC mixed-mip matches) on an RTX 5070 Ti, an RTX 3060 and an AMD Radeon iGPU, each against its own host. Since the code changed, the earlier validation results apply to fc60aa6, not to this head. A |
Item: new D3D item, claimed in #634 (no ID assigned yet). Rebased onto
mainat 4947579 (round 39); noDepends on.What
CopyTextureRegionbetween two block-compressed textures copies whole blocks on the PC runtime. When a mip edge falls inside a block on one side only (a 4x4 box into a 3x3 mip, a 6x6 mip into a 12x12 one), no singlevkCmdCopyImageextent is a block multiple or reaches the edge of both images, so the layer refused the copy withinvalid_copy. That was the known gap indocs/d3d12_vulkan.md§3.2, and the 8 BC mixed-mip casesd3d12_copy_compareprinted as known differences.Such a copy now goes through the transfer scratch that depth <-> colour copies already use (
vulkan_scratch.h,ReplayFunctions::copy_scratch,Prepared::staged):vkCmdCopyImageToBufferwith the source's own cut extent into whole blocks, thenvkCmdCopyBufferToImagewith the destination's. The box fits the source's padded mip, so the scratch holds every block the destination reads.prepare_texture_copydescribes the two regions (staged_reads/staged_writes);preparetakes the scratch. Withoutcopy_scratchthe copy is refused as before.copy_layoutafter the scratch write, so every earlier transfer write is ordered before the destination's. That covers the write-after-write @Vonsek found in the first version.vkCmdCopyImagepath as before.vkAllocateMemoryper staged copy, owned by the queue), this uses the shared, reused scratch chunks, which also answers @Parakeet-Wheat's allocation-count point.Tests
d3d12_copy_compare: the 8 former known differences (4 shapes, BC1 and BC7) must now match the host byte for byte, plus two more shapes: the box 4..8 of a 6x6 mip into the 3x3 mip, and the 3x3 mip into the 6x6 mip at (4, 4). The three shapes that don't fit are still refused by both sides.d3d12_state_map_test: the staged regions on the CPU (extents, offsets, row length), a copy that stays direct, and refusals that staging doesn't change.Measured at cde85e2, Windows 11, MSVC 14.50, driver 621.24:
LEONIDA_VK_DEVICE)ctest107/107 apart fromxbox_present(below); copy comparison 0 of 75 differ, 18/18 BC mixed-mip matchesd3d12_vulkan_device_testexit 0, 0 of 75 differ0x1002:0x164e, Vulkan driver 2.0.353)d3d12_vulkan_device_testexit 0, 0 of 75 differxbox_presentfails on this machine's real-time pacing check (30 frames at 60 Hz in about 7.3 s, limit 5 s). It fails the same way on plainmain4947579 here, so it isn't this PR.Not run here:
LEONIDA_VK_VALIDATION=1(no Vulkan SDK on this machine). @Vonsek, @Parakeet-Wheat and @quackottu validated the first version (fc60aa6); this head is a rework ontomain's scratch path, so a validation run at cde85e2 would be welcome.No game files. AI-assisted (Claude Code).
🤖 Generated with Claude Code