mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:40:52 +01:00
[PR #528] [MERGED] vulkan_replay: enforce 4-byte vkCmdFillBuffer alignment in zero_compressed_image #576
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#576
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/528
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @QemmHD
Base:
main← Head:fix/vk-zero-init-fill-align📝 Commits (1)
1d4310bvulkan_replay: enforce 4-byte vkCmdFillBuffer alignment in zero_compressed_image📊 Changes
2 files changed (+89 additions, -6 deletions)
View changed files
📝
runtime/src/vulkan_replay.h(+9 -6)📝
runtime/test/vk_bc_zero_init_test.cpp(+80 -0)📄 Description
Summary
(AI-assisted) Fixes
VK-ZERO-INIT-FILL-ALIGNinruntime/src/vulkan_replay.h:detail::initialize()routes not only block-compressed (fmt.block > 1) textures, but also uncompressed color textures on copy-only queues (!can_clear && color) intodetail::zero_compressed_image(). Whenvk.zero_bufferis absent (thevk.copy_scratch+vk.fill_bufferfallback),zero_compressed_image()previously roundedfill_bytesandalignonly tofmt.bytes, assumingfmt.byteswas 8 or 16.For 1-byte (
R8_UNORM, e.g.3x3 = 9 B) or 2-byte (R16_UNORM, e.g.3x1 = 6 B) color textures with non-4-byte-multiple sizes, this passed a non-4-byte-alignedsize(and, with non-4-aligned scratch offsets, a non-4-byte-aligneddstOffset) tovkCmdFillBuffer, violatingVUID-vkCmdFillBuffer-dstOffset-00024andVUID-vkCmdFillBuffer-size-00028.Changes
runtime/src/vulkan_replay.h: Inzero_compressed_image(), usealign = std::max<VkDeviceSize>(4, fmt.bytes)when sizing the scratch request, computingpad, and roundingusabledown to a multiple ofalignbefore callingvk.fill_buffer().runtime/test/vk_bc_zero_init_test.cpp:VulkanQueue::QueueKind::copy) zero-init readback tests for poisoned (0x5A)3x3VK_FORMAT_R8_UNORMand3x1VK_FORMAT_R16_UNORMtextures viacopy_scratch(nozero_buffer).ReplayFunctionsalignment check verifyingdstOffset % 4 == 0andsize % 4 == 0for3x3R8_UNORMeven with a deliberately unaligned scratch offset (offset = 2).Verification
vk_bc_zero_init_test.exe, MSVC 19.44 + Ninja):copy-queue zero-init (R8_UNORM 3x3 via copy_scratch)andcopy-queue zero-init (R16_UNORM 3x1 via copy_scratch)passed (all readback texels0x00, 0 validation errors).gfx1036, RDNA2): all cases passed identically.中文翻译
摘要
(AI 辅助)修复
runtime/src/vulkan_replay.h中的VK-ZERO-INIT-FILL-ALIGN:detail::initialize()不仅会将 BC 压缩纹理送入detail::zero_compressed_image(),在仅拷贝队列(!can_clear && color)上也会将未压缩彩色纹理送入该函数。当未配置vk.zero_buffer而走copy_scratch+vk.fill_buffer回退路径时,原实现假设fmt.bytes恒为 8 或 16,对 1 字节(如R8_UNORM 3x3 = 9B)或 2 字节(如R16_UNORM 3x1 = 6B)纹理会向vkCmdFillBuffer传入非 4 字节对齐的size/dstOffset,违反VUID-vkCmdFillBuffer-dstOffset-00024与VUID-vkCmdFillBuffer-size-00028。改动
runtime/src/vulkan_replay.h:在zero_compressed_image()中将align提升为std::max<VkDeviceSize>(4, fmt.bytes),确保vk.fill_buffer的偏移与长度均满足 4 字节与fmt.bytes对齐。runtime/test/vk_bc_zero_init_test.cpp:新增仅拷贝队列下R8_UNORM 3x3与R16_UNORM 3x1的真实 GPU 零初始化读回测试,以及非对齐暂存偏移下的vkCmdFillBuffer对齐断言。验证
vk_bc_zero_init_test.exe):在 NVIDIA RTX 5060 Ti 与 AMD Radeon(TM) Graphics(gfx1036) 上均全部通过,读回纹素全为0x00。🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.