[PR #1569] OLD-9794: fix(vulkan): use memory_type_order with OOM fallback in PredicateReducer::batch #1592

Open
opened 2026-11-26 20:21:47 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1569
Author: @Tortoche
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: old-9794


📝 Commits (1)

  • dd8625a fix(vulkan): use memory_type_order with OOM fallback in PredicateReducer::batch

📊 Changes

3 files changed (+306 additions, -9 deletions)

View changed files

📝 runtime/CMakeLists.txt (+6 -0)
📝 runtime/src/vulkan_predicate.h (+11 -9)
➕ runtime/test/predicate_alloc_test.cpp (+289 -0)

📄 Description

Item ID: OLD-9794
Carries forward Draft #71 (old-pr/9794 by totonii / totonicpu, preserving original commit authorship at dd8625af6), rebased cleanly onto main (364ab4eab).
Claimed in #14: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7147781405

AI-assisted: yes

Summary

  • runtime/src/vulkan_predicate.h (PredicateReducer::batch):
    • Replace the single-choice memory-type scan with leonida::memory_type_order(memory_, requirements.memoryTypeBits, 0, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, requirements.size) (runtime/src/vulkan_memory.h), filtering out heaps smaller than requirements.size (VUID-vkAllocateMemory-pAllocateInfo-01713).
    • Iterate over all ordered 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 safely.
  • runtime/test/predicate_alloc_test.cpp & runtime/CMakeLists.txt:
    • Add CPU-only mock Vulkan dispatch test predicate_alloc_test (registered as predicate_alloc under if(TARGET Vulkan::Headers)), covering undersized-heap skip, OOM fallback, all-heaps-undersized failure, and all-types-OOM cleanup.

Tests Executed (Linux x86_64, no retail game files / no Windows build)

  • ctest --test-dir runtime/build -C RelWithDebInfo: 71 Passed / 2 Skipped (shader_library_corpus, vk_sync_validation) / 0 Failed out of 73
    • ctest --test-dir runtime/build -C RelWithDebInfo -E "^xdxr_build_check$" --output-on-failure: 70 Passed / 2 Skipped / 0 Failed out of 72 (including predicate_alloc 1/1 and vk_predicate_capture 1/1)
    • Isolated ctest --test-dir runtime/build -C RelWithDebInfo -R "^xdxr_build_check$" --output-on-failure: 2/2 Passed (xdxr_build, xdxr_build_check)
  • ./runtime/build/predicate_alloc_test: OK (predicate_alloc_test: all checks passed)
  • python3 -I tests/test_ci_registration.py: 16/16 passed
  • python3 -I tests/test_ctest_registration.py: 5/5 passed
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed
  • python3 -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/src/vulkan_predicate.h runtime/test/predicate_alloc_test.cpp: OK (exit 0, zero game data)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1569 **Author:** [@Tortoche](https://github.com/Tortoche) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-9794` --- ### 📝 Commits (1) - [`dd8625a`](https://github.com/ubiquitarianism/leonida/commit/dd8625af674e1777e27d50b7a783c15656e3fbbe) fix(vulkan): use memory_type_order with OOM fallback in PredicateReducer::batch ### 📊 Changes **3 files changed** (+306 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+6 -0) 📝 `runtime/src/vulkan_predicate.h` (+11 -9) ➕ `runtime/test/predicate_alloc_test.cpp` (+289 -0) </details> ### 📄 Description Item ID: `OLD-9794` Carries forward Draft `#71` (`old-pr/9794` by `totonii` / `totonicpu`, preserving original commit authorship at `dd8625af6`), rebased cleanly onto `main` (`364ab4eab`). Claimed in `#14`: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7147781405 AI-assisted: yes ### Summary - `runtime/src/vulkan_predicate.h` (`PredicateReducer::batch`): - Replace the single-choice memory-type scan with `leonida::memory_type_order(memory_, requirements.memoryTypeBits, 0, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, requirements.size)` (`runtime/src/vulkan_memory.h`), filtering out heaps smaller than `requirements.size` (`VUID-vkAllocateMemory-pAllocateInfo-01713`). - Iterate over all ordered 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 safely. - `runtime/test/predicate_alloc_test.cpp` & `runtime/CMakeLists.txt`: - Add CPU-only mock Vulkan dispatch test `predicate_alloc_test` (registered as `predicate_alloc` under `if(TARGET Vulkan::Headers)`), covering undersized-heap skip, OOM fallback, all-heaps-undersized failure, and all-types-OOM cleanup. ### Tests Executed (Linux x86_64, no retail game files / no Windows build) - `ctest --test-dir runtime/build -C RelWithDebInfo`: **71 Passed / 2 Skipped** (`shader_library_corpus`, `vk_sync_validation`) **/ 0 Failed out of 73** - `ctest --test-dir runtime/build -C RelWithDebInfo -E "^xdxr_build_check$" --output-on-failure`: **70 Passed / 2 Skipped / 0 Failed out of 72** (including `predicate_alloc` **1/1** and `vk_predicate_capture` **1/1**) - Isolated `ctest --test-dir runtime/build -C RelWithDebInfo -R "^xdxr_build_check$" --output-on-failure`: **2/2 Passed** (`xdxr_build`, `xdxr_build_check`) - `./runtime/build/predicate_alloc_test`: **OK** (`predicate_alloc_test: all checks passed`) - `python3 -I tests/test_ci_registration.py`: **16/16 passed** - `python3 -I tests/test_ctest_registration.py`: **5/5 passed** - `python3 -I tests/test_text_write_line_endings.py`: **3/3 passed** - `python3 -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/src/vulkan_predicate.h runtime/test/predicate_alloc_test.cpp`: **OK** (exit 0, zero game data) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1592
No description provided.