mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #597] vulkan_backend: erase removed resource from storage_pending_ (VK-REMOVE-RESOURCE-STORAGE-PENDING) #638
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#638
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/597
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/vk-remove-resource-storage-pending📝 Commits (1)
0b3a5c9vulkan_backend: erase removed resource from storage_pending_ (VK-REMOVE-RESOURCE-STORAGE-PENDING)📊 Changes
3 files changed (+179 additions, -1 deletions)
View changed files
📝
runtime/CMakeLists.txt(+15 -0)📝
runtime/src/vulkan_backend.h(+2 -1)➕
runtime/test/vk_remove_resource_storage_pending_test.cpp(+162 -0)📄 Description
Summary
When a storage image (UAV) or sparse image is created, the D3D12 layer registers its
ResourceIdviaVulkanContext::note_shader_image(id)(storage_pending_.insert(id)). On the next shader submission (VulkanQueue::execute_now()),storage_pending_is drained and every listedResourceIdis resolved and initialized intoVK_IMAGE_LAYOUT_GENERALviadetail::initialize()(which emitsvkCmdClearColorImagefor committed images).In
VulkanContext::remove_resource(ResourceId id)(runtime/src/vulkan_backend.h),zero_pending_was already cleaned understorage_mutex_for buffers destroyed before any submission, butstorage_pending_was not. As a result:ResourceIdentries instorage_pending_until a shader submission ran.ResourceId(heap address reuse of COMID3D12Resourcepointers) before the next shader submission,execute_now()resolved the stale entry to the new image, spuriously transitioning it toVK_IMAGE_LAYOUT_GENERALand clearing its contents withvkCmdClearColorImageeven though it was never passed tonote_shader_image().Fix
idfromstorage_pending_understorage_mutex_inVulkanContext::remove_resource()(runtime/src/vulkan_backend.h), right alongsidezero_pending_.runtime/test/vk_remove_resource_storage_pending_test.cpp(registered asvk_remove_resource_storage_pendinginruntime/CMakeLists.txt) that registers Image A atid=1, callsnote_shader_image(1), removesid=1, registers a non-storage Image B at reusedid=1, executes a real SPIR-V computeDispatchonVulkanQueue, and verifies zero spuriousvkCmdClearColorImagecalls and that Image B's layout remainsVK_IMAGE_LAYOUT_UNDEFINED.Verification (Real Dual-GPU Hardware)
FAIL runtime/test/vk_remove_resource_storage_pending_test.cpp:153: driver::clear_color_calls.load() == 0vk_remove_resource_storage_pending_test: PASS (0 spurious clears, reused ResourceId untouched)vk_remove_resource_storage_pending_test: PASS (0 spurious clears, reused ResourceId untouched)Coordination
VK-REMOVE-RESOURCE-STORAGE-PENDING(no overlapping open PRs or claims).中文翻译
摘要
当创建存储图像(UAV)或稀疏图像时,D3D12 兼容层会通过
VulkanContext::note_shader_image(id)将其ResourceId加入storage_pending_;在下一次带着色器的提交(VulkanQueue::execute_now())中,运行时会取出这些id并对对应图像执行detail::initialize(..., VK_IMAGE_LAYOUT_GENERAL)(对已提交图像会发出vkCmdClearColorImage)。VulkanContext::remove_resource(ResourceId id)(runtime/src/vulkan_backend.h)在storage_mutex_下清理了zero_pending_,但遗漏了清理storage_pending_。如果旧存储图像在着色器提交前被销毁、且新创建的非存储纹理复用了相同的ResourceId(COM 堆地址复用),下一次Dispatch/Draw会误将该新纹理转换到GENERAL并执行vkCmdClearColorImage清零。修复
VulkanContext::remove_resource()的storage_mutex_临界区内增加storage_pending_.erase(id);。runtime/test/vk_remove_resource_storage_pending_test.cpp(CMake 注册名vk_remove_resource_storage_pending),在真实 GPU 上提交最小 SPIR-V 计算着色器Dispatch,验证不会对复用ResourceId的新图像发出误清零或误布局转换。真实双卡 GPU 验证
clear_color_calls != 0失败。PASS (0 spurious clears, reused ResourceId untouched)。PASS (0 spurious clears, reused ResourceId untouched)。协同
VK-REMOVE-RESOURCE-STORAGE-PENDING。🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.