Skip to content

fix(vulkan): use memory_type_order with OOM fallback in PredicateReducer::batch - #9794

Open
totonicpu wants to merge 1 commit into
ProjectLeonida:mainfrom
totonicpu:pr/fix-predicate-reducer-memory-type-order
Open

totonicpu wants to merge 1 commit into
ProjectLeonida:mainfrom
totonicpu:pr/fix-predicate-reducer-memory-type-order

Conversation

@totonicpu

Copy link
Copy Markdown
Contributor

Summary

Fixes VUID-vkAllocateMemory-pAllocateInfo-01713 and missing OOM memory-type fallback in leonida::PredicateReducer::batch() (runtime/src/vulkan_predicate.h:70-81), matching the memory_type_order() policy used in d3d12_vulkan_device.cpp and vulkan_indirect_dispatch_count.h (#8978):

  • Replaces the hand-rolled single-choice memory-type loop with leonida::memory_type_order() (runtime/src/vulkan_memory.h), skipping any memory type whose heap is smaller than requirements.size (and bounding memoryTypeCount / heapIndex).
  • Iterates through all compatible memory types when vkAllocateMemory() fails (e.g., VK_ERROR_OUT_OF_DEVICE_MEMORY), resetting b->memory = VK_NULL_HANDLE on each failed attempt so ~Batch() cleans up cleanly.

Testing

  • Fail-first proof: Added CPU-only mock test runtime/test/predicate_alloc_test.cpp (registered as predicate_alloc under Vulkan::Headers, no GPU required). Before the fix it failed at line 220: state.alloc_attempts[0].first == 1u (attempting to allocate 2048 B from a 1024 B heap).
  • Build (Debug & RelWithDebInfo, MSVC): 0 new warnings across predicate_alloc_test, d3d12_state_map_test, vk_predicate_capture_test, and vk_command_replay_test.
  • CTest (Debug & RelWithDebInfo) + RTX 4070 Ti with LEONIDA_VK_VALIDATION=1:
    • predicate_alloc: Passed (Debug & RelWithDebInfo)
    • d3d12_state_map: Passed (Debug & RelWithDebInfo)
    • vk_predicate_capture: Passed on NVIDIA GeForce RTX 4070 Ti with Vulkan validation enabled (32 gated + 32 reused submissions, 192 snapshots, 0 validation errors)
    • vk_command_replay: Passed on NVIDIA GeForce RTX 4070 Ti with Vulkan validation enabled (0 validation errors)

@egexon

egexon commented Nov 23, 2026

Copy link
Copy Markdown

Tested 028df8b (merged onto main 2d53a80) on RTX 5070, NVIDIA 621.24, Windows 11 (build 26200), Vulkan validation layer on (LEONIDA_VK_VALIDATION=1, VK_VALIDATION_VALIDATE_SYNC=1): pass.

  • predicate_alloc_test: new test; passes with this PR.

Ran the tests that belong to the test files this PR changes (ctest entries, or the test program directly when it is not registered), with no game files (LEONIDA_GAME_DIR unset). AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants