Repository navigation
runtime: BAR-aware memory fallback and bounded KHR/XDXR stage/query pools (RT-VK-MEMORY-FALLBACK-AND-STAGE-POOL-CAPS) - #1874
Open
IlyassRS3 wants to merge 1 commit into
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
Contributor
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. |
Merged
3 of 4 tasks
Contributor
Independent Hardware Verification & Cross-PR Interaction Note (RTX 3090, Windows 11)
Red -> Green Results
Heads-Up: Zero-Conflict CI Interaction with Open PR
|
Contributor
|
Verified by OreoFR — READY
AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR. |
This was referenced Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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