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

Closed
leonida/mandy
quietfold wants to merge 0 commits from fix/rt-vulkan13-features-enum-and-proc-safety into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

quietfold commented 2026-11-25 16:51:07 +00:00

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.
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.
copilot-pull-request-reviewer[bot] reviewed 2026-11-25 16:51:18 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
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.
MoonEyes commented 2026-11-28 02:51:29 +00:00

Hi @IlyassRS3, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/src/vulkan13_features.h), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

Hi @IlyassRS3, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/src/vulkan13_features.h`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 16:40:12 +00:00

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.
Sign in to join this conversation.
No description provided.