mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:40:52 +01:00
[PR #600] vulkan_replay: handle UNDEFINED->UNDEFINED TextureBarrier without illegal newLayout (VK-TEXTURE-BARRIER-UNDEF-NOOP) #642
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#642
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/600
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/vk-texture-barrier-undef-noop📝 Commits (1)
ab302eevulkan_replay: handle UNDEFINED->UNDEFINED TextureBarrier without illegal newLayout (VK-TEXTURE-BARRIER-UNDEF-NOOP)📊 Changes
3 files changed (+174 additions, -2 deletions)
View changed files
📝
runtime/CMakeLists.txt(+15 -0)📝
runtime/src/vulkan_replay.h(+19 -2)➕
runtime/test/vk_texture_barrier_undef_noop_test.cpp(+140 -0)📄 Description
Summary
In D3D12 Enhanced Barriers, a
D3D12_TEXTURE_BARRIERwithLayoutBefore == D3D12_BARRIER_LAYOUT_UNDEFINEDandLayoutAfter == D3D12_BARRIER_LAYOUT_UNDEFINEDis a legal sync/access-only barrier with no layout transition (and is explicitly accepted byCommandList::barrier(const TextureBarrier&)inruntime/src/command_list.h:693).Previously,
emit()inruntime/src/vulkan_replay.hhandled this case through the discard image-barrier path, which:VkImageMemoryBarrier2witholdLayout = VK_IMAGE_LAYOUT_UNDEFINEDandnewLayout = VK_IMAGE_LAYOUT_UNDEFINED, violatingVUID-VkImageMemoryBarrier2-newLayout-01198(newLayoutmust not beVK_IMAGE_LAYOUT_UNDEFINEDorVK_IMAGE_LAYOUT_PREINITIALIZED).LayoutTrackerfor the texture range toVK_IMAGE_LAYOUT_UNDEFINED, causing the next copy/draw/barrier to re-rundetail::initialize()and wipe the texture's rendered pixels to zeros on the GPU.Fix
texture->layout_before == d3d12_layout::undefined && texture->layout_after == d3d12_layout::undefinedinemit()(runtime/src/vulkan_replay.h), emit aVkMemoryBarrier2with the mapped (and queue-restricted)srcStageMask/dstStageMask/srcAccessMask/dstAccessMaskand leaveLayoutTrackeruntouched.runtime/test/vk_texture_barrier_undef_noop_test.cpp(registered asvk_texture_barrier_undef_noopinruntime/CMakeLists.txt) that clears a 4x4R8G8B8A8_UNORMtexture to magenta ((255, 0, 255, 255)), issues anUNDEFINED -> UNDEFINEDEnhancedTextureBarrier, copies the texture to a host-readable buffer, and verifies zero illegalUNDEFINEDnewLayoutbarriers, preservedLayoutTrackerstate, and 16/16 exact magenta pixels on host readback.Verification (Real Dual-GPU Hardware)
FAIL runtime/test/vk_texture_barrier_undef_noop_test.cpp:126: driver::illegal_undef_new_layout.load() == 0vk_texture_barrier_undef_noop_test: PASS (0 illegal UNDEFINED newLayout, 16/16 magenta pixels preserved)vk_texture_barrier_undef_noop_test: PASS (0 illegal UNDEFINED newLayout, 16/16 magenta pixels preserved)Coordination
VK-TEXTURE-BARRIER-UNDEF-NOOP(no overlapping open PRs or claims).中文翻译
摘要
在 D3D12 Enhanced Barriers 规范中,
LayoutBefore == D3D12_BARRIER_LAYOUT_UNDEFINED且LayoutAfter == D3D12_BARRIER_LAYOUT_UNDEFINED的D3D12_TEXTURE_BARRIER是合法的无布局切换同步屏障(runtime/src/command_list.h:693也明确允许该组合)。此前
runtime/src/vulkan_replay.h的emit()会将其当作 discard 布局转换,发出oldLayout = UNDEFINED, newLayout = UNDEFINED的VkImageMemoryBarrier2(违反VUID-VkImageMemoryBarrier2-newLayout-01198),并将LayoutTracker覆写为UNDEFINED,导致下一次拷贝或绘制触发detail::initialize()将纹理内容误清零。修复
emit()处理TextureBarrier时,若layout_before与layout_after均为d3d12_layout::undefined,改为发射受队列阶段约束的VkMemoryBarrier2并保持LayoutTracker不变。runtime/test/vk_texture_barrier_undef_noop_test.cpp(CMake 注册名vk_texture_barrier_undef_noop):将 4x4R8G8B8A8_UNORM纹理清除为洋红色,插入UNDEFINED -> UNDEFINED纹理屏障后拷贝读回,验证 0 次非法newLayout = UNDEFINED且 16/16 像素完好保留。真实双卡 GPU 验证
illegal_undef_new_layout != 0失败。PASS (0 illegal UNDEFINED newLayout, 16/16 magenta pixels preserved)。PASS (0 illegal UNDEFINED newLayout, 16/16 magenta pixels preserved)。协同
VK-TEXTURE-BARRIER-UNDEF-NOOP。🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.