Repository navigation
Runtime: erasing a bindless descriptor key no longer idles the GPU - #1863
Conversation
DescriptorTable::erase backward-shifted the key's probe cluster, which moved other live entries, so BindlessSet::erase_key flagged the next flush as needing idle and every texture release ended in vkDeviceWaitIdle on the next submit. The shift is not needed: every lookup, on the CPU and in the translated shaders (rdna2spirv.py desc_probe), compares all eight probe slots and never stops at an empty one. Erase now empties only the key's own slot, and inserts reuse the hole. An erase uploads like an add (one slot, no idle). Replacing a live key's index, a relocating insert and table growth still require idle. Tests: descriptor_table_test checks that an erase in the middle of a cluster leaves every other slot byte-identical and marks one changed slot (it fails on the old erase); vk_bindless_test now expects no idle after an erase.
|
Tested Built with
Not covered: I did not measure the removed No game data involved. AI-assisted (Claude Code): it built the tree and ran everything above on this machine. |
|
Tested Built with MSVC 19.44 / Ninja / Windows SDK 10.0.26100.0 / Vulkan SDK 1.4.363.0 (
(Note: AI-assisted (Antigravity / Gemini); no game files used. |
|
Tested
AI-assisted. |
|
Tested 174ca0a on NVIDIA GeForce RTX 5060 (Blackwell, driver 617.42, Vulkan 1.4.351), Windows 11 Pro build 26300, MSVC (VS 2026), LLVM_MC set, scripts\build_runtime.ps1, then ctest -j 4: builds, and descriptor_table and bindless_sizing pass. 100 of 101 run tests pass; the one failure is d3d12_draw ("fence signal 4 is not above 20"), the same pre-existing fence failure that #1807 fixes, unrelated to this PR. Not covered: vk_bindless_test builds but is not part of ctest (it needs vs_ids.spv / ps_tex.spv), so I did not run it. (Run with an AI coding agent.) |
|
Tested 174ca0a on AMD Radeon RX 7600 (RDNA3), AMD 26.11.2 (LLPC), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0: pass.
AI-assisted (Claude Code, reviewed with Codex). No game files. |
Claimed in the coordination issue as: #1745 (comment)
What and why
DescriptorTable::erasebackward-shifted the erased key's probe cluster. That moved other live entries, soBindlessSet::erase_keysetexisting_entries_changed_and the next flush reportedflush_needs_idle(). The bindless prepare hook (d3d12_vulkan_device.cpp) then ranvkDeviceWaitIdleunder the submit lock. As a result, every texture release (Resourcedestructor →forget_image→erase_key) stalled the whole GPU on the nextExecuteCommandLists. This will matter once the game streams textures; today's synthetic tests release textures only at teardown.The shift is not needed. Every lookup, both on the CPU (
DescriptorTable::lookup/contains/insert_locked) and in the translated shaders (rdna2spirv.pydesc_probe, and the GLSL references inruntime/test/glsl), compares all eight probe slots and never stops at an empty one. A hole therefore breaks no probe chain:erasenow empties only the key's own slot and marks that one slot changed; inserts reuse the hole.erase_keysetstable_dirty_only, so an erase uploads like an add: one slot, no idle. A torn read of the slot being cleared is the same case already accepted for adds, because the erased key is not live.docs/d3d12_vulkan.mdis updated to match.Tested
descriptor_table_test(Windows 11, MSVCity,/std:c++20 /W4, and in the CMakeruntime build): all tests pass. The newtest_erase_moves_no_other_entryerases a key in the middle of a five-key cluster that wraps the end of the table. It checks that every other slot stays byte-identical, that exactly one slot is marked changed, that the remaining keys are still found, and that a new key with the same home reuses the hole. Run against the previousdescriptor_table.h, it fails, as does the updatedtest_change_trackingcheck.vk_bindless_testthroughscripts/run_gpu_tests.py --filter ps_tex(NVIDIA GeForce RTX 3060 Ti, driver 591.86, Windows 11; llvm-mc 23.1.6, SPIRV-Tools 2026.4): PASS, 24 draws read back, 0 bad pixels, largest error 0. The expectation after erasing the T# is now!flush_needs_idle(), and the draw that follows still reads the zero fallback for the miss. Not run with Khronos validation (the Vulkan SDK is not installed here).Checklist
docs/design.md, with how it was confirmed. (Not applicable: no translator change.)AI-assisted