Repository navigation
Address guard: share the page-table buffer across queue families (RT-ADDRESS-GUARD-QUEUE-SHARING) - #2527
Conversation
create_address_guard() made the page table that shaders translated with --address-guard read through its device address with VK_SHARING_MODE_EXCLUSIVE, though those shaders run on the direct and the async-compute queue. The other buffers every queue reads are shared by the device's queue families (DeviceState::share). The create info now comes from address_guard::table_buffer_info(), which shares it the same way (concurrent on two or more families, exclusive on one), with a CPU test. Found by kevincommits (ProjectLeonida#1608). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed at head Verification
Notes
Approve. AI-assisted review + local MSVC verification. |
|
#2527 | head f065771 (merged cleanly with main 09c1539) | |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed the diff and tested merged onto main (493867366) with Ninja Release (MSVC).
Extracting the address guard buffer logic into address_guard_buffer.h with dedicated unit coverage in address_guard_buffer_test.cpp is clean and well scoped.
Tests run
ctest --output-on-failure -R "^address_guard_buffer$": 1/1 passed (address_guard_buffer0.02 s).
AI-assisted (Antigravity, Gemini).
timbot103
left a comment
There was a problem hiding this comment.
Reviewed head f06577169 and found no issues. runtime/shims/d3d12_vulkan_device.cpp:15043 collects the graphics, compute, and copy family indices before guard initialization, skips absent families, and removes duplicates. The resulting device-owned array stays valid through vkCreateBuffer at runtime/shims/d3d12_vulkan_device.cpp:6569. runtime/src/address_guard_buffer.h:14 and runtime/src/queue_families.h:28 select concurrent sharing only for two or more distinct families, so guarded shaders on the graphics and async-compute families can read the page table without an ownership transfer. A single family gets exclusive sharing with a zero count and null pointer.
runtime/test/address_guard_buffer_test.cpp:14 exercises the production helper and would catch an exclusive create-info result for two families. It also checks the single-family fallback, buffer size, and usage flags. runtime/CMakeLists.txt:2409 builds the CPU test with C++20 and Vulkan headers on Windows and Linux, with MSVC options gated on MSVC. The test covers buffer creation parameters. Cross-family shader execution remains unverified by this audit.
Static audit only. No builds, tests, or GPU runs were performed.
AI-assisted.
|
Tested
No blocker from my side. AI-assisted (Claude Code). |
Claimed in the coordination issue as: RT-ADDRESS-GUARD-QUEUE-SHARING (#1608 (comment)). Found by @kevincommits, item 4 of #1608 (comment). Thanks!
What and why
With
LEONIDA_ADDRESS_GUARD,DeviceState::create_address_guard()creates the page table that shaders translated with--address-guardread through its device address. Those shaders run on the direct and the async-compute queue, but the buffer was created withVK_SHARING_MODE_EXCLUSIVE. That is the same class of bug as #2489: on a device with more than one queue family, a buffer one family owns is used by another without an ownership transfer. The other buffers every queue reads are shared throughDeviceState::share(share_across_queue_families).Fix. A small header,
runtime/src/address_guard_buffer.h, builds the create info (address_guard::table_buffer_info): storage plus device address, shared by the device's queue families (concurrent on two or more, exclusive on one).create_address_guard()uses it withfamilies. Nothing else changes.Tested
address_guard_buffer_test(CPU only, no device): two families giveVK_SHARING_MODE_CONCURRENTwith both indices; one family stays exclusive; size and usage are the old ones.gta6rt_d3d12_com(which buildsd3d12_vulkan_device.cpp) builds with MSVC 17, Release; no new warnings.GPUs tested: n/a (CPU test).
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).🤖 Generated with Claude Code