M2(Vulkan): Vulkan mock-game backend + volk/Vulkan-Headers submodules

Add render_vk.cpp (selectable as `vk`): brings up a real Vulkan
instance/device/swap chain via volk (which dlopens vulkan-1.dll -- the
loader-bypass case the capture hook must handle) and clears the swap-chain image
to the frame-counter colour each frame with vkCmdClearColorImage (no pipeline,
no shaders, no SPIR-V) and presents. The whole image encodes the frame number,
so it animates and stale frames are detectable.

Adds the official Khronos Vulkan-Headers + zeux/volk submodules and a
coop_require_submodule() CMake helper that fails with a clear "git submodule
update --init --recursive" message rather than auto-cloning. volk is pinned to
the project's dynamic CRT (no LNK4098).

mock_game_test gets a vk liveness check (its present pointer is cached at init,
so late injection can't hook it -- the capture path needs the early-load path,
to come). 16/16 ctest, skips cleanly without a Vulkan driver.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 12:12:55 +02:00
parent e996188aec
commit 49daa1d81f
11 changed files with 406 additions and 3 deletions

View File

@@ -18,3 +18,26 @@ if(MSVC)
endif()
target_link_libraries(imgui PUBLIC d3d11 dxgi dwmapi)
# --- Vulkan: official Khronos headers + volk meta-loader (submodules) -------
# volk dynamically loads vulkan-1.dll at runtime (no link-time loader lib, no SDK install),
# so the Vulkan mock backend + capture hook need only these two submodules.
coop_require_submodule("Vulkan-Headers" "third_party/Vulkan-Headers/include/vulkan/vulkan.h")
coop_require_submodule("volk" "third_party/volk/volk.h")
add_library(vulkan_headers INTERFACE)
target_include_directories(vulkan_headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers/include)
add_library(volk STATIC volk/volk.c)
target_include_directories(volk PUBLIC volk)
target_link_libraries(volk PUBLIC vulkan_headers)
# VK_NO_PROTOTYPES: volk provides the entry points itself (no link to a loader lib).
target_compile_definitions(volk PUBLIC VK_NO_PROTOTYPES)
if(WIN32)
target_compile_definitions(volk PUBLIC VK_USE_PLATFORM_WIN32_KHR)
endif()
if(MSVC)
target_compile_options(volk PRIVATE /W0) # third-party source
# Match the rest of the project's CRT (dynamic) so it doesn't drag in LIBCMT (LNK4098).
set_target_properties(volk PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()