Repository navigation
runtime: BAR-aware memory fallback and bounded KHR/XDXR stage/query pools (RT-VK-MEMORY-FALLBACK-AND-STAGE-POOL-CAPS) - #1874
Conversation
…ools - Replace single-type vkAllocateMemory picks in PresentComposer::ensure_target, OcclusionResolve::initialize, and VulkanQueue::acquire_stage with ordered memory_type_order + BAR-aware fallback and OOM retry across compatible types, enforcing heap-size bounds (VUID-vkAllocateMemory-pAllocateInfo-01713) and clearing memory handles on failed allocation attempts. - Reject zero-extent compose targets in PresentComposer::ensure_target before vkCreateImage (VUID-VkImageCreateInfo-extent-00944). - Reclaim completed slots' KHR/XDXR stages and postbuild query pools before prepare() allocates fresh ones, switch pool selection to best-fit, and cap khr_stage_pool_ and khr_as_query_pool_ at 8 largest entries so growing world streaming tables do not leak VkDeviceMemory/VkQueryPool allocations. Item: RT-VK-MEMORY-FALLBACK-AND-STAGE-POOL-CAPS
Independent verification — Turing and Blackwell
Environment
NVIDIA 621.14, Vulkan SDK 1.4.363.0, Three repetitions per GPU, revision and validation mode. Results
146 executions: 146 passed, 0 failed, 0 skipped. Findings
No regressions observed on either architecture. Synthetic tests only. No game files used. |
Independent Hardware Verification & Cross-PR Interaction Note (RTX 3090, Windows 11)
Red -> Green Results
Heads-Up: Zero-Conflict CI Interaction with Open PR
|
|
Verified by OreoFR — READY
AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR. |
|
Independent verification on this machine (Windows 11, MSVC 19.44.35226): this pull request applies and builds, and its own new test then fails - and the reason is how far 1. It applies. 2. It builds, and the test is not hardware-dependent - its own header says so: 3. The test fails, on two assertions: which come from: expect(drv.alloc_attempts.size() == 3 && drv.alloc_attempts[0].type == 1 &&
drv.alloc_attempts[1].type == 0 && drv.alloc_attempts[2].type == 2,
"PresentComposer tries VRAM (1) -> BAR (0) -> RAM (2) in order");4. Why a clean merge is not a working tree here: The pull request carries both the implementation and the test, and the file it implements against has been rewritten in What that means for the author: a rebase will not fix this by itself. The fallback order the test demands has to be reconciled with what How it was found: a sweep of open pull requests that replay onto Written with an AI assistant. |
|
I reproduced the two mock failures on Linux and isolated the change in policy. Stock The shared I also tested updating the fixture to the current policy while keeping the merged runtime unchanged. For both PresentComposer and OcclusionResolve, simulated OOM on VRAM now asserts Native Vulkan A/B: CachyOS, clang++ 23.1.5, RTX 4070 SUPER (620.73.04) and Radeon 610M/Raphael (RADV 26.3.1), Khronos validation 1.4.363. The same five CTest entries passed on each GPU with each tree, 20/20 overall. These were AI-assisted: yes (OpenAI Codex). |
Item:
RT-VK-MEMORY-FALLBACK-AND-STAGE-POOL-CAPSClaim: #1608 (comment)
Summary
Fixes three ad-hoc single-type
vkAllocateMemoryhelpers and unbounded per-queue acceleration-structure staging/query pools on the multi-frame world rendering path:BAR-aware memory fallback and heap-size validation (
runtime/src/vulkan_backend.h,runtime/src/vulkan_present_compose.h):detail::device_memory_orderanddetail::host_stage_memory_orderoverleonida::memory_type_order+resizable_bar()(with a fallback for synthetic zero-heap mocks such asreplay_query_edges_test.cppwherememoryHeapCount == 0).PresentComposer::ensure_target: guards zero width/height beforevkCreateImage(VUID-VkImageCreateInfo-extent-00944), avoids placing never-mapped RGBA16F compose targets in a 256 MiB non-ReBAR window when pure VRAM is available, skips undersized heaps (VUID-vkAllocateMemory-pAllocateInfo-01713), and retries remaining compatible types (including system RAM and host-only devices) onvkAllocateMemoryfailure while clearing failed handles before retry.OcclusionResolve::initialize: applies the same BAR-aware ordering, heap-size filtering, OOM retry loop, and cleanup onvkBindBufferMemoryfailure.VulkanQueue::acquire_stage(KHR TLASARRAY_OF_POINTERSand XDXR BLAS-address table staging): prefersDEVICE_LOCALon Resizable BAR GPUs and system RAM (!DEVICE_LOCAL) on non-ReBAR GPUs so per-frame staging does not exhaust the 256 MiB BAR window, skips undersized heaps, and retries remaining host-visible coherent types on OOM.Bounded pools, pre-prepare reclamation, and best-fit reuse (
runtime/src/vulkan_backend.h):VulkanQueue::recycle_completed_khr_pools()soacquire_stage()andallocate_khr_as_queries()reclaim KHR/XDXR stages and postbuildVkQueryPools from already-completed command slots beforeprepare()allocates fresh ones (previouslyrecycle_finished()ran inacquire()afterprepare(), causing steady frame-to-frame traffic to double-allocate).acquire_stage()andallocate_khr_as_queries()to best-fit selection (smallest sufficient pooled entry).khr_stage_pool_andkhr_as_query_pool_at 8 entries (kMaxPooledKhrStages/kMaxPooledKhrAsQueries), keeping the largest stages/pools and destroying evicted allocations immediately so monotonically growingtitle_va_aliasestables or TLAS bursts do not accumulate leakedVkDeviceMemory/VkQueryPoolhandles over sustained streaming.Regression test (
runtime/test/vk_memory_fallback_and_pools_test.cpp,runtime/CMakeLists.txt):Verification
Vulkan-Headers6802bb4733b63ed5efd3adb308a6c885ef180ea1)vk_memory_fallback_and_pools_test.cpp:clang++ -std=c++20 -Wall -Wextra -Werror ... -fsanitize=address,undefined->vk_memory_fallback_and_pools: okclang++ -std=c++20 -Wall -Wextra -Werror ... -fsanitize=thread->vk_memory_fallback_and_pools: okclang++ -std=c++20 -Wall -Wextra -Werror ... -O2(3 runs) ->vk_memory_fallback_and_pools: okvk_host_at_aliasing_test.cpp->vk_host_at_aliasing: okreplay_query_edges_test.cpp-> passedreplay_khr_as_copy_postbuild_test.cpp-> passedmainvulkan_backend.handvulkan_present_compose.h): 25 failures reproduced cleanly, exit code 1.python3 -I scripts/check_no_game_data.py runtime/src/vulkan_backend.h runtime/src/vulkan_present_compose.h runtime/test/vk_memory_fallback_and_pools_test.cpp runtime/CMakeLists.txt-> OKpython3 -I tests/test_text_write_line_endings.py-> 3 tests OK