vulkan_replay: honor format alignment, block size, and depth in tile_footprint staging #434
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!434
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/434/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tahffo68hk-hash on GitHub · 2026-11-24 05:11 UTC · original
tahffo68hk-hash:fix/vk-tile-copy-align→main· +138 −14 · 2 files · 1 commits · merged 2026-11-24 16:25 UTCSummary
(AI-assisted) Fixes VK-TILE-COPY-ALIGN in
untime/src/vulkan_replay.h:
ow_bytes and pitch, ignored mt.block for block-compressed formats, ignored imageExtent.depth > 1 (only copying slice 0), left ufferImageHeight non-zero on the tightly-packed scratch region, and did not guard against
gb96 / depth24_as_float paths that read uffer.buffer directly.
Changes
untime/src/vulkan_replay.h:
ow_bytes, pitch, slice_rows, slice_pitch, and depth slices from BlockFormat, clear ufferImageHeight = 0 alongside ufferRowLength = 0, and reject unsupported
gb96 / depth24_as_float unaligned tile staging.
untime/test/replay_copy_offset_test.cpp: Add regression coverage for 8-byte 3D (VK_FORMAT_R16G16B16A16_SFLOAT) and block-compressed (VK_FORMAT_BC1_RGBA_UNORM_BLOCK) ile_footprint copies with offset = 4, verifying scratch size, per-row/per-slice VkBufferCopy offsets/sizes, aligned VkBufferImageCopy::bufferOffset, and cleared ufferRowLength/ufferImageHeight.
Verification
eplay_copy_offset_test with MSVC 19.44 + Ninja and ran ctest -R "^replay_copy_offset$" --output-on-failure: 1/1 PASS (0.16s).
中文翻译
摘要
(AI 辅助)修复
untime/src/vulkan_replay.h 中的 VK-TILE-COPY-ALIGN:
ow_bytes 与 pitch 硬编码乘以 4,未处理块压缩格式的 mt.block,未拷贝 depth > 1 的后续切片且未清零 ufferImageHeight,也未拦截与暂存路径冲突的
gb96 / depth24_as_float 路径。
改动
untime/src/vulkan_replay.h:按 copy_block_format(image, aspectMask) 计算真实格式对齐;泛化 stage_unaligned_tile() 支持任意元素字节数、块压缩尺寸与 3D 切片,并清零 ufferImageHeight。
untime/test/replay_copy_offset_test.cpp:新增 8 字节 3D(R16G16B16A16_SFLOAT)与 BC1_RGBA_UNORM_BLOCK 在 offset=4 下的回归测试,验证暂存大小、行/切片步长及 VkBufferImageCopy 对齐参数。
验证
@moffington on GitHub · 2026-11-24 05:26 UTC · original
Tested
cfb34363on Linux. replay_copy_offset passed. Running the same test against the merge base (2a2b1680) failed seven of the new assertions covering scratch allocation, row and slice offsets, and image-copy parameters for BC1 and 8-byte 3D uploads. This was a CPU replay test that checked the emitted Vulkan command parameters.@Dezmonius on GitHub · 2026-11-24 05:45 UTC · original
Independent Windows check of PR head
cfb343636applied tomain@8f481cf16. Windows 10 22H2, RTX 5070 / NVIDIA 610.88, MSVC 19.51.36256, Windows SDK 10.0.26100, Vulkan-Headers 1.4.363, Ninja Release.replay_copy_offset,replay_texture_barrier,d3d12_texture_tiles). The hardware tile test matched 992,768 native D3D12 pixels across four cases in each run.Synthetic fixtures only. The Khronos validation layer was unavailable. AI-assisted.
@QemmHD on GitHub · 2026-11-24 16:25 UTC · original
Merging.
Why merged: tile_footprint staging now follows the format's real alignment, block size and depth. Before, it assumed 2D RGBA8, which was wrong for 8- and 16-byte texels, BC formats and 3D. moffington showed 7 new asserts fail on the base, and Dezmonius passed it on Windows with an RTX 5070.
Why it's good: replay_copy_offset, replay_texture_barrier and d3d12_texture_tiles all pass both plain and under validation. A possible follow-up, not a blocker: staging now triggers on offset % fmt.bytes, so an R8/R16 tile copy at an offset that isn't a multiple of 4 is no longer staged. On a transfer-only queue that would hit VUID-vkCmdCopyBufferToImage-commandBuffer-07737. main's non-tile path already behaves that way, and the old *4 staging was wrong for R8/R16 anyway; max(4, fmt.bytes) for colour formats would cover both.
Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Alone on main, its tests passed both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #388, #418, #421, #434, #470, #484, #485, #486 and #488 merged onto main
1504c1af6(a225e593e). There the repo-consistency set gives 566 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 306/308. The 2 failures are the same pre-existing ones as main (d3d12_execute_indirect_validation, d3d12_depth_resolve), with the same skip set. git merge-tree against current main98a977b4b: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).