runtime: check vkEnumerateDeviceExtensionProperties results and harden device_proc_or_khr in vulkan13_features #1963

Open
github-bot wants to merge 1 commit from github-bot/gh-1963 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 16:51 UTC · original
IlyassRS3:fix/rt-vulkan13-features-enum-and-proc-safety → main · +164 −10 · 2 files · 1 commits · open

Claim: RT-VULKAN13-FEATURES-ENUM-AND-PROC-SAFETY (claim comment #7168584905 on #1608).

Fixes (runtime/src/vulkan13_features.h)

  1. Check VkResult on both vkEnumerateDeviceExtensionProperties calls (Vulkan 1.2 / MoltenVK path):
    • Previously both calls ignored their VkResult: a failed count query could leave count uninitialized/poisoned and allocate from it, a count == 0 device issued an unnecessary second call, a failed fill query still inspected extensions, a VK_INCOMPLETE fill dropped extensions instead of retrying, and a short fill (count < extensions.size()) scanned unwritten trailing entries.
    • Now query() returns immediately on any error or count == 0, retries VK_INCOMPLETE up to 4 times, and resizes extensions to the actual returned count.
  2. Harden device_proc_or_khr() and eliminate per-lookup heap allocations:
    • Guard against null get, null name, or empty name (previously dereferenced null).
    • Use a 256-byte stack buffer for appending KHR / EXT (with a single-allocation std::string fallback only for unusually long names > 252 bytes) instead of allocating two temporary std::strings per Vulkan device proc lookup.
  3. Consistent compute_full_subgroups gating on Vulkan 1.3:
    • Gate compute_full_subgroups on subgroup_size_control on Vulkan 1.3 (in both query() and enable()), matching the existing Vulkan 1.2 path.

Verification

  • AI-assisted: yes.
  • GPUs tested: none (host is macOS arm64; no retail files; 0 CMakeLists.txt changes).
  • Expanded runtime/test/vulkan13_features_test.cpp to cover count error (poisoned count), count == 0, fill error, transient VK_INCOMPLETE retry, persistent VK_INCOMPLETE bounded exit, short fill ignoring trailing slots, Vulkan 1.3 compute_full_subgroups gating, null/empty device_proc_or_khr inputs, and long-name heap fallback.
  • Ran vulkan13_features_test cleanly under:
    • clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Wno-missing-field-initializers -Werror
    • clang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Wno-missing-field-initializers -Werror
    • clang++ -std=c++20 -O2 -Wall -Wextra -Wno-missing-field-initializers -Werror
  • Ran python3 -I scripts/check_no_game_data.py on both files and python3 -I tests/test_text_write_line_endings.py: all passed.
**@⁠IlyassRS3** on GitHub · 2026-11-25 16:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1963) `IlyassRS3:fix/rt-vulkan13-features-enum-and-proc-safety` → `main` · +164 −10 · 2 files · 1 commits · open Claim: `RT-VULKAN13-FEATURES-ENUM-AND-PROC-SAFETY` (claim comment `#7168584905` on #1608). ### Fixes (`runtime/src/vulkan13_features.h`) 1. **Check `VkResult` on both `vkEnumerateDeviceExtensionProperties` calls (Vulkan 1.2 / MoltenVK path)**: - Previously both calls ignored their `VkResult`: a failed count query could leave `count` uninitialized/poisoned and allocate from it, a `count == 0` device issued an unnecessary second call, a failed fill query still inspected `extensions`, a `VK_INCOMPLETE` fill dropped extensions instead of retrying, and a short fill (`count < extensions.size()`) scanned unwritten trailing entries. - Now `query()` returns immediately on any error or `count == 0`, retries `VK_INCOMPLETE` up to 4 times, and resizes `extensions` to the actual returned `count`. 2. **Harden `device_proc_or_khr()` and eliminate per-lookup heap allocations**: - Guard against null `get`, null `name`, or empty `name` (previously dereferenced null). - Use a 256-byte stack buffer for appending `KHR` / `EXT` (with a single-allocation `std::string` fallback only for unusually long names > 252 bytes) instead of allocating two temporary `std::string`s per Vulkan device proc lookup. 3. **Consistent `compute_full_subgroups` gating on Vulkan 1.3**: - Gate `compute_full_subgroups` on `subgroup_size_control` on Vulkan 1.3 (in both `query()` and `enable()`), matching the existing Vulkan 1.2 path. ### Verification - **AI-assisted**: yes. - **GPUs tested**: none (host is macOS arm64; no retail files; 0 `CMakeLists.txt` changes). - Expanded `runtime/test/vulkan13_features_test.cpp` to cover count error (poisoned count), `count == 0`, fill error, transient `VK_INCOMPLETE` retry, persistent `VK_INCOMPLETE` bounded exit, short fill ignoring trailing slots, Vulkan 1.3 `compute_full_subgroups` gating, null/empty `device_proc_or_khr` inputs, and long-name heap fallback. - Ran `vulkan13_features_test` cleanly under: - `clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Wno-missing-field-initializers -Werror` - `clang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Wno-missing-field-initializers -Werror` - `clang++ -std=c++20 -O2 -Wall -Wextra -Wno-missing-field-initializers -Werror` - Ran `python3 -I scripts/check_no_game_data.py` on both files and `python3 -I tests/test_text_write_line_endings.py`: all passed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:12:57 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 16:51 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 16:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1963#pullrequestreview-6061526570) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
This pull request has changes conflicting with the target branch.
  • runtime/src/vulkan13_features.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1963/head:github-bot/gh-1963'
git switch 'github-bot/gh-1963'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1963'
git switch 'github-bot/gh-1963'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1963'
git switch 'github-bot/gh-1963'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1963'
git switch 'main'
git merge --squash 'github-bot/gh-1963'
git switch 'main'
git merge --ff-only 'github-bot/gh-1963'
git switch 'main'
git merge 'github-bot/gh-1963'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.