Repository navigation
Modularize samples - #2667
Modularize samples#2667sharadhr wants to merge 37 commits into
Conversation
d24f9db to
6607f92
Compare
|
I think this is mostly ready, but this branch also includes changes to make Vulkan-Hpp ready for proposed changes in CMake 4.5 that aren't in the public releases yet. These include temporary changes in CI to pull and build with CMake's nightly builds. Additionally, the MSVC build appears to fail regularly with the following error: The invocation does contain Additionally as a stretch goal I want to provide benchmarks, as I think this build of the samples is a reasonably complex attempt at a (mostly) modularised project. To give some preliminary data, I am seeing something like a 2× speedup over a pure header build, and it is slightly slower than the PCH build, but changing a header (and therefore changing the PCH interface and module interface) is much faster. I suspect there is plenty of low-hanging fruit to resolve to speed up the module build. |
|
Do you encounter the MSVC build errors only on CI, or also on local runs?
Indeed. Something that may be even more important than full compilation benchmarks would be iterative builds. Leave the PCH/module as is and just change code that includes/imports those. PCHs are quite large so perhaps there's a measurable difference there. Binary size may also be of note. |
|
There's one thing that makes me wonder: where does that |
|
The utils module is shared between the samples; thats where the concurrent access should be coming from |
I saw it locally in a previous commit, but it seems to have gone away. |
|
Ah. The macOS build fails because that workflow uses CMake 4.1.2, whereas I have modified the CMakeLists to expect 4.5 behaviour (removed |
5e28bdf to
0c481b9
Compare
6e27097 to
2e3252d
Compare
8eb807c to
88d4e79
Compare
88d4e79 to
a57a2d0
Compare
- simplify modules flags for macOS; pass in JSON flag in CI and test
CMake 4.5.0 has been released, so install it with lukka/get-cmake (`latest`) rather than downloading a pinned nightly.
Extract common target setup and Vulkan include-dir logic into shared helpers, and collapse the repetitive option -> compile-definition checks into a loop. Prepares for modularizing sample target setup.
Replace vulkan_hpp__setup_sample_static/_dynamic with a single parametrized vulkan_hpp__setup_sample_variant, removing duplicate wrapper functions and their ~50 call sites.
Needed to reuse it for glm's and (later) utils'/RAII_utils' own modules, not just Vulkan's.
Optionally skip the plain variant (VULKAN_HPP_SAMPLES_BUILD_MODULES_ONLY) for faster module-only iteration.
Platform-conditional constants are baked in at build time; without this they're missing depending on which platform macro was set.
Reordering GLFW after Vulkan needs windows.h's APIENTRY/NOMINMAX defined first, so use vulkan/vulkan.h (not vulkan_core.h) and define NOMINMAX up front.
Modules do not expose macros or incidental declarations from textual headers. Import standard and GLM facilities explicitly, prefer Vulkan-Hpp constants, and isolate required C API headers before module imports.
Import dependencies explicitly, qualify standard-library calls in exported templates, and avoid relying on macros or declarations leaked by textual includes.
Import std directly and neutralize Windows macro collisions so isolated module builds do not depend on textual-header side effects.
Use CMake 4.5's automatic import std support, make module mode select MODULE_* samples without PCHs, and inherit Vulkan-Hpp configuration through module utility targets. Anchor module file sets for isolated test builds.
a57a2d0 to
9826aa6
Compare
An experiment to modularise the samples. utils and RAII_utils are provided as named modules, and all the samples consume them as executables in normal translation units.
This is largely AI-generated (not this commit message), and linker errors are still seen in my local experiments. Do not merge yet.