Skip to content

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

Closed
Andretuta wants to merge 1 commit into
mainfrom
old-pr/9794
Closed

Andretuta wants to merge 1 commit into
mainfrom
old-pr/9794

Conversation

@Andretuta

Copy link
Copy Markdown
Collaborator

Carried over from old PR 9794 by totonicpu in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9794, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
totonicpu: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

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)

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@MoonEyes

Copy link
Copy Markdown
Collaborator

Thanks a lot for carrying this over, @Andretuta. The same change is in #1569: it is the same commit from old-pr/9794 (by totonicpu, authorship kept), with the same three files (runtime/CMakeLists.txt, runtime/src/vulkan_predicate.h and the new runtime/test/predicate_alloc_test.cpp), and it was claimed in #14 as OLD-9794.

I am closing this draft so the review happens in one place. Please continue the discussion on #1569, or reopen this one if you see something it misses.

AI-assisted (Claude Code, Claude Opus 5.5)

@MoonEyes MoonEyes closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants