mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:45:53 +01:00
[PR #491] runtime: -DLEONIDA_VULKAN_HEADERS_FETCH=ON uses the pinned Vulkan-Headers even when others are installed (CMAKE-VULKAN-HEADERS-PIN) #541
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#541
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/491
Author: @milk4sale
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:claude/vulkan-headers-pin-0114f6📝 Commits (5)
c8ac7e4runtime: -DLEONIDA_VULKAN_HEADERS_FETCH=ON uses the pinned Vulkan-Headers even when others are installed (CMAKE-VULKAN-HEADERS-PIN)aea4da4runtime: the Vulkan-Headers pin can't be replaced by an installed package (CMAKE-VULKAN-HEADERS-PIN)b7c9afdruntime: a disconnected configure no longer calls the cached Vulkan-Headers "hash-checked" (CMAKE-VULKAN-HEADERS-PIN)5ef40e8Merge main into claude/vulkan-headers-pin-0114f672041e9Merge main into claude/vulkan-headers-pin-0114f6📊 Changes
6 files changed (+566 additions, -16 deletions)
View changed files
📝
docs/gpu_test_results.md(+6 -0)📝
docs/testing.md(+15 -0)📝
runtime/CMakeLists.txt(+49 -15)📝
runtime/README.md(+2 -1)➕
runtime/cmake/vulkan_headers_report.cmake(+104 -0)➕
tests/test_cmake_vulkan_headers_pin.py(+390 -0)📄 Description
Claimed in the coordination issue as: CMAKE-VULKAN-HEADERS-PIN (claim)
What and why
Mby159's finding (record in #431):
runtime/CMakeLists.txtranfind_package(Vulkan QUIET)and thefind_path(Vulkan_INCLUDE_DIR ...)fallback before theLEONIDA_VULKAN_HEADERS_FETCH/FETCHCONTENT_SOURCE_DIR_VULKANHEADERSbranch. Any Vulkan headers on the machine (an SDK, conda-forge'svulkan-headers,/usr/include) therefore definedVulkan::Headersfirst, and the pinned Khronos Vulkan-Headers6802bb47(vulkan-sdk-1.4.363.0, the same commit.github/workflows/runtime.ymlchecks out) were never used, even with-DLEONIDA_VULKAN_HEADERS_FETCH=ON. On a Radeon 780M this changed the GPU counts: against conda-forge's Vulkan 1.3 headersrun_gpu_tests.pyskippedps_texoff,ps_texoff_formsandps_texoff_implicit(225/248 passed instead of 228/248).FETCHCONTENT_SOURCE_DIR_VULKANHEADERS, now runs beforefind_package(Vulkan). FindVulkan still runs afterwards, because it is what findsglslangValidator(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE, used by the shader-building tests). It createsVulkan::Headersonlyif(... NOT TARGET Vulkan::Headers), so the target is defined once. If the fetched project defines noVulkan::Headers, the configure stops instead of quietly falling back to other headers. Without the flag nothing changes and nothing is downloaded.-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS,FetchContent_MakeAvailable()used to tryfind_package(VulkanHeaders)first, so an installedVulkanHeadersConfig.cmake(VK_HEADER_VERSION 111) becameVulkan::Headers, nothing was downloaded, and the line still said "the pin". The declaration now carriesOVERRIDE_FIND_PACKAGE, which stops that try. AfterFetchContent_MakeAvailable(),leonida_vulkan_headers_checkfails the configure unlessVulkan::Headersis the copy FetchContent populated, which covers a dependency provider or an earlierFetchContent_Declare(VulkanHeaders). For the pin, the copy must also have VK_HEADER_VERSIONLEONIDA_VULKAN_HEADERS_PIN_VERSION(363), which covers a stale copy thatFETCHCONTENT_FULLY_DISCONNECTED=ONkeeps after the pin changes.LEONIDA_VULKAN_HEADERS_PIN, which the URL uses, and its VK_HEADER_VERSION inLEONIDA_VULKAN_HEADERS_PIN_VERSION. A test checks both against the two checkouts inruntime.yml(ref: <commit> # vulkan-sdk-1.4.363.0).runtime/cmake/vulkan_headers_report.cmake): AFETCHCONTENT_SOURCE_DIR_VULKANHEADERScopy is reported as such: a local copy that is not checked against the pin. WithFETCHCONTENT_FULLY_DISCONNECTED=ON, FetchContent reuses the copy already inFETCHCONTENT_BASE_DIRand checks no archive. The version check still applies, but the line no longer says "hash-checked" (titoreinaldo's review):docs/testing.md(Build the test programs) anddocs/gpu_test_results.mdnow say: for a result you will post, configure with-DLEONIDA_VULKAN_HEADERS_FETCH=ONand quote theVulkan headers:line. They also note that older entries naming the flag may have used installed headers.runtime/README.mdand the option's doc string no longer say the flag only applies "if no Vulkan headers are found".The fetch stays opt-in rather than becoming the default: the configure downloads nothing unless asked.
#269 (Vulkan header version check for the Windows runtime) edits the same block. This PR doesn't build on it and stays out of its way: the two
endif()lines and theif(TARGET Vulkan::Headers)line where #269 inserts its check are unchanged.git merge-treeof this branch with #269's heada2828eeeis clean, and on the merged treetests/test_cmake_vulkan_headers_version.py,tests/test_cmake_vulkan_headers_pin.pyandtests/test_cmake_vulkan_missing.pyall pass. If both land, #269's advice to pass the flag "with no other headers installed" can drop that qualifier.Tested
CachyOS Linux (kernel 7.3.3), CMake 4.4.5 + Ninja, GCC 16.2.1, system Vulkan headers in
/usr/include(VK_HEADER_VERSION 363):tests/test_cmake_vulkan_headers_pin.py(new, 19 tests, 3.6 s): it configuresruntime/with a fake installed SDK onVULKAN_SDK(VK_HEADER_VERSION 231) and a fake local copy of the pinned project throughFETCHCONTENT_SOURCE_DIR_VULKANHEADERS(363), with no network. Acmake_language(DEFER)hook reads the include directoriesVulkan::Headersreally carries. With FETCH=ON on a fresh build folder, and after turning FETCH on in a folder that already found (and cached) the SDK, the pin is used; turning it off again returns to the SDK. Thecmake -Pcases check the report line and the new check. Onorigin/mainthe first version of the file failed 9/9, and the configure case failed for the bug itself:Vulkan::Headers includes ['/tmp/.../sdk/include'], not /tmp/.../vulkan-headers/include.VulkanHeadersConfig.cmake, VK_HEADER_VERSION 111) onVulkanHeaders_DIR,-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS, noFETCHCONTENT_SOURCE_DIR_VULKANHEADERS, and a fake pin already inFETCHCONTENT_BASE_DIRwithFETCHCONTENT_FULLY_DISCONNECTED=ON. The pin is used. There is also a dependency provider (CMAKE_PROJECT_TOP_LEVEL_INCLUDES) that answers with the package, and a stale copy at version 362; both now fail the configure. On the previous headc8ac7e4athe ALWAYS case fails withVulkan::Headers includes ['/tmp/.../package/include'], not /tmp/.../deps/vulkanheaders-src/include, and the provider configure exits 0 while calling 111 the pin. The disconnected case also asserts the "cached source; archive not checked" wording and no "hash-checked"; onaea4da4cthat assertion fails.c8ac7e4ait exits 0 with no_deps/and prints.../pkg/include (VK_HEADER_VERSION 111), the pin: .... With this PR it downloads the pin and prints<build>/_deps/vulkanheaders-src/include (VK_HEADER_VERSION 363), the pin: ....main,-DLEONIDA_VULKAN_HEADERS_FETCH=ONcreates no_deps/, cachesVulkan_INCLUDE_DIR=/usr/include, andvk_harnesscompiles with no-I. With this PR,compile_commands.jsonhasvk_harnesscompiled with-I<build>/_deps/vulkanheaders-src/includewhile/usr/includeis still found (Vulkan_INCLUDE_DIRandglslangValidatorare cached as before). Without the flag it is/usr/include, as before.ctest --test-dir <build> --output-on-failure(portable subset): 72 tests, 70 passed and 2 skipped (shader_library_corpus,vk_sync_validation), the same onmain, on this PR without the flag, on this PR with the pin, and with the pin under-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYSafter the review fix. The GPU runs below predate the review fix, which leaves the headers of both those builds unchanged (the same-Ipaths).python -I scripts/run_gpu_tests.py(VK_LOADER_DRIVERS_SELECT='*nvidia*',VK_LOADER_LAYERS_DISABLE='~implicit~'):main(system headers) gave 257/257 shaders translated and spirv-val valid, and 197/248 passed, 49 skipped, 2 failed. This PR built against the pin gave the same, with identical per-test statuses. The two failures are the knowncs_imgload_tfe/cs_imgload_d16_tfe(the tfe status VGPR), and the skips are the wave64 fixtures plus the 16 "run by d3d12_*_test" cases, as ingpu-test-results/RTX4070Ti.txt. The system headers here are also 363, so no count difference was expected.tests/test_docs_*.py,tests/test_cmake_*.py,tests/test_build_runtime_cmake.py,tests/test_text_write_line_endings.py,python -m compileall -q make_game.py tools tests, andscripts/check_no_game_data.pyon every changed file: all OK.-DLEONIDA_BUILD_WINDOWS_RUNTIME=OFF -DBUILD_TESTING=OFFand skips when CMake has no working C++ compiler.GPUs tested: NVIDIA GeForce RTX 4070 Ti (AD104), NVIDIA 620.70.06 (proprietary), Vulkan 1.4.357, CachyOS Linux
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.