Compare commits

...

45 Commits

Author SHA1 Message Date
Alexandre
cc53d411ef Added a flake 2026-09-01 19:04:20 +02:00
Alexandre
3844f654cb Tweaked error messages in logs 2026-08-31 01:45:39 +02:00
Alexandre
b01fab5b9c Tweaked the gitignore 2026-08-31 01:42:02 +02:00
Alexandre
b25c3d8360 Tweaked help messages, and model loading 2026-08-31 01:40:02 +02:00
Alexandre
87e7db0c87 Added CLI arg and added a model 2026-08-25 23:40:47 +02:00
Alexandre
77ff2d7c0e Working on CLI args 2026-08-23 16:22:22 +02:00
Alexandre
f8b47fbdd4 Changed location of submodules 2026-08-22 12:11:30 +02:00
Alexandre
9236ada59a Added a rectangle, and started reworking logs 2026-08-18 03:13:38 +02:00
Alexandre
2603d12394 Added Viewport, now adding logs 2026-08-13 19:51:57 +02:00
Alexandre
46d150ac1d Commit before change, diverging from vkguide to add a viewport 2026-08-13 18:44:54 +02:00
Alexandre
fe7f7521d8 Added a triangle 2026-08-06 19:54:29 +02:00
Alexandre
c20c6928b1 Picked up vkguide again, switched from slang to glsl.
Created the triangle pipeline
2026-08-06 19:10:46 +02:00
Alexandre
50c0e866cf Dropped VKGUIDE, switching to "How to Vulkan in 2026" by SaschaWillems 2026-07-26 22:30:40 +02:00
Alexandre
49963f3425 Added automatic shader inclusion.
Continued pipeline creation
2026-07-25 21:33:53 +02:00
Alexandre
ec2955436d Added new shaders, modified logs messages, continued the tutorial. 2026-07-23 20:48:42 +02:00
Alexandre
a444a53ea7 Added build date, and version type to build id 2026-07-20 17:25:14 +02:00
Alexandre
79a73b8ceb Modified resize logic 2026-07-20 01:14:21 +02:00
Alexandre
622c0478ac Modified the default dimentions to be 1080p 2026-07-20 00:51:46 +02:00
Alexandre
e3fd8a5b2b Fixed some format missmatch 2026-07-20 00:25:56 +02:00
Alexandre
f54f70d9d4 Added more shaders, and an ImGui window to choose the shader 2026-07-20 00:13:12 +02:00
Alexandre
891e178008 Added resize, started doing multiple shaders 2026-07-14 21:04:05 +02:00
Alexandre
bf2e15fcd3 Added imgui 2026-07-14 15:43:10 +02:00
Alexandre
d5d8dc50e4 Compiles, but validation errors prevent it from running 2026-07-02 21:15:33 +02:00
Alexandre
5308e0777b Switched all structs to designated initializers, didn't test building it as I was offline 2026-06-26 19:14:05 +02:00
Alexandre
f05e1605d6 Forgot to init ImGUI, oops 2026-06-09 22:57:10 +02:00
Alexandre
f5965b2142 Added ImGUI demo for compilation 2026-06-09 22:56:11 +02:00
Alexandre
76947a59ee Added ImGUI into the render loop, not tested atm 2026-06-09 22:54:53 +02:00
Alexandre
78b5577ff2 Modified some cmake things 2026-06-09 20:42:06 +02:00
Alexandre
2e111c13e9 Added ImGUI, not called, so benchmark without imgui from here 2026-06-09 20:32:19 +02:00
Alexandre
e9af67ad25 Now draws a gradient with compute 2026-05-28 23:32:38 +02:00
Alexandre
921832a950 Added a descriptor set builder, changed some filepaths and added a basic server 2026-05-24 13:13:20 +02:00
Alexandre
d3cc173d97 Splitted code into folder (see previous commit) 2026-05-05 11:44:41 +02:00
Alexandre
48a88078cd Started adding a server binary, and added common headers, for a modular
approach.
2026-05-05 11:44:15 +02:00
Alexandre
03a30c0096 Fixed a CMake error 2026-05-04 19:11:00 +02:00
Alexandre
a3b498d11b Extended the swapchain creation process 2026-04-23 08:54:57 +02:00
Alexandre
04763de733 Added a version id, the current git hash 2026-04-23 08:28:02 +02:00
Alexandre
a05df4d541 Added a deletion queue, and started reworking the render method 2026-04-22 22:54:24 +02:00
Alexandre
83c5c0bde4 The engine now displays a blue flashing square 2026-04-19 20:37:16 +02:00
Alexandre
0e1c4da452 Create callbacks.h 2026-04-19 01:38:18 +02:00
Alexandre
102e4de093 Switched to GLFW 2026-04-19 01:38:12 +02:00
Alexandre
8cf07095dd Started the engine, using a 'header-only' architecture for compoments of the engine 2026-04-18 23:22:13 +02:00
Alexandre
13327f6fc3 Started the engine, using a 'header-only' architecture for compoments of the engine 2026-04-18 23:22:06 +02:00
Alexandre
7be2cf162d Update README.md 2026-04-18 14:53:37 +02:00
Alexandre
ca590a987b Update README.md 2026-04-18 14:51:30 +02:00
Alexandre
5c52aafc77 Started the vkguide branch, removed everything, exept the licence and
readme
2026-04-18 14:50:50 +02:00
76 changed files with 6674 additions and 289282 deletions

View File

@ -0,0 +1,633 @@
{
"date": "2026-08-25T23:21:08.955192774+02:00",
"data": {
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/book/CMakeLists.txt": [
{
"label": "book_sources",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/book/CMakeLists.txt"
}
],
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/fuzz/CMakeLists.txt": [
{
"label": "CLI11_FUZZ_ARTIFACT_PATH",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/fuzz/CMakeLists.txt"
},
{
"label": "CLI11_FUZZ_TIME_APP",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/fuzz/CMakeLists.txt"
},
{
"label": "CLI11_FUZZ_TIME_FILE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/fuzz/CMakeLists.txt"
}
],
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/single-include/CMakeLists.txt": [
{
"label": "Python::Interpreter",
"kind": 6,
"detail": "Variable",
"documentation": "package from: Python"
},
{
"label": "Python_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: Python"
},
{
"label": "Python_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: Python"
}
],
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt": [
{
"label": "VERSION_REGEX",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "Doxygen_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: Doxygen"
},
{
"label": "Doxygen_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: Doxygen"
},
{
"label": "BUILD_TESTING",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "docs_EXIST",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "docs_EXIST",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "examples_EXIST",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "examples_EXIST",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CLI11_WARNINGS_AS_ERRORS",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CLI11_SINGLE_FILE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CLI11_PRECOMPILED",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CLI11_MODULES",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CMAKE_CXX_STANDARD",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CMAKE_CXX_EXTENSIONS",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CMAKE_CXX_STANDARD_REQUIRED",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CMAKE_CXX_STANDARD_LIBRARIES_INIT",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CMAKE_CXX_STANDARD_LIBRARIES",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CLI11_headerLoc",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CLI11_headers",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CLI11_impl_headers",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CLI11_library_headers",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CMAKE_CUDA_FLAGS",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt\n\nPrint out warning and error numbers"
},
{
"label": "CPACK_PACKAGE_VENDOR",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CPACK_PACKAGE_CONTACT",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CPACK_PACKAGE_VERSION_MAJOR",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CPACK_PACKAGE_VERSION_MINOR",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt\n\nAutomatic in CMake 3.12+"
},
{
"label": "CPACK_PACKAGE_VERSION_PATCH",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt\n\nAutomatic in CMake 3.12+"
},
{
"label": "CPACK_PACKAGE_DESCRIPTION_SUMMARY",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt\n\nAutomatic in CMake 3.12+"
},
{
"label": "CPACK_RESOURCE_FILE_LICENSE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CPACK_RESOURCE_FILE_README",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CPACK_PACKAGE_DESCRIPTION_FILE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CPACK_SOURCE_GENERATOR",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CPACK_SOURCE_IGNORE_FILES",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt\n\nCPack collects *everything* except what's listed here."
},
{
"label": "CPACK_DEBIAN_PACKAGE_ARCHITECTURE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CPACK_DEBIAN_COMPRESSION_TYPE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
},
{
"label": "CPACK_DEBIAN_PACKAGE_NAME",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
}
],
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt": [
{
"label": "add_dependent_application_definitions",
"kind": 3,
"detail": "Function",
"documentation": "defined function\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "add_sanitizers",
"kind": 3,
"detail": "Function",
"documentation": "defined macro\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "add_catch_test",
"kind": 3,
"detail": "Function",
"documentation": "defined macro\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt\n\nTarget must already exist"
},
{
"label": "Sanitizers_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: Sanitizers"
},
{
"label": "Sanitizers_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: Sanitizers"
},
{
"label": "CLI11_BOOST",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt\n\nAdd boost to test boost::optional (currently explicitly requested)\""
},
{
"label": "Boost_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: Boost"
},
{
"label": "Boost_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: Boost"
},
{
"label": "Boost_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: Boost"
},
{
"label": "Boost_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: Boost"
},
{
"label": "boost-optional-def",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "CLI11_TESTS",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "CLI11_MULTIONLY_TESTS",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "Catch2_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: Catch2"
},
{
"label": "Catch2_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: Catch2"
},
{
"label": "catch2_url",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "catch2_header",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "catch2_hash",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "CLI11_DEPENDENT_APPLICATIONS",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt\n\nBuild dependent applications which are launched from test code"
},
{
"label": "TEST_FILE_FOLDER",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "Threads_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: Threads"
},
{
"label": "Threads_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: Threads"
},
{
"label": "no-deprecated-declarations",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt\n\nAdd -Wno-deprecated-declarations to DeprecatedTest"
},
{
"label": "cli11_boost_target",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "cli11_boost_target",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "CLI11_PACKAGE_SEARCH_LOC",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "package_test_command",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "package_test_command",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt\n\nsome other setup that isn't that important to run on all OS"
},
{
"label": "CLI11_PACKAGE_TEST_BUILD_TYPE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
},
{
"label": "CLI11_PACKAGE_TEST_BUILD_TYPE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt"
}
],
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt": [
{
"label": "PUBLIC_OR_INTERFACE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt"
},
{
"label": "PUBLIC_OR_INTERFACE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt"
},
{
"label": "SYSTEM_INCL",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt"
},
{
"label": "SYSTEM_INCL",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt\n\nthe compiler emitting any warnings about them"
}
],
"/home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt": [
{
"label": "addGlslShader",
"kind": 3,
"detail": "Function",
"documentation": "defined function\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt\n\nHelper functions to build shaders"
},
{
"label": "addSlangShader",
"kind": 3,
"detail": "Function",
"documentation": "defined function\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "addBinary",
"kind": 3,
"detail": "Function",
"documentation": "defined function\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt\n\nA function to automate executables aditions"
},
{
"label": "CMAKE_EXPORT_COMPILE_COMMANDS",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "CMAKE_AR",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "CMAKE_RANLIB",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "glfw3_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: glfw3"
},
{
"label": "glfw3_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: glfw3"
},
{
"label": "glm_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: glm"
},
{
"label": "glm_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: glm"
},
{
"label": "VulkanMemoryAllocator_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: VulkanMemoryAllocator"
},
{
"label": "VulkanMemoryAllocator_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: VulkanMemoryAllocator"
},
{
"label": "fmt_LIBRARIES",
"kind": 6,
"detail": "Variable",
"documentation": "package: fmt"
},
{
"label": "fmt_INCLUDE_DIRS",
"kind": 6,
"detail": "Variable",
"documentation": "package: fmt"
},
{
"label": "SPV_FILE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "SPV_FILE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "SPV_FILE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "SPV_FILE",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "SHADER_OUTPUT_DIR",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "ALL_SPV_FILES",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "EXPANDED_SHADERS",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "SHADER_SRC",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt"
},
{
"label": "RESOLVED_MODELS",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt\n\nAdds the 3D models in the binary folder"
},
{
"label": "RESOLVED_TEXTURES",
"kind": 12,
"detail": "Value",
"documentation": "defined variable\nfrom: /home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt\n\nAdds the textures in the binary folder"
}
],
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/CMakeLists.txt": [
{
"label": "add_cli_exe",
"kind": 3,
"detail": "Function",
"documentation": "defined function\nfrom: /home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/CMakeLists.txt"
}
]
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
{
"date": "2026-08-26T14:26:46.281424105+02:00",
"data": {
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/cmake/CLI11GeneratePkgConfig.cmake": [
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
]
}
}

View File

@ -0,0 +1,15 @@
{
"date": "2026-08-26T14:26:46.281337341+02:00",
"data": {
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/docs/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt",
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt",
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/modules/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt",
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/single-include/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt",
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt",
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/subcom_in_files/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/CMakeLists.txt",
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt",
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/fuzz/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt",
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt",
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/book/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
}
}

14
.clangd Normal file
View File

@ -0,0 +1,14 @@
CompileFlags:
CompilationDatabase: bin/debug
Add:
- -DENGINE_IMPL
- -DIMAGES_IMPL
- -DINITIALIZERS_IMPL
- -DPIPELINES_IMPL
- -DDESCRIPTORS_IMPL
- -DCALLBACK_IMPL
- -DTIMER_IMPL
- -DLOGGER_IMPL
- -DSERVER_INIT_IMPL
- -DSERVER_IMPL
- -DLOADER_IMPL

6
.gitignore vendored
View File

@ -1,6 +1,8 @@
# Build directories
build/
build-*/
bin/
bin-*/
cmake-build-*/
# CMake generated files
@ -35,6 +37,10 @@ Thumbs.db
# direnv
.direnv/
# cache
.cache/
# Nix flakes
result
result-*
.cache/neocmakelsp/

8
.gitmodules vendored Normal file
View File

@ -0,0 +1,8 @@
[submodule "include/imgui"]
path = include/imgui
url = https://github.com/ocornut/imgui.git
branch = docking
[submodule "include/CLI11"]
path = include/CLI11
url = https://github.com/CLIUtils/CLI11.git

56
CMake/BuildInfo.cmake Normal file
View File

@ -0,0 +1,56 @@
find_package(Git)
if (GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE ENGINE_VERSION
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE ENGINE_HASH
RESULT_VARIABLE GIT_HASH_ERROR_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
set(GIT_DEPS "${CMAKE_SOURCE_DIR}/.git/HEAD")
if(GIT_BRANCH AND EXISTS "${CMAKE_SOURCE_DIR}/.git/refs/heads/${GIT_BRANCH}")
list(APPEND GIT_DEPS "${CMAKE_SOURCE_DIR}/.git/refs/heads/${GIT_BRANCH}")
endif()
# Optionnel : index pour les modifications stagées
if(EXISTS "${CMAKE_SOURCE_DIR}/.git/index")
list(APPEND GIT_DEPS "${CMAKE_SOURCE_DIR}/.git/index")
endif()
# On définit la propriété pour le répertoire source.
set_directory_properties(PROPERTIES CMAKE_CONFIGURE_DEPENDS "${GIT_DEPS}")
endif()
# Fallback
if (NOT ENGINE_VERSION OR GIT_DESCRIBE_ERROR_CODE)
set(ENGINE_VERSION "0.0.0")
message(WARNING "No Git tag found, using default version ${ENGINE_VERSION}, fix this....")
endif()
if (NOT ENGINE_HASH OR GIT_HASH_ERROR_CODE)
set(ENGINE_HASH "0000000")
message(WARNING "No Git hash found, using default hash ${ENGINE_HASH}")
endif()
string(REGEX REPLACE "^v" "" ENGINE_VERSION "${ENGINE_VERSION}")
set(ENGINE_VERSION "${ENGINE_VERSION}-${CMAKE_BUILD_TYPE}")
message(STATUS "Engine Version: ${ENGINE_VERSION}")

View File

@ -1,106 +0,0 @@
# FindKTX.cmake
#
# Finds the KTX library
#
# This will define the following variables
#
# KTX_FOUND
# KTX_INCLUDE_DIRS
# KTX_LIBRARIES
#
# and the following imported targets
#
# KTX::ktx
#
# Check if we're on Linux - if so, we'll skip the search and directly use FetchContent
if(UNIX AND NOT APPLE)
# On Linux, we assume KTX is not installed and proceed directly to fetching it
set(KTX_FOUND FALSE)
else()
# On non-Linux platforms, try to find KTX using pkg-config first
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_KTX QUIET ktx libktx ktx2 libktx2)
endif()
# Try to find KTX using standard find_package
find_path(KTX_INCLUDE_DIR
NAMES ktx.h
PATH_SUFFIXES include ktx KTX ktx2 KTX2
HINTS
${PC_KTX_INCLUDEDIR}
/usr/include
/usr/local/include
$ENV{KTX_DIR}/include
$ENV{VULKAN_SDK}/include
${CMAKE_SOURCE_DIR}/external/ktx/include
)
find_library(KTX_LIBRARY
NAMES ktx ktx2 libktx libktx2
PATH_SUFFIXES lib lib64
HINTS
${PC_KTX_LIBDIR}
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
$ENV{KTX_DIR}/lib
$ENV{VULKAN_SDK}/lib
${CMAKE_SOURCE_DIR}/external/ktx/lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(KTX
REQUIRED_VARS KTX_INCLUDE_DIR KTX_LIBRARY
FAIL_MESSAGE "" # Suppress the error message to allow our fallback
)
# Debug output if KTX is not found (only on non-Linux platforms)
if(NOT KTX_FOUND)
message(STATUS "KTX include directory search paths: ${PC_KTX_INCLUDEDIR}, /usr/include, /usr/local/include, $ENV{KTX_DIR}/include, $ENV{VULKAN_SDK}/include, ${CMAKE_SOURCE_DIR}/external/ktx/include")
message(STATUS "KTX library search paths: ${PC_KTX_LIBDIR}, /usr/lib, /usr/lib64, /usr/local/lib, /usr/local/lib64, $ENV{KTX_DIR}/lib, $ENV{VULKAN_SDK}/lib, ${CMAKE_SOURCE_DIR}/external/ktx/lib")
endif()
endif()
if(KTX_FOUND)
set(KTX_INCLUDE_DIRS ${KTX_INCLUDE_DIR})
set(KTX_LIBRARIES ${KTX_LIBRARY})
if(NOT TARGET KTX::ktx)
add_library(KTX::ktx UNKNOWN IMPORTED)
set_target_properties(KTX::ktx PROPERTIES
IMPORTED_LOCATION "${KTX_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${KTX_INCLUDE_DIRS}"
)
endif()
else()
# If not found, use FetchContent to download and build
include(FetchContent)
# Only show the message on non-Linux platforms
if(NOT (UNIX AND NOT APPLE))
message(STATUS "KTX not found, fetching from GitHub...")
endif()
FetchContent_Declare(
ktx
GIT_REPOSITORY https://github.com/KhronosGroup/KTX-Software.git
GIT_TAG v4.3.1 # Use a specific tag for stability
)
# Set options to minimize build time and dependencies
set(KTX_FEATURE_TOOLS OFF CACHE BOOL "Build KTX tools" FORCE)
set(KTX_FEATURE_DOC OFF CACHE BOOL "Build KTX documentation" FORCE)
set(KTX_FEATURE_TESTS OFF CACHE BOOL "Build KTX tests" FORCE)
FetchContent_MakeAvailable(ktx)
# Create an alias to match the expected target name
if(NOT TARGET KTX::ktx)
add_library(KTX::ktx ALIAS ktx)
endif()
set(KTX_FOUND TRUE)
endif()

View File

@ -1,937 +0,0 @@
# Updates for iOS Copyright (c) 2024, Holochip Inc.
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindVulkan
----------
.. versionadded:: 3.7
Find Vulkan, which is a low-overhead, cross-platform 3D graphics
and computing API.
Optional COMPONENTS
^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.24
This module respects several optional COMPONENTS.
There are corresponding imported targets for each of these.
``glslc``
The SPIR-V compiler.
``glslangValidator``
The ``glslangValidator`` tool.
``glslang``
The SPIR-V generator library.
``shaderc_combined``
The static library for Vulkan shader compilation.
``SPIRV-Tools``
Tools to process SPIR-V modules.
``MoltenVK``
On macOS, an additional component ``MoltenVK`` is available.
``dxc``
.. versionadded:: 3.25
The DirectX Shader Compiler.
The ``glslc`` and ``glslangValidator`` components are provided even
if not explicitly requested (for backward compatibility).
IMPORTED Targets
^^^^^^^^^^^^^^^^
This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found:
``Vulkan::Vulkan``
The main Vulkan library.
``Vulkan::glslc``
.. versionadded:: 3.19
The GLSLC SPIR-V compiler, if it has been found.
``Vulkan::Headers``
.. versionadded:: 3.21
Provides just Vulkan headers include paths, if found. No library is
included in this target. This can be useful for applications that
load Vulkan library dynamically.
``Vulkan::glslangValidator``
.. versionadded:: 3.21
The glslangValidator tool, if found. It is used to compile GLSL and
HLSL shaders into SPIR-V.
``Vulkan::glslang``
.. versionadded:: 3.24
Defined if SDK has the Khronos-reference front-end shader parser and SPIR-V
generator library (glslang).
``Vulkan::shaderc_combined``
.. versionadded:: 3.24
Defined if SDK has the Google static library for Vulkan shader compilation
(shaderc_combined).
``Vulkan::SPIRV-Tools``
.. versionadded:: 3.24
Defined if SDK has the Khronos library to process SPIR-V modules
(SPIRV-Tools).
``Vulkan::MoltenVK``
.. versionadded:: 3.24
Defined if SDK has the Khronos library which implement a subset of Vulkan API
over Apple Metal graphics framework. (MoltenVK).
``Vulkan::volk``
.. versionadded:: 3.25
Defined if SDK has the Vulkan meta-loader (volk).
``Vulkan::dxc_lib``
.. versionadded:: 3.25
Defined if SDK has the DirectX shader compiler library.
``Vulkan::dxc_exe``
.. versionadded:: 3.25
Defined if SDK has the DirectX shader compiler CLI tool.
Result Variables
^^^^^^^^^^^^^^^^
This module defines the following variables:
``Vulkan_FOUND``
set to true if Vulkan was found
``Vulkan_INCLUDE_DIRS``
include directories for Vulkan
``Vulkan_LIBRARIES``
link against this library to use Vulkan
``Vulkan_VERSION``
.. versionadded:: 3.23
value from ``vulkan/vulkan_core.h``
``Vulkan_glslc_FOUND``
.. versionadded:: 3.24
True, if the SDK has the glslc executable.
``Vulkan_glslangValidator_FOUND``
.. versionadded:: 3.24
True, if the SDK has the glslangValidator executable.
``Vulkan_glslang_FOUND``
.. versionadded:: 3.24
True, if the SDK has the glslang library.
``Vulkan_shaderc_combined_FOUND``
.. versionadded:: 3.24
True, if the SDK has the shaderc_combined library.
``Vulkan_SPIRV-Tools_FOUND``
.. versionadded:: 3.24
True, if the SDK has the SPIRV-Tools library.
``Vulkan_MoltenVK_FOUND``
.. versionadded:: 3.24
True, if the SDK has the MoltenVK library.
``Vulkan_volk_FOUND``
.. versionadded:: 3.25
True, if the SDK has the volk library.
``Vulkan_dxc_lib_FOUND``
.. versionadded:: 3.25
True, if the SDK has the DirectX shader compiler library.
``Vulkan_dxc_exe_FOUND``
.. versionadded:: 3.25
True, if the SDK has the DirectX shader compiler CLI tool.
The module will also defines these cache variables:
``Vulkan_INCLUDE_DIR``
the Vulkan include directory
``Vulkan_LIBRARY``
the path to the Vulkan library
``Vulkan_GLSLC_EXECUTABLE``
the path to the GLSL SPIR-V compiler
``Vulkan_GLSLANG_VALIDATOR_EXECUTABLE``
the path to the glslangValidator tool
``Vulkan_glslang_LIBRARY``
.. versionadded:: 3.24
Path to the glslang library.
``Vulkan_shaderc_combined_LIBRARY``
.. versionadded:: 3.24
Path to the shaderc_combined library.
``Vulkan_SPIRV-Tools_LIBRARY``
.. versionadded:: 3.24
Path to the SPIRV-Tools library.
``Vulkan_MoltenVK_LIBRARY``
.. versionadded:: 3.24
Path to the MoltenVK library.
``Vulkan_volk_LIBRARY``
.. versionadded:: 3.25
Path to the volk library.
``Vulkan_dxc_LIBRARY``
.. versionadded:: 3.25
Path to the DirectX shader compiler library.
``Vulkan_dxc_EXECUTABLE``
.. versionadded:: 3.25
Path to the DirectX shader compiler CLI tool.
Hints
^^^^^
.. versionadded:: 3.18
The ``VULKAN_SDK`` environment variable optionally specifies the
location of the Vulkan SDK root directory for the given
architecture. It is typically set by sourcing the toplevel
``setup-env.sh`` script of the Vulkan SDK directory into the shell
environment.
#]=======================================================================]
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW)
# Provide compatibility with a common invalid component request that
# was silently ignored prior to CMake 3.24.
if("FATAL_ERROR" IN_LIST Vulkan_FIND_COMPONENTS)
message(AUTHOR_WARNING
"Ignoring unknown component 'FATAL_ERROR'.\n"
"The find_package() command documents no such argument."
)
list(REMOVE_ITEM Vulkan_FIND_COMPONENTS "FATAL_ERROR")
endif()
if(IOS)
get_filename_component(Vulkan_Target_SDK "$ENV{VULKAN_SDK}/.." REALPATH)
list(APPEND CMAKE_FRAMEWORK_PATH "${Vulkan_Target_SDK}/iOS/lib")
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
endif()
# For backward compatibility as `FindVulkan` in previous CMake versions allow to retrieve `glslc`
# and `glslangValidator` without requesting the corresponding component.
if(NOT glslc IN_LIST Vulkan_FIND_COMPONENTS)
list(APPEND Vulkan_FIND_COMPONENTS glslc)
endif()
if(NOT glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
list(APPEND Vulkan_FIND_COMPONENTS glslangValidator)
endif()
if(WIN32)
set(_Vulkan_library_name vulkan-1)
set(_Vulkan_hint_include_search_paths
"$ENV{VULKAN_SDK}/include"
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_Vulkan_hint_executable_search_paths
"$ENV{VULKAN_SDK}/bin"
)
set(_Vulkan_hint_library_search_paths
"$ENV{VULKAN_SDK}/lib"
"$ENV{VULKAN_SDK}/bin"
)
else()
set(_Vulkan_hint_executable_search_paths
"$ENV{VULKAN_SDK}/bin32"
"$ENV{VULKAN_SDK}/bin"
)
set(_Vulkan_hint_library_search_paths
"$ENV{VULKAN_SDK}/lib32"
"$ENV{VULKAN_SDK}/bin32"
"$ENV{VULKAN_SDK}/lib"
"$ENV{VULKAN_SDK}/bin"
)
endif()
else()
set(_Vulkan_library_name vulkan)
set(_Vulkan_hint_include_search_paths
"$ENV{VULKAN_SDK}/include"
)
set(_Vulkan_hint_executable_search_paths
"$ENV{VULKAN_SDK}/bin"
)
set(_Vulkan_hint_library_search_paths
"$ENV{VULKAN_SDK}/lib"
)
endif()
if(APPLE AND DEFINED ENV{VULKAN_SDK})
list(APPEND _Vulkan_hint_include_search_paths
"${Vulkan_Target_SDK}/macOS/include"
)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
list(APPEND _Vulkan_hint_library_search_paths
"${Vulkan_Target_SDK}/iOS/lib"
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
list(APPEND _Vulkan_hint_library_search_paths
"${Vulkan_Target_SDK}/tvOS/lib"
)
else()
list(APPEND _Vulkan_hint_library_search_paths
"${Vulkan_Target_SDK}}/lib"
)
endif()
endif()
find_path(Vulkan_INCLUDE_DIR
NAMES vulkan/vulkan.h
HINTS
${_Vulkan_hint_include_search_paths}
)
message(STATUS "vulkan_include_dir ${Vulkan_INCLUDE_DIR} search paths ${_Vulkan_hint_include_search_paths}")
mark_as_advanced(Vulkan_INCLUDE_DIR)
find_library(Vulkan_LIBRARY
NAMES ${_Vulkan_library_name}
HINTS
${_Vulkan_hint_library_search_paths}
)
message(STATUS "vulkan_library ${Vulkan_LIBRARY} search paths ${_Vulkan_hint_library_search_paths}")
mark_as_advanced(Vulkan_LIBRARY)
find_library(Vulkan_Layer_API_DUMP
NAMES VkLayer_api_dump
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_Layer_API_DUMP)
find_library(Vulkan_Layer_SHADER_OBJECT
NAMES VkLayer_khronos_shader_object
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(VkLayer_khronos_shader_object)
find_library(Vulkan_Layer_SYNC2
NAMES VkLayer_khronos_synchronization2
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_Layer_SYNC2)
find_library(Vulkan_Layer_VALIDATION
NAMES VkLayer_khronos_validation
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_Layer_VALIDATION)
if(glslc IN_LIST Vulkan_FIND_COMPONENTS)
find_program(Vulkan_GLSLC_EXECUTABLE
NAMES glslc
HINTS
${_Vulkan_hint_executable_search_paths}
)
mark_as_advanced(Vulkan_GLSLC_EXECUTABLE)
endif()
if(glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE
NAMES glslangValidator
HINTS
${_Vulkan_hint_executable_search_paths}
)
mark_as_advanced(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
endif()
if(glslang IN_LIST Vulkan_FIND_COMPONENTS)
find_library(Vulkan_glslang-spirv_LIBRARY
NAMES SPIRV
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-spirv_LIBRARY)
find_library(Vulkan_glslang-spirv_DEBUG_LIBRARY
NAMES SPIRVd
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-spirv_DEBUG_LIBRARY)
find_library(Vulkan_glslang-oglcompiler_LIBRARY
NAMES OGLCompiler
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-oglcompiler_LIBRARY)
find_library(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY
NAMES OGLCompilerd
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)
find_library(Vulkan_glslang-osdependent_LIBRARY
NAMES OSDependent
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-osdependent_LIBRARY)
find_library(Vulkan_glslang-osdependent_DEBUG_LIBRARY
NAMES OSDependentd
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-osdependent_DEBUG_LIBRARY)
find_library(Vulkan_glslang-machineindependent_LIBRARY
NAMES MachineIndependent
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-machineindependent_LIBRARY)
find_library(Vulkan_glslang-machineindependent_DEBUG_LIBRARY
NAMES MachineIndependentd
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)
find_library(Vulkan_glslang-genericcodegen_LIBRARY
NAMES GenericCodeGen
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-genericcodegen_LIBRARY)
find_library(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY
NAMES GenericCodeGend
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)
find_library(Vulkan_glslang_LIBRARY
NAMES glslang
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang_LIBRARY)
find_library(Vulkan_glslang_DEBUG_LIBRARY
NAMES glslangd
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_glslang_DEBUG_LIBRARY)
endif()
if(shaderc_combined IN_LIST Vulkan_FIND_COMPONENTS)
find_library(Vulkan_shaderc_combined_LIBRARY
NAMES shaderc_combined
HINTS
${_Vulkan_hint_library_search_paths})
mark_as_advanced(Vulkan_shaderc_combined_LIBRARY)
find_library(Vulkan_shaderc_combined_DEBUG_LIBRARY
NAMES shaderc_combinedd
HINTS
${_Vulkan_hint_library_search_paths})
mark_as_advanced(Vulkan_shaderc_combined_DEBUG_LIBRARY)
endif()
if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS)
find_library(Vulkan_SPIRV-Tools_LIBRARY
NAMES SPIRV-Tools
HINTS
${_Vulkan_hint_library_search_paths})
mark_as_advanced(Vulkan_SPIRV-Tools_LIBRARY)
find_library(Vulkan_SPIRV-Tools_DEBUG_LIBRARY
NAMES SPIRV-Toolsd
HINTS
${_Vulkan_hint_library_search_paths})
mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
endif()
if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS)
# CMake has a bug in 3.28 that doesn't handle xcframeworks. Do it by hand for now.
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
if(CMAKE_VERSION VERSION_LESS 3.29)
set( _Vulkan_hint_library_search_paths ${Vulkan_Target_SDK}/ios/lib/MoltenVK.xcframework/ios-arm64)
else ()
set( _Vulkan_hint_library_search_paths ${Vulkan_Target_SDK}/ios/lib/)
endif ()
endif ()
find_library(Vulkan_MoltenVK_LIBRARY
NAMES MoltenVK
HINTS
${_Vulkan_hint_library_search_paths}
)
mark_as_advanced(Vulkan_MoltenVK_LIBRARY)
find_path(Vulkan_MoltenVK_INCLUDE_DIR
NAMES MoltenVK/mvk_vulkan.h
HINTS
${_Vulkan_hint_include_search_paths}
)
mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR)
endif()
if(volk IN_LIST Vulkan_FIND_COMPONENTS)
find_library(Vulkan_volk_LIBRARY
NAMES volk
HINTS
${_Vulkan_hint_library_search_paths})
mark_as_advanced(Vulkan_Volk_LIBRARY)
endif()
if (dxc IN_LIST Vulkan_FIND_COMPONENTS)
find_library(Vulkan_dxc_LIBRARY
NAMES dxcompiler
HINTS
${_Vulkan_hint_library_search_paths})
mark_as_advanced(Vulkan_dxc_LIBRARY)
find_program(Vulkan_dxc_EXECUTABLE
NAMES dxc
HINTS
${_Vulkan_hint_executable_search_paths})
mark_as_advanced(Vulkan_dxc_EXECUTABLE)
endif()
if(Vulkan_GLSLC_EXECUTABLE)
set(Vulkan_glslc_FOUND TRUE)
else()
set(Vulkan_glslc_FOUND FALSE)
endif()
if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
set(Vulkan_glslangValidator_FOUND TRUE)
else()
set(Vulkan_glslangValidator_FOUND FALSE)
endif()
if (Vulkan_dxc_EXECUTABLE)
set(Vulkan_dxc_exe_FOUND TRUE)
else()
set(Vulkan_dxc_exe_FOUND FALSE)
endif()
function(_Vulkan_set_library_component_found component)
cmake_parse_arguments(PARSE_ARGV 1 _ARG
"NO_WARNING"
""
"DEPENDENT_COMPONENTS")
set(all_dependent_component_found TRUE)
foreach(dependent_component IN LISTS _ARG_DEPENDENT_COMPONENTS)
if(NOT Vulkan_${dependent_component}_FOUND)
set(all_dependent_component_found FALSE)
break()
endif()
endforeach()
if(all_dependent_component_found AND (Vulkan_${component}_LIBRARY OR Vulkan_${component}_DEBUG_LIBRARY))
set(Vulkan_${component}_FOUND TRUE PARENT_SCOPE)
# For Windows Vulkan SDK, third party tools binaries are provided with different MSVC ABI:
# - Release binaries uses a runtime library
# - Debug binaries uses a debug runtime library
# This lead to incompatibilities in linking for some configuration types due to CMake-default or project-configured selected MSVC ABI.
if(WIN32 AND NOT _ARG_NO_WARNING)
if(NOT Vulkan_${component}_LIBRARY)
message(WARNING
"Library ${component} for Release configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI.")
endif()
if(NOT Vulkan_${component}_DEBUG_LIBRARY)
message(WARNING
"Library ${component} for Debug configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI. Consider re-installing the Vulkan SDK and request debug libraries to fix this warning.")
endif()
endif()
else()
set(Vulkan_${component}_FOUND FALSE PARENT_SCOPE)
endif()
endfunction()
_Vulkan_set_library_component_found(glslang-spirv NO_WARNING)
_Vulkan_set_library_component_found(glslang-oglcompiler NO_WARNING)
_Vulkan_set_library_component_found(glslang-osdependent NO_WARNING)
_Vulkan_set_library_component_found(glslang-machineindependent NO_WARNING)
_Vulkan_set_library_component_found(glslang-genericcodegen NO_WARNING)
_Vulkan_set_library_component_found(glslang
DEPENDENT_COMPONENTS
glslang-spirv
glslang-oglcompiler
glslang-osdependent
glslang-machineindependent
glslang-genericcodegen)
_Vulkan_set_library_component_found(shaderc_combined)
_Vulkan_set_library_component_found(SPIRV-Tools)
_Vulkan_set_library_component_found(volk)
_Vulkan_set_library_component_found(dxc)
if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY)
set(Vulkan_MoltenVK_FOUND TRUE)
else()
set(Vulkan_MoltenVK_FOUND FALSE)
endif()
set(Vulkan_LIBRARIES ${Vulkan_LIBRARY})
set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR})
# detect version e.g 1.2.189
set(Vulkan_VERSION "")
if(Vulkan_INCLUDE_DIR)
set(VULKAN_CORE_H ${Vulkan_INCLUDE_DIR}/vulkan/vulkan_core.h)
if(EXISTS ${VULKAN_CORE_H})
file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine REGEX "^#define VK_HEADER_VERSION ")
string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion "${VulkanHeaderVersionLine}")
file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ")
string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion2 "${VulkanHeaderVersionLine2}")
list(LENGTH VulkanHeaderVersion2 _len)
# versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2'
if(_len EQUAL 3)
list(REMOVE_AT VulkanHeaderVersion2 0)
endif()
list(APPEND VulkanHeaderVersion2 ${VulkanHeaderVersion})
list(JOIN VulkanHeaderVersion2 "." Vulkan_VERSION)
endif()
endif()
if(Vulkan_MoltenVK_FOUND)
set(Vulkan_MoltenVK_VERSION "")
if(Vulkan_MoltenVK_INCLUDE_DIR)
set(VK_MVK_MOLTENVK_H ${Vulkan_MoltenVK_INCLUDE_DIR}/MoltenVK/vk_mvk_moltenvk.h)
if(EXISTS ${VK_MVK_MOLTENVK_H})
file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MAJOR REGEX "^#define MVK_VERSION_MAJOR ")
string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MAJOR "${_Vulkan_MoltenVK_VERSION_MAJOR}")
file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MINOR REGEX "^#define MVK_VERSION_MINOR ")
string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MINOR "${_Vulkan_MoltenVK_VERSION_MINOR}")
file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_PATCH REGEX "^#define MVK_VERSION_PATCH ")
string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_PATCH "${_Vulkan_MoltenVK_VERSION_PATCH}")
set(Vulkan_MoltenVK_VERSION "${_Vulkan_MoltenVK_VERSION_MAJOR}.${_Vulkan_MoltenVK_VERSION_MINOR}.${_Vulkan_MoltenVK_VERSION_PATCH}")
unset(_Vulkan_MoltenVK_VERSION_MAJOR)
unset(_Vulkan_MoltenVK_VERSION_MINOR)
unset(_Vulkan_MoltenVK_VERSION_PATCH)
endif()
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Vulkan
REQUIRED_VARS
Vulkan_LIBRARY
Vulkan_INCLUDE_DIR
VERSION_VAR
Vulkan_VERSION
HANDLE_COMPONENTS
)
if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan)
add_library(Vulkan::Vulkan UNKNOWN IMPORTED)
set_target_properties(Vulkan::Vulkan PROPERTIES
IMPORTED_LOCATION "${Vulkan_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
endif()
if(Vulkan_FOUND AND NOT TARGET Vulkan::Headers)
add_library(Vulkan::Headers INTERFACE IMPORTED)
set_target_properties(Vulkan::Headers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
endif()
if(Vulkan_FOUND AND Vulkan_GLSLC_EXECUTABLE AND NOT TARGET Vulkan::glslc)
add_executable(Vulkan::glslc IMPORTED)
set_property(TARGET Vulkan::glslc PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLC_EXECUTABLE}")
endif()
if(Vulkan_FOUND AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE AND NOT TARGET Vulkan::glslangValidator)
add_executable(Vulkan::glslangValidator IMPORTED)
set_property(TARGET Vulkan::glslangValidator PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}")
endif()
if(Vulkan_FOUND)
if((Vulkan_glslang-spirv_LIBRARY OR Vulkan_glslang-spirv_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-spirv)
add_library(Vulkan::glslang-spirv STATIC IMPORTED)
set_property(TARGET Vulkan::glslang-spirv
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
if(Vulkan_glslang-spirv_LIBRARY)
set_property(TARGET Vulkan::glslang-spirv APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::glslang-spirv
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-spirv_LIBRARY}")
endif()
if(Vulkan_glslang-spirv_DEBUG_LIBRARY)
set_property(TARGET Vulkan::glslang-spirv APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Debug)
set_property(TARGET Vulkan::glslang-spirv
PROPERTY
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-spirv_DEBUG_LIBRARY}")
endif()
endif()
if((Vulkan_glslang-oglcompiler_LIBRARY OR Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-oglcompiler)
add_library(Vulkan::glslang-oglcompiler STATIC IMPORTED)
set_property(TARGET Vulkan::glslang-oglcompiler
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
if(Vulkan_glslang-oglcompiler_LIBRARY)
set_property(TARGET Vulkan::glslang-oglcompiler APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::glslang-oglcompiler
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-oglcompiler_LIBRARY}")
endif()
if(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)
set_property(TARGET Vulkan::glslang-oglcompiler APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Debug)
set_property(TARGET Vulkan::glslang-oglcompiler
PROPERTY
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-oglcompiler_DEBUG_LIBRARY}")
endif()
endif()
if((Vulkan_glslang-osdependent_LIBRARY OR Vulkan_glslang-osdependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-osdependent)
add_library(Vulkan::glslang-osdependent STATIC IMPORTED)
set_property(TARGET Vulkan::glslang-osdependent
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
if(Vulkan_glslang-osdependent_LIBRARY)
set_property(TARGET Vulkan::glslang-osdependent APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::glslang-osdependent
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-osdependent_LIBRARY}")
endif()
if(Vulkan_glslang-osdependent_DEBUG_LIBRARY)
set_property(TARGET Vulkan::glslang-osdependent APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Debug)
set_property(TARGET Vulkan::glslang-osdependent
PROPERTY
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-osdependent_DEBUG_LIBRARY}")
endif()
endif()
if((Vulkan_glslang-machineindependent_LIBRARY OR Vulkan_glslang-machineindependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-machineindependent)
add_library(Vulkan::glslang-machineindependent STATIC IMPORTED)
set_property(TARGET Vulkan::glslang-machineindependent
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
if(Vulkan_glslang-machineindependent_LIBRARY)
set_property(TARGET Vulkan::glslang-machineindependent APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::glslang-machineindependent
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-machineindependent_LIBRARY}")
endif()
if(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)
set_property(TARGET Vulkan::glslang-machineindependent APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Debug)
set_property(TARGET Vulkan::glslang-machineindependent
PROPERTY
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-machineindependent_DEBUG_LIBRARY}")
endif()
endif()
if((Vulkan_glslang-genericcodegen_LIBRARY OR Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-genericcodegen)
add_library(Vulkan::glslang-genericcodegen STATIC IMPORTED)
set_property(TARGET Vulkan::glslang-genericcodegen
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
if(Vulkan_glslang-genericcodegen_LIBRARY)
set_property(TARGET Vulkan::glslang-genericcodegen APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::glslang-genericcodegen
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-genericcodegen_LIBRARY}")
endif()
if(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)
set_property(TARGET Vulkan::glslang-genericcodegen APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Debug)
set_property(TARGET Vulkan::glslang-genericcodegen
PROPERTY
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-genericcodegen_DEBUG_LIBRARY}")
endif()
endif()
if((Vulkan_glslang_LIBRARY OR Vulkan_glslang_DEBUG_LIBRARY)
AND TARGET Vulkan::glslang-spirv
AND TARGET Vulkan::glslang-oglcompiler
AND TARGET Vulkan::glslang-osdependent
AND TARGET Vulkan::glslang-machineindependent
AND TARGET Vulkan::glslang-genericcodegen
AND NOT TARGET Vulkan::glslang)
add_library(Vulkan::glslang STATIC IMPORTED)
set_property(TARGET Vulkan::glslang
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
if(Vulkan_glslang_LIBRARY)
set_property(TARGET Vulkan::glslang APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::glslang
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_glslang_LIBRARY}")
endif()
if(Vulkan_glslang_DEBUG_LIBRARY)
set_property(TARGET Vulkan::glslang APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Debug)
set_property(TARGET Vulkan::glslang
PROPERTY
IMPORTED_LOCATION_DEBUG "${Vulkan_glslang_DEBUG_LIBRARY}")
endif()
target_link_libraries(Vulkan::glslang
INTERFACE
Vulkan::glslang-spirv
Vulkan::glslang-oglcompiler
Vulkan::glslang-osdependent
Vulkan::glslang-machineindependent
Vulkan::glslang-genericcodegen
)
endif()
if((Vulkan_shaderc_combined_LIBRARY OR Vulkan_shaderc_combined_DEBUG_LIBRARY) AND NOT TARGET Vulkan::shaderc_combined)
add_library(Vulkan::shaderc_combined STATIC IMPORTED)
set_property(TARGET Vulkan::shaderc_combined
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
if(Vulkan_shaderc_combined_LIBRARY)
set_property(TARGET Vulkan::shaderc_combined APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::shaderc_combined
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_shaderc_combined_LIBRARY}")
endif()
if(Vulkan_shaderc_combined_DEBUG_LIBRARY)
set_property(TARGET Vulkan::shaderc_combined APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Debug)
set_property(TARGET Vulkan::shaderc_combined
PROPERTY
IMPORTED_LOCATION_DEBUG "${Vulkan_shaderc_combined_DEBUG_LIBRARY}")
endif()
if(UNIX)
find_package(Threads REQUIRED)
target_link_libraries(Vulkan::shaderc_combined
INTERFACE
Threads::Threads)
endif()
endif()
if((Vulkan_SPIRV-Tools_LIBRARY OR Vulkan_SPIRV-Tools_DEBUG_LIBRARY) AND NOT TARGET Vulkan::SPIRV-Tools)
add_library(Vulkan::SPIRV-Tools STATIC IMPORTED)
set_property(TARGET Vulkan::SPIRV-Tools
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
if(Vulkan_SPIRV-Tools_LIBRARY)
set_property(TARGET Vulkan::SPIRV-Tools APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::SPIRV-Tools
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_SPIRV-Tools_LIBRARY}")
endif()
if(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
set_property(TARGET Vulkan::SPIRV-Tools APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Debug)
set_property(TARGET Vulkan::SPIRV-Tools
PROPERTY
IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}")
endif()
endif()
if(Vulkan_volk_LIBRARY AND NOT TARGET Vulkan::volk)
add_library(Vulkan::volk STATIC IMPORTED)
set_property(TARGET Vulkan::volk
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
set_property(TARGET Vulkan::volk APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::volk APPEND
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_volk_LIBRARY}")
if (NOT WIN32)
set_property(TARGET Vulkan::volk APPEND
PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES dl)
endif()
endif()
if (Vulkan_dxc_LIBRARY AND NOT TARGET Vulkan::dxc_lib)
add_library(Vulkan::dxc_lib STATIC IMPORTED)
set_property(TARGET Vulkan::dxc_lib
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
set_property(TARGET Vulkan::dxc_lib APPEND
PROPERTY
IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Vulkan::dxc_lib APPEND
PROPERTY
IMPORTED_LOCATION_RELEASE "${Vulkan_dxc_LIBRARY}")
endif()
if(Vulkan_dxc_EXECUTABLE AND NOT TARGET Vulkan::dxc_exe)
add_executable(Vulkan::dxc_exe IMPORTED)
set_property(TARGET Vulkan::dxc_exe PROPERTY IMPORTED_LOCATION "${Vulkan_dxc_EXECUTABLE}")
endif()
endif()
if(Vulkan_MoltenVK_FOUND)
if(Vulkan_MoltenVK_LIBRARY AND NOT TARGET Vulkan::MoltenVK)
add_library(Vulkan::MoltenVK SHARED IMPORTED)
set_target_properties(Vulkan::MoltenVK
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_MoltenVK_INCLUDE_DIR}"
IMPORTED_LOCATION "${Vulkan_MoltenVK_LIBRARY}"
)
endif()
endif()
unset(_Vulkan_library_name)
unset(_Vulkan_hint_include_search_paths)
unset(_Vulkan_hint_executable_search_paths)
unset(_Vulkan_hint_library_search_paths)
cmake_policy(POP)

View File

@ -1,426 +0,0 @@
# FindVulkanHpp.cmake
#
# Finds or downloads the Vulkan-Hpp headers and Vulkan Profiles headers
#
# This will define the following variables
#
# VulkanHpp_FOUND
# VulkanHpp_INCLUDE_DIRS
#
# and the following imported targets
#
# VulkanHpp::VulkanHpp
#
# Try to find the package using standard find_path
find_path(VulkanHpp_INCLUDE_DIR
NAMES vulkan/vulkan.hpp
PATHS
${Vulkan_INCLUDE_DIR}
/usr/include
/usr/local/include
$ENV{VULKAN_SDK}/include
${ANDROID_NDK}/sources/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/include
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../include
)
# Also try to find vulkan.cppm
find_path(VulkanHpp_CPPM_DIR
NAMES vulkan/vulkan.cppm
PATHS
${Vulkan_INCLUDE_DIR}
/usr/include
/usr/local/include
$ENV{VULKAN_SDK}/include
${ANDROID_NDK}/sources/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/include
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../include
)
# Try to find vulkan_profiles.hpp
find_path(VulkanProfiles_INCLUDE_DIR
NAMES vulkan/vulkan_profiles.hpp
PATHS
${Vulkan_INCLUDE_DIR}
/usr/include
/usr/local/include
$ENV{VULKAN_SDK}/include
${ANDROID_NDK}/sources/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/include
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../include
)
# Function to extract Vulkan version from vulkan_core.h
function(extract_vulkan_version VULKAN_CORE_H_PATH OUTPUT_VERSION_TAG)
# Extract the version information from vulkan_core.h
file(STRINGS ${VULKAN_CORE_H_PATH} VULKAN_VERSION_MAJOR_LINE REGEX "^#define VK_VERSION_MAJOR")
file(STRINGS ${VULKAN_CORE_H_PATH} VULKAN_VERSION_MINOR_LINE REGEX "^#define VK_VERSION_MINOR")
file(STRINGS ${VULKAN_CORE_H_PATH} VULKAN_HEADER_VERSION_LINE REGEX "^#define VK_HEADER_VERSION")
set(VERSION_TAG "v1.3.275") # Default fallback
if(VULKAN_VERSION_MAJOR_LINE AND VULKAN_VERSION_MINOR_LINE AND VULKAN_HEADER_VERSION_LINE)
string(REGEX REPLACE "^#define VK_VERSION_MAJOR[ \t]+([0-9]+).*$" "\\1" VULKAN_VERSION_MAJOR "${VULKAN_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define VK_VERSION_MINOR[ \t]+([0-9]+).*$" "\\1" VULKAN_VERSION_MINOR "${VULKAN_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define VK_HEADER_VERSION[ \t]+([0-9]+).*$" "\\1" VULKAN_HEADER_VERSION "${VULKAN_HEADER_VERSION_LINE}")
# Construct the version tag
set(VERSION_TAG "v${VULKAN_VERSION_MAJOR}.${VULKAN_VERSION_MINOR}.${VULKAN_HEADER_VERSION}")
else()
# Alternative approach: look for VK_HEADER_VERSION_COMPLETE
file(STRINGS ${VULKAN_CORE_H_PATH} VULKAN_HEADER_VERSION_COMPLETE_LINE REGEX "^#define VK_HEADER_VERSION_COMPLETE")
file(STRINGS ${VULKAN_CORE_H_PATH} VULKAN_HEADER_VERSION_LINE REGEX "^#define VK_HEADER_VERSION")
if(VULKAN_HEADER_VERSION_COMPLETE_LINE AND VULKAN_HEADER_VERSION_LINE)
# Extract the header version
string(REGEX REPLACE "^#define VK_HEADER_VERSION[ \t]+([0-9]+).*$" "\\1" VULKAN_HEADER_VERSION "${VULKAN_HEADER_VERSION_LINE}")
# Check if the complete version line contains the major and minor versions
if(VULKAN_HEADER_VERSION_COMPLETE_LINE MATCHES "VK_MAKE_API_VERSION\\(.*,[ \t]*([0-9]+),[ \t]*([0-9]+),[ \t]*VK_HEADER_VERSION\\)")
set(VULKAN_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(VULKAN_VERSION_MINOR "${CMAKE_MATCH_2}")
set(VERSION_TAG "v${VULKAN_VERSION_MAJOR}.${VULKAN_VERSION_MINOR}.${VULKAN_HEADER_VERSION}")
endif()
endif()
endif()
# Return the version tag
set(${OUTPUT_VERSION_TAG} ${VERSION_TAG} PARENT_SCOPE)
endfunction()
# Determine the Vulkan version to use for Vulkan-Hpp and Vulkan-Profiles
set(VULKAN_VERSION_TAG "v1.3.275") # Default version
# Try to detect the Vulkan version
set(VULKAN_CORE_H "")
# If we're building for Android, try to detect the NDK's Vulkan version
if(DEFINED ANDROID_NDK)
# Find the vulkan_core.h file in the NDK
find_file(VULKAN_CORE_H vulkan_core.h
PATHS
${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/vulkan
${ANDROID_NDK}/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/vulkan
${ANDROID_NDK}/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/vulkan
${ANDROID_NDK}/toolchains/llvm/prebuilt/windows/sysroot/usr/include/vulkan
NO_DEFAULT_PATH
)
if(VULKAN_CORE_H)
extract_vulkan_version(${VULKAN_CORE_H} VULKAN_VERSION_TAG)
message(STATUS "Detected NDK Vulkan version: ${VULKAN_VERSION_TAG}")
else()
message(STATUS "Could not find vulkan_core.h in NDK, using default version: ${VULKAN_VERSION_TAG}")
endif()
# For desktop builds, try to detect the Vulkan SDK version
elseif(DEFINED ENV{VULKAN_SDK})
# Find the vulkan_core.h file in the Vulkan SDK
find_file(VULKAN_CORE_H vulkan_core.h
PATHS
$ENV{VULKAN_SDK}/include/vulkan
NO_DEFAULT_PATH
)
if(VULKAN_CORE_H)
extract_vulkan_version(${VULKAN_CORE_H} VULKAN_VERSION_TAG)
message(STATUS "Detected Vulkan SDK version: ${VULKAN_VERSION_TAG}")
else()
message(STATUS "Could not find vulkan_core.h in Vulkan SDK, using default version: ${VULKAN_VERSION_TAG}")
endif()
# If Vulkan package was already found, try to use its include directory
elseif(DEFINED Vulkan_INCLUDE_DIR)
# Find the vulkan_core.h file in the Vulkan include directory
find_file(VULKAN_CORE_H vulkan_core.h
PATHS
${Vulkan_INCLUDE_DIR}/vulkan
NO_DEFAULT_PATH
)
if(VULKAN_CORE_H)
extract_vulkan_version(${VULKAN_CORE_H} VULKAN_VERSION_TAG)
message(STATUS "Detected Vulkan version from include directory: ${VULKAN_VERSION_TAG}")
else()
message(STATUS "Could not find vulkan_core.h in Vulkan include directory, using default version: ${VULKAN_VERSION_TAG}")
endif()
else()
# Try to find vulkan_core.h in system paths
find_file(VULKAN_CORE_H vulkan_core.h
PATHS
/usr/include/vulkan
/usr/local/include/vulkan
)
if(VULKAN_CORE_H)
extract_vulkan_version(${VULKAN_CORE_H} VULKAN_VERSION_TAG)
message(STATUS "Detected system Vulkan version: ${VULKAN_VERSION_TAG}")
else()
message(STATUS "Could not find vulkan_core.h in system paths, using default version: ${VULKAN_VERSION_TAG}")
endif()
endif()
# If the include directory wasn't found, use FetchContent to download and build
if(NOT VulkanHpp_INCLUDE_DIR OR NOT VulkanHpp_CPPM_DIR)
# If not found, use FetchContent to download
include(FetchContent)
message(STATUS "Vulkan-Hpp not found, fetching from GitHub with version ${VULKAN_VERSION_TAG}...")
FetchContent_Declare(
VulkanHpp
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Hpp.git
GIT_TAG ${VULKAN_VERSION_TAG} # Use the detected or default version
)
# Set policy to suppress the deprecation warning
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
# Make sure FetchContent is available
include(FetchContent)
# Populate the content
FetchContent_GetProperties(VulkanHpp SOURCE_DIR VulkanHpp_SOURCE_DIR)
if(NOT VulkanHpp_POPULATED)
FetchContent_Populate(VulkanHpp)
# Get the source directory after populating
FetchContent_GetProperties(VulkanHpp SOURCE_DIR VulkanHpp_SOURCE_DIR)
endif()
# Set the include directory to the source directory
set(VulkanHpp_INCLUDE_DIR ${VulkanHpp_SOURCE_DIR})
message(STATUS "VulkanHpp_SOURCE_DIR: ${VulkanHpp_SOURCE_DIR}")
message(STATUS "VulkanHpp_INCLUDE_DIR: ${VulkanHpp_INCLUDE_DIR}")
# Check if vulkan.cppm exists in the downloaded repository
if(EXISTS "${VulkanHpp_SOURCE_DIR}/vulkan/vulkan.cppm")
set(VulkanHpp_CPPM_DIR ${VulkanHpp_SOURCE_DIR})
else()
# If vulkan.cppm doesn't exist, we need to create it
set(VulkanHpp_CPPM_DIR ${CMAKE_CURRENT_BINARY_DIR}/VulkanHpp)
file(MAKE_DIRECTORY ${VulkanHpp_CPPM_DIR}/vulkan)
# Create vulkan.cppm file
file(WRITE "${VulkanHpp_CPPM_DIR}/vulkan/vulkan.cppm"
"// Auto-generated vulkan.cppm file
module;
#include <vulkan/vulkan.hpp>
export module vulkan;
export namespace vk {
using namespace VULKAN_HPP_NAMESPACE;
}
")
endif()
endif()
# If the Vulkan Profiles include directory wasn't found, use FetchContent to download
if(NOT VulkanProfiles_INCLUDE_DIR)
# If not found, use FetchContent to download
include(FetchContent)
message(STATUS "Vulkan-Profiles not found, fetching from GitHub main branch...")
FetchContent_Declare(
VulkanProfiles
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Profiles.git
GIT_TAG main # Use main branch instead of a specific tag
)
# Set policy to suppress the deprecation warning
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
# Populate the content
FetchContent_GetProperties(VulkanProfiles SOURCE_DIR VulkanProfiles_SOURCE_DIR)
if(NOT VulkanProfiles_POPULATED)
FetchContent_Populate(VulkanProfiles)
# Get the source directory after populating
FetchContent_GetProperties(VulkanProfiles SOURCE_DIR VulkanProfiles_SOURCE_DIR)
endif()
# Create the include directory structure if it doesn't exist
set(VulkanProfiles_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/VulkanProfiles/include)
file(MAKE_DIRECTORY ${VulkanProfiles_INCLUDE_DIR}/vulkan)
# Create a stub vulkan_profiles.hpp file if it doesn't exist
if(NOT EXISTS "${VulkanProfiles_INCLUDE_DIR}/vulkan/vulkan_profiles.hpp")
file(WRITE "${VulkanProfiles_INCLUDE_DIR}/vulkan/vulkan_profiles.hpp"
"// Auto-generated vulkan_profiles.hpp stub file
#pragma once
#include <vulkan/vulkan.hpp>
namespace vp {
// Stub implementation for Vulkan Profiles
struct ProfileDesc {
const char* name;
uint32_t specVersion;
};
inline bool GetProfileSupport(VkPhysicalDevice physicalDevice, const ProfileDesc* pProfile, VkBool32* pSupported) {
*pSupported = VK_TRUE;
return true;
}
}
")
endif()
message(STATUS "VulkanProfiles_SOURCE_DIR: ${VulkanProfiles_SOURCE_DIR}")
message(STATUS "VulkanProfiles_INCLUDE_DIR: ${VulkanProfiles_INCLUDE_DIR}")
endif()
# Set the variables
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VulkanHpp
REQUIRED_VARS VulkanHpp_INCLUDE_DIR
FAIL_MESSAGE "Could NOT find VulkanHpp. Install it or set VulkanHpp_INCLUDE_DIR to the directory containing vulkan/vulkan.hpp"
)
# Debug output
message(STATUS "VulkanHpp_FOUND: ${VulkanHpp_FOUND}")
message(STATUS "VULKANHPP_FOUND: ${VULKANHPP_FOUND}")
if(VulkanHpp_FOUND)
set(VulkanHpp_INCLUDE_DIRS ${VulkanHpp_INCLUDE_DIR})
# Make sure VulkanHpp_CPPM_DIR is set
if(NOT DEFINED VulkanHpp_CPPM_DIR)
# Check if vulkan.cppm exists in the include directory
if(EXISTS "${VulkanHpp_INCLUDE_DIR}/vulkan/vulkan.cppm")
set(VulkanHpp_CPPM_DIR ${VulkanHpp_INCLUDE_DIR})
message(STATUS "Found vulkan.cppm in VulkanHpp_INCLUDE_DIR: ${VulkanHpp_CPPM_DIR}")
elseif(DEFINED VulkanHpp_SOURCE_DIR AND EXISTS "${VulkanHpp_SOURCE_DIR}/vulkan/vulkan.cppm")
set(VulkanHpp_CPPM_DIR ${VulkanHpp_SOURCE_DIR})
message(STATUS "Found vulkan.cppm in VulkanHpp_SOURCE_DIR: ${VulkanHpp_CPPM_DIR}")
elseif(DEFINED vulkanhpp_SOURCE_DIR AND EXISTS "${vulkanhpp_SOURCE_DIR}/vulkan/vulkan.cppm")
set(VulkanHpp_CPPM_DIR ${vulkanhpp_SOURCE_DIR})
message(STATUS "Found vulkan.cppm in vulkanhpp_SOURCE_DIR: ${VulkanHpp_CPPM_DIR}")
else()
# If vulkan.cppm doesn't exist, we need to create it
set(VulkanHpp_CPPM_DIR ${CMAKE_CURRENT_BINARY_DIR}/VulkanHpp)
file(MAKE_DIRECTORY ${VulkanHpp_CPPM_DIR}/vulkan)
message(STATUS "Creating vulkan.cppm in ${VulkanHpp_CPPM_DIR}")
# Create vulkan.cppm file
file(WRITE "${VulkanHpp_CPPM_DIR}/vulkan/vulkan.cppm"
"// Auto-generated vulkan.cppm file
module;
#include <vulkan/vulkan.hpp>
export module vulkan;
export namespace vk {
using namespace VULKAN_HPP_NAMESPACE;
}
")
endif()
endif()
message(STATUS "Final VulkanHpp_CPPM_DIR: ${VulkanHpp_CPPM_DIR}")
# Add Vulkan Profiles include directory if found
if(VulkanProfiles_INCLUDE_DIR AND EXISTS "${VulkanProfiles_INCLUDE_DIR}/vulkan/vulkan_profiles.hpp")
list(APPEND VulkanHpp_INCLUDE_DIRS ${VulkanProfiles_INCLUDE_DIR})
message(STATUS "Added Vulkan Profiles include directory: ${VulkanProfiles_INCLUDE_DIR}")
endif()
# Create an imported target
if(NOT TARGET VulkanHpp::VulkanHpp)
add_library(VulkanHpp::VulkanHpp INTERFACE IMPORTED)
set_target_properties(VulkanHpp::VulkanHpp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${VulkanHpp_INCLUDE_DIRS}"
)
endif()
elseif(DEFINED VulkanHpp_SOURCE_DIR OR DEFINED vulkanhpp_SOURCE_DIR)
# If find_package_handle_standard_args failed but we have a VulkanHpp source directory from FetchContent
# Create an imported target
if(NOT TARGET VulkanHpp::VulkanHpp)
add_library(VulkanHpp::VulkanHpp INTERFACE IMPORTED)
# Determine the source directory
if(DEFINED VulkanHpp_SOURCE_DIR)
set(_vulkanhpp_source_dir ${VulkanHpp_SOURCE_DIR})
elseif(DEFINED vulkanhpp_SOURCE_DIR)
set(_vulkanhpp_source_dir ${vulkanhpp_SOURCE_DIR})
endif()
message(STATUS "Using fallback VulkanHpp source directory: ${_vulkanhpp_source_dir}")
set_target_properties(VulkanHpp::VulkanHpp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_vulkanhpp_source_dir}"
)
endif()
# Set variables to indicate that VulkanHpp was found
set(VulkanHpp_FOUND TRUE)
set(VULKANHPP_FOUND TRUE)
# Set include directories
if(DEFINED _vulkanhpp_source_dir)
set(VulkanHpp_INCLUDE_DIR ${_vulkanhpp_source_dir})
elseif(DEFINED VulkanHpp_SOURCE_DIR)
set(VulkanHpp_INCLUDE_DIR ${VulkanHpp_SOURCE_DIR})
elseif(DEFINED vulkanhpp_SOURCE_DIR)
set(VulkanHpp_INCLUDE_DIR ${vulkanhpp_SOURCE_DIR})
endif()
set(VulkanHpp_INCLUDE_DIRS ${VulkanHpp_INCLUDE_DIR})
# Add Vulkan Profiles include directory if found
if(VulkanProfiles_INCLUDE_DIR AND EXISTS "${VulkanProfiles_INCLUDE_DIR}/vulkan/vulkan_profiles.hpp")
list(APPEND VulkanHpp_INCLUDE_DIRS ${VulkanProfiles_INCLUDE_DIR})
message(STATUS "Added Vulkan Profiles include directory to fallback: ${VulkanProfiles_INCLUDE_DIR}")
endif()
# Make sure VulkanHpp_CPPM_DIR is set
if(NOT DEFINED VulkanHpp_CPPM_DIR)
# Check if vulkan.cppm exists in the downloaded repository
if(DEFINED VulkanHpp_INCLUDE_DIR AND EXISTS "${VulkanHpp_INCLUDE_DIR}/vulkan/vulkan.cppm")
set(VulkanHpp_CPPM_DIR ${VulkanHpp_INCLUDE_DIR})
message(STATUS "Found vulkan.cppm in VulkanHpp_INCLUDE_DIR: ${VulkanHpp_CPPM_DIR}")
elseif(DEFINED _vulkanhpp_source_dir AND EXISTS "${_vulkanhpp_source_dir}/vulkan/vulkan.cppm")
set(VulkanHpp_CPPM_DIR ${_vulkanhpp_source_dir})
message(STATUS "Found vulkan.cppm in _vulkanhpp_source_dir: ${VulkanHpp_CPPM_DIR}")
elseif(DEFINED VulkanHpp_SOURCE_DIR AND EXISTS "${VulkanHpp_SOURCE_DIR}/vulkan/vulkan.cppm")
set(VulkanHpp_CPPM_DIR ${VulkanHpp_SOURCE_DIR})
message(STATUS "Found vulkan.cppm in VulkanHpp_SOURCE_DIR: ${VulkanHpp_CPPM_DIR}")
elseif(DEFINED vulkanhpp_SOURCE_DIR AND EXISTS "${vulkanhpp_SOURCE_DIR}/vulkan/vulkan.cppm")
set(VulkanHpp_CPPM_DIR ${vulkanhpp_SOURCE_DIR})
message(STATUS "Found vulkan.cppm in vulkanhpp_SOURCE_DIR: ${VulkanHpp_CPPM_DIR}")
else()
# If vulkan.cppm doesn't exist, we need to create it
set(VulkanHpp_CPPM_DIR ${CMAKE_CURRENT_BINARY_DIR}/VulkanHpp)
file(MAKE_DIRECTORY ${VulkanHpp_CPPM_DIR}/vulkan)
message(STATUS "Creating vulkan.cppm in ${VulkanHpp_CPPM_DIR}")
# Create vulkan.cppm file
file(WRITE "${VulkanHpp_CPPM_DIR}/vulkan/vulkan.cppm"
"// Auto-generated vulkan.cppm file
module;
#include <vulkan/vulkan.hpp>
export module vulkan;
export namespace vk {
using namespace VULKAN_HPP_NAMESPACE;
}
")
endif()
endif()
message(STATUS "Final VulkanHpp_CPPM_DIR: ${VulkanHpp_CPPM_DIR}")
endif()
mark_as_advanced(VulkanHpp_INCLUDE_DIR VulkanHpp_CPPM_DIR)

View File

@ -1,133 +0,0 @@
# Findglm.cmake
#
# Finds the GLM library
#
# This will define the following variables
#
# glm_FOUND
# glm_INCLUDE_DIRS
#
# and the following imported targets
#
# glm::glm
#
# Try to find the package using pkg-config first
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_glm QUIET glm)
endif()
# Find the include directory
find_path(glm_INCLUDE_DIR
NAMES glm/glm.hpp
PATHS
${PC_glm_INCLUDE_DIRS}
/usr/include
/usr/local/include
$ENV{VULKAN_SDK}/include
${ANDROID_NDK}/sources/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/include
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../include
PATH_SUFFIXES glm
)
# If the include directory wasn't found, use FetchContent to download and build
if(NOT glm_INCLUDE_DIR)
# If not found, use FetchContent to download and build
include(FetchContent)
message(STATUS "GLM not found, fetching from GitHub...")
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 0.9.9.8 # Use a specific tag for stability
)
# Define a function to update the CMake minimum required version
function(update_glm_cmake_version)
# Get the source directory
FetchContent_GetProperties(glm SOURCE_DIR glm_SOURCE_DIR)
# Update the minimum required CMake version
file(READ "${glm_SOURCE_DIR}/CMakeLists.txt" GLM_CMAKE_CONTENT)
string(REPLACE "cmake_minimum_required(VERSION 3.2"
"cmake_minimum_required(VERSION 3.5"
GLM_CMAKE_CONTENT "${GLM_CMAKE_CONTENT}")
file(WRITE "${glm_SOURCE_DIR}/CMakeLists.txt" "${GLM_CMAKE_CONTENT}")
endfunction()
# Set policy to suppress the deprecation warning
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
# First, declare and populate the content
FetchContent_GetProperties(glm)
if(NOT glm_POPULATED)
FetchContent_Populate(glm)
# Update the CMake version before making it available
update_glm_cmake_version()
endif()
# Now make it available (this will process the CMakeLists.txt)
FetchContent_MakeAvailable(glm)
# Get the include directory from the target
if(TARGET glm)
get_target_property(glm_INCLUDE_DIR glm INTERFACE_INCLUDE_DIRECTORIES)
if(NOT glm_INCLUDE_DIR)
# If we can't get the include directory from the target, use the source directory
set(glm_INCLUDE_DIR ${glm_SOURCE_DIR})
endif()
else()
# GLM might not create a target, so use the source directory
set(glm_INCLUDE_DIR ${glm_SOURCE_DIR})
endif()
endif()
# Set the variables
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(glm
REQUIRED_VARS glm_INCLUDE_DIR
)
if(glm_FOUND)
set(glm_INCLUDE_DIRS ${glm_INCLUDE_DIR})
# Create an imported target
if(NOT TARGET glm::glm)
add_library(glm::glm INTERFACE IMPORTED)
set_target_properties(glm::glm PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${glm_INCLUDE_DIRS}"
)
endif()
elseif(TARGET glm)
# If find_package_handle_standard_args failed but we have a glm target from FetchContent
# Create an alias for the glm target
if(NOT TARGET glm::glm)
add_library(glm::glm ALIAS glm)
endif()
# Set variables to indicate that glm was found
set(glm_FOUND TRUE)
set(GLM_FOUND TRUE)
# Set include directories
get_target_property(glm_INCLUDE_DIR glm INTERFACE_INCLUDE_DIRECTORIES)
if(glm_INCLUDE_DIR)
set(glm_INCLUDE_DIRS ${glm_INCLUDE_DIR})
else()
# If we can't get the include directory from the target, use the source directory
set(glm_INCLUDE_DIR ${glm_SOURCE_DIR})
set(glm_INCLUDE_DIRS ${glm_INCLUDE_DIR})
endif()
endif()
mark_as_advanced(glm_INCLUDE_DIR)

View File

@ -1,154 +0,0 @@
# Findnlohmann_json.cmake
#
# Finds the nlohmann_json library
#
# This will define the following variables
#
# nlohmann_json_FOUND
# nlohmann_json_INCLUDE_DIRS
#
# and the following imported targets
#
# nlohmann_json::nlohmann_json
#
# Try to find the package using pkg-config first
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_nlohmann_json QUIET nlohmann_json)
endif()
# Find the include directory
find_path(nlohmann_json_INCLUDE_DIR
NAMES nlohmann/json.hpp json.hpp
PATHS
${PC_nlohmann_json_INCLUDE_DIRS}
/usr/include
/usr/local/include
$ENV{VULKAN_SDK}/include
${ANDROID_NDK}/sources/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/include
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../include
PATH_SUFFIXES nlohmann json
)
# If the include directory wasn't found, use FetchContent to download and build
if(NOT nlohmann_json_INCLUDE_DIR)
# If not found, use FetchContent to download and build
include(FetchContent)
message(STATUS "nlohmann_json not found, fetching from GitHub...")
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.12.0 # Use a specific tag for stability
)
# Set policy to suppress the deprecation warning
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
# Populate the content but don't configure it yet
FetchContent_GetProperties(nlohmann_json)
if(NOT nlohmann_json_POPULATED)
FetchContent_Populate(nlohmann_json)
if(ANDROID)
# Update the minimum required CMake version before including the CMakeLists.txt
file(READ "${nlohmann_json_SOURCE_DIR}/CMakeLists.txt" NLOHMANN_JSON_CMAKE_CONTENT)
string(REPLACE "cmake_minimum_required(VERSION 3.1"
"cmake_minimum_required(VERSION 3.10"
NLOHMANN_JSON_CMAKE_CONTENT "${NLOHMANN_JSON_CMAKE_CONTENT}")
string(REPLACE "cmake_minimum_required(VERSION 3.2"
"cmake_minimum_required(VERSION 3.10"
NLOHMANN_JSON_CMAKE_CONTENT "${NLOHMANN_JSON_CMAKE_CONTENT}")
string(REPLACE "cmake_minimum_required(VERSION 3.3"
"cmake_minimum_required(VERSION 3.10"
NLOHMANN_JSON_CMAKE_CONTENT "${NLOHMANN_JSON_CMAKE_CONTENT}")
string(REPLACE "cmake_minimum_required(VERSION 3.4"
"cmake_minimum_required(VERSION 3.10"
NLOHMANN_JSON_CMAKE_CONTENT "${NLOHMANN_JSON_CMAKE_CONTENT}")
string(REPLACE "cmake_minimum_required(VERSION 3.5"
"cmake_minimum_required(VERSION 3.10"
NLOHMANN_JSON_CMAKE_CONTENT "${NLOHMANN_JSON_CMAKE_CONTENT}")
string(REPLACE "cmake_minimum_required(VERSION 3.6"
"cmake_minimum_required(VERSION 3.10"
NLOHMANN_JSON_CMAKE_CONTENT "${NLOHMANN_JSON_CMAKE_CONTENT}")
string(REPLACE "cmake_minimum_required(VERSION 3.7"
"cmake_minimum_required(VERSION 3.10"
NLOHMANN_JSON_CMAKE_CONTENT "${NLOHMANN_JSON_CMAKE_CONTENT}")
string(REPLACE "cmake_minimum_required(VERSION 3.8"
"cmake_minimum_required(VERSION 3.10"
NLOHMANN_JSON_CMAKE_CONTENT "${NLOHMANN_JSON_CMAKE_CONTENT}")
string(REPLACE "cmake_minimum_required(VERSION 3.9"
"cmake_minimum_required(VERSION 3.10"
NLOHMANN_JSON_CMAKE_CONTENT "${NLOHMANN_JSON_CMAKE_CONTENT}")
file(WRITE "${nlohmann_json_SOURCE_DIR}/CMakeLists.txt" "${NLOHMANN_JSON_CMAKE_CONTENT}")
endif()
# Now add the subdirectory manually
add_subdirectory(${nlohmann_json_SOURCE_DIR} ${nlohmann_json_BINARY_DIR})
else()
# If already populated, just make it available
FetchContent_MakeAvailable(nlohmann_json)
endif()
# Get the include directory from the target
if(TARGET nlohmann_json)
get_target_property(nlohmann_json_INCLUDE_DIR nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
if(NOT nlohmann_json_INCLUDE_DIR)
# If we can't get the include directory from the target, use the source directory
set(nlohmann_json_INCLUDE_DIR ${nlohmann_json_SOURCE_DIR}/include)
endif()
else()
# nlohmann_json might not create a target, so use the source directory
set(nlohmann_json_INCLUDE_DIR ${nlohmann_json_SOURCE_DIR}/include)
endif()
endif()
# Set the variables
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(nlohmann_json
REQUIRED_VARS nlohmann_json_INCLUDE_DIR
)
if(nlohmann_json_FOUND)
set(nlohmann_json_INCLUDE_DIRS ${nlohmann_json_INCLUDE_DIR})
# Create an imported target
if(NOT TARGET nlohmann_json::nlohmann_json)
add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)
set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${nlohmann_json_INCLUDE_DIRS}"
)
endif()
elseif(TARGET nlohmann_json)
# If find_package_handle_standard_args failed but we have a nlohmann_json target from FetchContent
# Create an alias for the nlohmann_json target
if(NOT TARGET nlohmann_json::nlohmann_json)
add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json)
endif()
# Set variables to indicate that nlohmann_json was found
set(nlohmann_json_FOUND TRUE)
set(NLOHMANN_JSON_FOUND TRUE)
# Set include directories
get_target_property(nlohmann_json_INCLUDE_DIR nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
if(nlohmann_json_INCLUDE_DIR)
set(nlohmann_json_INCLUDE_DIRS ${nlohmann_json_INCLUDE_DIR})
else()
# If we can't get the include directory from the target, use the source directory
set(nlohmann_json_INCLUDE_DIR ${nlohmann_json_SOURCE_DIR}/include)
set(nlohmann_json_INCLUDE_DIRS ${nlohmann_json_INCLUDE_DIR})
endif()
endif()
mark_as_advanced(nlohmann_json_INCLUDE_DIR)

View File

@ -1,86 +0,0 @@
# Findstb.cmake
#
# Finds the stb library (specifically stb_image.h)
#
# This will define the following variables
#
# stb_FOUND
# stb_INCLUDE_DIRS
#
# and the following imported targets
#
# stb::stb
#
# Try to find the package using pkg-config first
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_stb QUIET stb)
endif()
# Find the include directory
find_path(stb_INCLUDE_DIR
NAMES stb_image.h
PATHS
${PC_stb_INCLUDE_DIRS}
/usr/include
/usr/local/include
$ENV{VULKAN_SDK}/include
${ANDROID_NDK}/sources/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/include
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../include
PATH_SUFFIXES stb
)
# If the include directory wasn't found, use FetchContent to download and build
if(NOT stb_INCLUDE_DIR)
# If not found, use FetchContent to download and build
include(FetchContent)
message(STATUS "stb_image.h not found, fetching from GitHub...")
FetchContent_Declare(
stb
GIT_REPOSITORY https://github.com/nothings/stb.git
GIT_TAG master # stb doesn't use version tags, so we use master
)
# Set policy to suppress the deprecation warning
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
# Populate the content
FetchContent_GetProperties(stb)
if(NOT stb_POPULATED)
FetchContent_Populate(stb)
endif()
# stb is a header-only library with no CMakeLists.txt, so we just need to set the include directory
set(stb_INCLUDE_DIR ${stb_SOURCE_DIR})
endif()
# Set the variables
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(stb
REQUIRED_VARS stb_INCLUDE_DIR
)
if(stb_FOUND)
set(stb_INCLUDE_DIRS ${stb_INCLUDE_DIR})
# Create an imported target
if(NOT TARGET stb::stb)
add_library(stb::stb INTERFACE IMPORTED)
set_target_properties(stb::stb PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${stb_INCLUDE_DIRS}"
)
endif()
endif()
mark_as_advanced(stb_INCLUDE_DIR)

View File

@ -1,162 +0,0 @@
# Findtinygltf.cmake
#
# Finds the tinygltf library
#
# This will define the following variables
#
# tinygltf_FOUND
# tinygltf_INCLUDE_DIRS
#
# and the following imported targets
#
# tinygltf::tinygltf
#
# First, try to find nlohmann_json
find_package(nlohmann_json QUIET)
if(NOT nlohmann_json_FOUND)
include(FetchContent)
message(STATUS "nlohmann_json not found, fetching v3.12.0 from GitHub...")
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.12.0 # Use a specific tag for stability
)
FetchContent_MakeAvailable(nlohmann_json)
endif()
# Try to find tinygltf using standard find_package
find_path(tinygltf_INCLUDE_DIR
NAMES tiny_gltf.h
PATHS
${PC_tinygltf_INCLUDE_DIRS}
/usr/include
/usr/local/include
$ENV{VULKAN_SDK}/include
${ANDROID_NDK}/sources/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/include
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../include
PATH_SUFFIXES tinygltf include
)
# If not found, use FetchContent to download and build
if(NOT tinygltf_INCLUDE_DIR)
# If not found, use FetchContent to download and build
include(FetchContent)
message(STATUS "tinygltf not found, fetching from GitHub...")
FetchContent_Declare(
tinygltf
GIT_REPOSITORY https://github.com/syoyo/tinygltf.git
GIT_TAG v2.8.18 # Use a specific tag for stability
)
# Set policy to suppress the deprecation warning
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
# Populate the content but don't configure it yet
FetchContent_GetProperties(tinygltf)
if(NOT tinygltf_POPULATED)
FetchContent_Populate(tinygltf)
# Update the minimum required CMake version to avoid deprecation warning
file(READ "${tinygltf_SOURCE_DIR}/CMakeLists.txt" TINYGLTF_CMAKE_CONTENT)
string(REPLACE "cmake_minimum_required(VERSION 3.6)"
"cmake_minimum_required(VERSION 3.10)"
TINYGLTF_CMAKE_CONTENT "${TINYGLTF_CMAKE_CONTENT}")
file(WRITE "${tinygltf_SOURCE_DIR}/CMakeLists.txt" "${TINYGLTF_CMAKE_CONTENT}")
# Create a symbolic link to make nlohmann/json.hpp available
if(EXISTS "${tinygltf_SOURCE_DIR}/json.hpp")
file(MAKE_DIRECTORY "${tinygltf_SOURCE_DIR}/nlohmann")
file(CREATE_LINK "${tinygltf_SOURCE_DIR}/json.hpp" "${tinygltf_SOURCE_DIR}/nlohmann/json.hpp" SYMBOLIC)
endif()
# Set tinygltf to header-only mode
set(TINYGLTF_HEADER_ONLY ON CACHE BOOL "Use header only version" FORCE)
set(TINYGLTF_INSTALL OFF CACHE BOOL "Do not install tinygltf" FORCE)
# Add the subdirectory after modifying the CMakeLists.txt
add_subdirectory(${tinygltf_SOURCE_DIR} ${tinygltf_BINARY_DIR})
else()
# If already populated, just make it available
FetchContent_MakeAvailable(tinygltf)
endif()
# Get the include directory from the target
get_target_property(tinygltf_INCLUDE_DIR tinygltf INTERFACE_INCLUDE_DIRECTORIES)
if(NOT tinygltf_INCLUDE_DIR)
# If we can't get the include directory from the target, use the source directory
FetchContent_GetProperties(tinygltf SOURCE_DIR tinygltf_SOURCE_DIR)
set(tinygltf_INCLUDE_DIR ${tinygltf_SOURCE_DIR})
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(tinygltf
REQUIRED_VARS tinygltf_INCLUDE_DIR
)
if(tinygltf_FOUND)
set(tinygltf_INCLUDE_DIRS ${tinygltf_INCLUDE_DIR})
if(NOT TARGET tinygltf::tinygltf)
add_library(tinygltf::tinygltf INTERFACE IMPORTED)
set_target_properties(tinygltf::tinygltf PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${tinygltf_INCLUDE_DIRS}"
INTERFACE_COMPILE_DEFINITIONS "TINYGLTF_IMPLEMENTATION;TINYGLTF_NO_EXTERNAL_IMAGE;TINYGLTF_NO_STB_IMAGE;TINYGLTF_NO_STB_IMAGE_WRITE"
)
if(TARGET nlohmann_json::nlohmann_json)
target_link_libraries(tinygltf::tinygltf INTERFACE nlohmann_json::nlohmann_json)
endif()
endif()
elseif(TARGET tinygltf)
# If find_package_handle_standard_args failed but we have a tinygltf target from FetchContent
# Create an alias for the tinygltf target
if(NOT TARGET tinygltf::tinygltf)
add_library(tinygltf_wrapper INTERFACE)
target_link_libraries(tinygltf_wrapper INTERFACE tinygltf)
target_compile_definitions(tinygltf_wrapper INTERFACE
TINYGLTF_IMPLEMENTATION
TINYGLTF_NO_EXTERNAL_IMAGE
TINYGLTF_NO_STB_IMAGE
TINYGLTF_NO_STB_IMAGE_WRITE
)
if(TARGET nlohmann_json::nlohmann_json)
target_link_libraries(tinygltf_wrapper INTERFACE nlohmann_json::nlohmann_json)
endif()
add_library(tinygltf::tinygltf ALIAS tinygltf_wrapper)
endif()
# Set variables to indicate that tinygltf was found
set(tinygltf_FOUND TRUE)
set(TINYGLTF_FOUND TRUE)
# Set include directories
get_target_property(tinygltf_INCLUDE_DIR tinygltf INTERFACE_INCLUDE_DIRECTORIES)
if(tinygltf_INCLUDE_DIR)
set(tinygltf_INCLUDE_DIRS ${tinygltf_INCLUDE_DIR})
else()
# If we can't get the include directory from the target, use the source directory
FetchContent_GetProperties(tinygltf SOURCE_DIR tinygltf_SOURCE_DIR)
set(tinygltf_INCLUDE_DIR ${tinygltf_SOURCE_DIR})
set(tinygltf_INCLUDE_DIRS ${tinygltf_INCLUDE_DIR})
# Explicitly set the include directory on the target
if(TARGET tinygltf)
set_target_properties(tinygltf PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${tinygltf_INCLUDE_DIR}"
)
endif()
endif()
endif()
mark_as_advanced(tinygltf_INCLUDE_DIR)

View File

@ -1,160 +0,0 @@
# Findtinyobjloader.cmake
# Find the tinyobjloader library
#
# This module defines the following variables:
# tinyobjloader_FOUND - True if tinyobjloader was found
# tinyobjloader_INCLUDE_DIRS - Include directories for tinyobjloader
# tinyobjloader_LIBRARIES - Libraries to link against tinyobjloader
#
# It also defines the following targets:
# tinyobjloader::tinyobjloader
# Try to find the package using pkg-config first
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_tinyobjloader QUIET tinyobjloader)
endif()
# Find the include directory
find_path(tinyobjloader_INCLUDE_DIR
NAMES tiny_obj_loader.h
PATHS
${PC_tinyobjloader_INCLUDE_DIRS}
/usr/include
/usr/local/include
$ENV{VULKAN_SDK}/include
${ANDROID_NDK}/sources/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/include
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../include
PATH_SUFFIXES tinyobjloader tiny_obj_loader
)
# Find the library
find_library(tinyobjloader_LIBRARY
NAMES tinyobjloader
PATHS
${PC_tinyobjloader_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
$ENV{VULKAN_SDK}/lib
${ANDROID_NDK}/sources/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../attachments/lib
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../external
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../lib
PATH_SUFFIXES lib
)
# If the include directory wasn't found, use FetchContent to download and build
if(NOT tinyobjloader_INCLUDE_DIR)
# If not found, use FetchContent to download and build
include(FetchContent)
message(STATUS "tinyobjloader not found, fetching from GitHub...")
FetchContent_Declare(
tinyobjloader
GIT_REPOSITORY https://github.com/tinyobjloader/tinyobjloader.git
GIT_TAG v2.0.0rc10 # Use a specific tag for stability
)
# Set options before making tinyobjloader available
set(TINYOBJLOADER_BUILD_TEST_LOADER OFF CACHE BOOL "Do not build test loader" FORCE)
set(TINYOBJLOADER_BUILD_OBJ_STICHER OFF CACHE BOOL "Do not build obj sticher" FORCE)
set(TINYOBJLOADER_INSTALL OFF CACHE BOOL "Do not install tinyobjloader" FORCE)
# Update CMake policy to suppress the deprecation warning
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
# Populate the content but don't configure it yet
FetchContent_GetProperties(tinyobjloader)
if(NOT tinyobjloader_POPULATED)
FetchContent_Populate(tinyobjloader)
# Update the minimum required CMake version before including the CMakeLists.txt
file(READ "${tinyobjloader_SOURCE_DIR}/CMakeLists.txt" TINYOBJLOADER_CMAKE_CONTENT)
string(REPLACE "cmake_minimum_required(VERSION 3.2)"
"cmake_minimum_required(VERSION 3.10)"
TINYOBJLOADER_CMAKE_CONTENT "${TINYOBJLOADER_CMAKE_CONTENT}")
string(REPLACE "cmake_minimum_required(VERSION 3.5)"
"cmake_minimum_required(VERSION 3.10)"
TINYOBJLOADER_CMAKE_CONTENT "${TINYOBJLOADER_CMAKE_CONTENT}")
file(WRITE "${tinyobjloader_SOURCE_DIR}/CMakeLists.txt" "${TINYOBJLOADER_CMAKE_CONTENT}")
# Now add the subdirectory manually
add_subdirectory(${tinyobjloader_SOURCE_DIR} ${tinyobjloader_BINARY_DIR})
else()
# If already populated, just make it available
FetchContent_MakeAvailable(tinyobjloader)
endif()
# Get the include directory from the target
get_target_property(tinyobjloader_INCLUDE_DIR tinyobjloader INTERFACE_INCLUDE_DIRECTORIES)
if(NOT tinyobjloader_INCLUDE_DIR)
# If we can't get the include directory from the target, use the source directory
set(tinyobjloader_INCLUDE_DIR ${tinyobjloader_SOURCE_DIR})
endif()
endif()
# Set the variables
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(tinyobjloader
REQUIRED_VARS tinyobjloader_INCLUDE_DIR
)
if(tinyobjloader_FOUND)
set(tinyobjloader_INCLUDE_DIRS ${tinyobjloader_INCLUDE_DIR})
if(tinyobjloader_LIBRARY)
set(tinyobjloader_LIBRARIES ${tinyobjloader_LIBRARY})
else()
# tinyobjloader is a header-only library, so no library is needed
set(tinyobjloader_LIBRARIES "")
endif()
# Create an imported target
if(NOT TARGET tinyobjloader::tinyobjloader)
add_library(tinyobjloader::tinyobjloader INTERFACE IMPORTED)
set_target_properties(tinyobjloader::tinyobjloader PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${tinyobjloader_INCLUDE_DIRS}"
)
if(tinyobjloader_LIBRARIES)
set_target_properties(tinyobjloader::tinyobjloader PROPERTIES
INTERFACE_LINK_LIBRARIES "${tinyobjloader_LIBRARIES}"
)
endif()
endif()
elseif(TARGET tinyobjloader)
# If find_package_handle_standard_args failed but we have a tinyobjloader target from FetchContent
# Create an alias for the tinyobjloader target
if(NOT TARGET tinyobjloader::tinyobjloader)
add_library(tinyobjloader::tinyobjloader ALIAS tinyobjloader)
endif()
# Set variables to indicate that tinyobjloader was found
set(tinyobjloader_FOUND TRUE)
set(TINYOBJLOADER_FOUND TRUE)
# Set include directories
get_target_property(tinyobjloader_INCLUDE_DIR tinyobjloader INTERFACE_INCLUDE_DIRECTORIES)
if(tinyobjloader_INCLUDE_DIR)
set(tinyobjloader_INCLUDE_DIRS ${tinyobjloader_INCLUDE_DIR})
else()
# If we can't get the include directory from the target, use the source directory
set(tinyobjloader_INCLUDE_DIR ${tinyobjloader_SOURCE_DIR})
set(tinyobjloader_INCLUDE_DIRS ${tinyobjloader_INCLUDE_DIR})
endif()
endif()
mark_as_advanced(tinyobjloader_INCLUDE_DIR tinyobjloader_LIBRARY)

View File

@ -1,233 +1,252 @@
cmake_minimum_required (VERSION 3.29)
project (VulkanTutorial)
project(VulkanEngine)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
# Add option to enable/disable C++ 20 module
option(ENABLE_CPP20_MODULE "Enable C++ 20 module support for Vulkan" OFF)
# Enable C++ module dependency scanning only if C++ 20 module is enabled
if(ENABLE_CPP20_MODULE)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
endif()
find_package (glfw3 REQUIRED)
find_package (glm REQUIRED)
find_package (Vulkan 1.4.335 REQUIRED) # Require Vulkan SDK version 1.4.335 or higher
find_package (tinyobjloader REQUIRED)
find_package (tinygltf REQUIRED)
find_package (nlohmann_json REQUIRED)
find_library(KTX_LIBRARY NAMES ktx REQUIRED)
find_path(KTX_INCLUDE_DIR NAMES ktx.h REQUIRED)
message(STATUS "KTX library found at: ${KTX_LIBRARY}")
message(STATUS "KTX include dir: ${KTX_INCLUDE_DIR}")
add_library(KTX::ktx SHARED IMPORTED GLOBAL)
set_target_properties(KTX::ktx PROPERTIES
IMPORTED_LOCATION "${KTX_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${KTX_INCLUDE_DIR}"
)
# set up Vulkan C++ module only if enabled
if(ENABLE_CPP20_MODULE)
add_library(VulkanCppModule)
add_library(Vulkan::cppm ALIAS VulkanCppModule)
target_compile_definitions(VulkanCppModule
PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VULKAN_HPP_NO_STRUCT_CONSTRUCTORS=1
)
target_include_directories(VulkanCppModule
PUBLIC
"${Vulkan_INCLUDE_DIR}"
)
target_link_libraries(VulkanCppModule
PUBLIC
Vulkan::Vulkan
)
set_target_properties(VulkanCppModule PROPERTIES CXX_STANDARD 20)
# Add MSVC-specific compiler options for proper C++ module support
if(MSVC)
target_compile_options(VulkanCppModule PRIVATE
/std:c++latest # Use latest C++ standard for better module support
/permissive- # Standards conformance mode
/Zc:__cplusplus # Enable correct __cplusplus macro
/EHsc # Enable C++ exception handling
/Zc:preprocessor # Use conforming preprocessor
/translateInclude # Automatically translate #include to import for standard library
)
endif()
target_sources(VulkanCppModule
PUBLIC
FILE_SET cxx_modules TYPE CXX_MODULES
BASE_DIRS
"${Vulkan_INCLUDE_DIR}"
FILES
"${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm"
)
# Add the vulkan.cppm file directly as a source file
target_sources(VulkanCppModule
PRIVATE
"${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm"
)
else()
# Create a dummy interface library when C++ 20 module is disabled
add_library(VulkanCppModule INTERFACE)
add_library(Vulkan::cppm ALIAS VulkanCppModule)
target_link_libraries(VulkanCppModule INTERFACE Vulkan::Vulkan)
target_compile_definitions(VulkanCppModule
INTERFACE VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VULKAN_HPP_NO_STRUCT_CONSTRUCTORS=1
)
endif()
find_package(stb REQUIRED)
set(STB_INCLUDEDIR ${stb_INCLUDE_DIRS})
add_executable (glslang::validator IMPORTED)
find_program (GLSLANG_VALIDATOR "glslangValidator" HINTS $ENV{VULKAN_SDK}/bin REQUIRED)
set_property (TARGET glslang::validator PROPERTY IMPORTED_LOCATION "${GLSLANG_VALIDATOR}")
find_program(SLANGC_EXECUTABLE slangc HINTS $ENV{VULKAN_SDK}/bin REQUIRED)
include(BuildInfo)
include(FetchContent)
#LTO
include(CheckIPOSupported)
check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT LTO_ERROR)
if(LTO_SUPPORTED AND CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "LTO activated")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "LTO not supported : ${LTO_ERROR}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
find_program(GCC_AR NAMES gcc-ar REQUIRED)
find_program(GCC_RANLIB NAMES gcc-ranlib REQUIRED)
set(CMAKE_AR "${GCC_AR}")
set(CMAKE_RANLIB "${GCC_RANLIB}")
endif()
function (add_shaders_target TARGET)
cmake_parse_arguments ("SHADER" "" "CHAPTER_NAME" "SOURCES" ${ARGN})
set (SHADERS_DIR ${SHADER_CHAPTER_NAME}/shaders)
add_custom_command (
OUTPUT ${SHADERS_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${SHADERS_DIR}
)
add_custom_command (
OUTPUT ${SHADERS_DIR}/frag.spv ${SHADERS_DIR}/vert.spv
COMMAND glslang::validator
ARGS --target-env vulkan1.0 ${SHADER_SOURCES} --quiet
WORKING_DIRECTORY ${SHADERS_DIR}
DEPENDS ${SHADERS_DIR} ${SHADER_SOURCES}
COMMENT "Compiling Shaders"
VERBATIM
)
add_custom_target (${TARGET} DEPENDS ${SHADERS_DIR}/frag.spv ${SHADERS_DIR}/vert.spv)
endfunction ()
# Find all package dependencies
find_package( glfw3 REQUIRED )
find_package( glm REQUIRED )
find_package( VulkanMemoryAllocator CONFIG REQUIRED )
find_package( fmt REQUIRED )
# Shader compilers
add_executable (glslang::validator IMPORTED)
find_program (
GLSLANG_VALIDATOR
"glslangValidator"
HINTS $ENV{VULKAN_SDK}/bin
REQUIRED
)
function (add_slang_shader_target TARGET)
cmake_parse_arguments ("SHADER" "" "CHAPTER_NAME" "SOURCES" ${ARGN})
set (SHADERS_DIR ${SHADER_CHAPTER_NAME}/shaders)
#file(GLOB HAS_COMPUTE ${CHAPTER_SHADER}.comp)
set (ENTRY_POINTS -entry vertMain -entry fragMain)
if(HAS_COMPUTE)
list(APPEND ENTRY_POINTS -entry compMain)
endif()
add_custom_command (
OUTPUT ${SHADERS_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${SHADERS_DIR}
)
add_custom_command (
OUTPUT ${SHADERS_DIR}/slang.spv
COMMAND ${SLANGC_EXECUTABLE} ${SHADER_SOURCES} -target spirv -profile spirv_1_4+spvRayQueryKHR -emit-spirv-directly -fvk-use-entrypoint-name ${ENTRY_POINTS} -o slang.spv
WORKING_DIRECTORY ${SHADERS_DIR}
DEPENDS ${SHADERS_DIR} ${SHADER_SOURCES}
COMMENT "Compiling Slang Shaders"
set_property (
TARGET glslang::validator
PROPERTY IMPORTED_LOCATION "${GLSLANG_VALIDATOR}"
)
find_program(SLANGC_EXECUTABLE slangc HINTS $ENV{VULKAN_SDK}/bin REQUIRED)
# CL11
add_subdirectory(include/CLI11)
# fastgltf because it's not in nixpkgs
FetchContent_Declare(
fastgltf
GIT_REPOSITORY https://github.com/spnda/fastgltf.git
GIT_TAG v0.8.0
)
FetchContent_MakeAvailable(fastgltf)
# vk-bootstrap because CMAKE can't find it on NixOS
FetchContent_Declare(
vk-bootstrap
GIT_REPOSITORY https://github.com/charles-lunarg/vk-bootstrap.git
GIT_TAG v1.3.295
)
FetchContent_MakeAvailable(vk-bootstrap)
# Helper functions to build shaders
function(addGlslShader SOURCE OUTPUT_DIR)
get_filename_component(SHADER_NAME ${SOURCE} NAME_WE)
set(SPV_FILE "${OUTPUT_DIR}/${SHADER_NAME}.spv")
add_custom_command(
OUTPUT ${SPV_FILE}
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT_DIR}
COMMAND glslang::validator
-V
--target-env vulkan1.4 # Change if needed
-o ${SPV_FILE}
${SOURCE}
DEPENDS ${SOURCE}
COMMENT "Compiling GLSL shader: ${SOURCE} -> ${SPV_FILE}"
VERBATIM
)
add_custom_target (${TARGET} DEPENDS ${SHADERS_DIR}/slang.spv)
set(SPV_FILE ${SPV_FILE} PARENT_SCOPE)
endfunction()
function (add_chapter CHAPTER_NAME)
cmake_parse_arguments (CHAPTER "" "SHADER" "LIBS;TEXTURES;MODELS" ${ARGN})
add_executable (${CHAPTER_NAME} src/${CHAPTER_NAME}.cpp)
set_target_properties (${CHAPTER_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CHAPTER_NAME})
set_target_properties (${CHAPTER_NAME} PROPERTIES CXX_STANDARD 20)
target_link_libraries (${CHAPTER_NAME} Vulkan::cppm glfw)
target_include_directories (${CHAPTER_NAME} PRIVATE ${STB_INCLUDEDIR})
# Add compile definition if C++ 20 module is enabled
if(ENABLE_CPP20_MODULE)
target_compile_definitions(${CHAPTER_NAME} PRIVATE USE_CPP20_MODULES=1)
function(addSlangShader SOURCES ENTRY_POINTS OUTPUT_DIR)
set(SPV_FILE "${OUTPUT_DIR}/slang.spv")
add_custom_command(
OUTPUT ${SPV_FILE}
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT_DIR}
COMMAND ${SLANGC_EXECUTABLE}
${SOURCES}
-target spirv
-profile spirv_1_6+spvRayQueryKHR # Change if needed
-emit-spirv-directly
-fvk-use-entrypoint-name
${ENTRY_POINTS}
-o ${SPV_FILE}
DEPENDS ${SOURCES}
COMMENT "Compiling Slang shaders -> ${SPV_FILE}"
VERBATIM
)
set(SPV_FILE ${SPV_FILE} PARENT_SCOPE)
endfunction()
# A function to automate executables aditions
function ( addBinary BINARY_NAME )
cmake_parse_arguments ( BINARY "IMGUI;LICENSE" "SOURCE" "SHADERS;SLANG_SHADERS;LIBS;TEXTURES;MODELS" ${ARGN} )
if (DEFINED BINARY_SOURCE)
add_executable ( ${BINARY_NAME} src/${BINARY_SOURCE}.cpp )
endif()
target_include_directories( ${BINARY_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src )
# Sets the output dir to have clear separation between binaries
set_target_properties ( ${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BINARY_NAME} )
set_target_properties ( ${BINARY_NAME} PROPERTIES CXX_STANDARD 20 ) # Uses C++20
# Sets per binary LTO
if(LTO_SUPPORTED AND CMAKE_BUILD_TYPE STREQUAL "Release")
set_target_properties(${BINARY_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
message("Enabled LTO")
endif()
set_target_properties(${BINARY_NAME} PROPERTIES CXX_SCAN_FOR_MODULES OFF)
# Define VULKAN_HPP_HANDLE_ERROR_OUT_OF_DATE_AS_SUCCESS to treat VK_ERROR_OUT_OF_DATE_KHR as a success code
target_compile_definitions(${CHAPTER_NAME} PRIVATE "VULKAN_HPP_HANDLE_ERROR_OUT_OF_DATE_AS_SUCCESS" )
target_compile_definitions (
${BINARY_NAME}
PRIVATE
"VULKAN_HPP_HANDLE_ERROR_OUT_OF_DATE_AS_SUCCESS"
$<$<CONFIG:Debug>:DEBUG> # So CMAKE expose a #define DEBUG for debug builds
# Exposes versions
BUILD_ID="${ENGINE_VERSION}"
)
if(BINARY_IMGUI)
target_include_directories(${BINARY_NAME} PRIVATE
${CMAKE_SOURCE_DIR}/include/imgui
${CMAKE_SOURCE_DIR}/include/imgui/backends
)
if(WIN32)
if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
set_target_properties(${CHAPTER_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${CHAPTER_NAME}")
endif()
target_sources(${BINARY_NAME} PRIVATE
${CMAKE_SOURCE_DIR}/include/imgui/imgui.cpp
${CMAKE_SOURCE_DIR}/include/imgui/imgui_draw.cpp
${CMAKE_SOURCE_DIR}/include/imgui/imgui_tables.cpp
${CMAKE_SOURCE_DIR}/include/imgui/imgui_widgets.cpp
${CMAKE_SOURCE_DIR}/include/imgui/imgui_demo.cpp
#${CMAKE_SOURCE_DIR}/include/imgui/imgui_memory_editor.h
${CMAKE_SOURCE_DIR}/include/imgui/backends/imgui_impl_glfw.cpp
${CMAKE_SOURCE_DIR}/include/imgui/backends/imgui_impl_vulkan.cpp
)
endif()
if (DEFINED CHAPTER_SHADER)
set (CHAPTER_SHADER_TARGET ${CHAPTER_NAME}_shader)
file (GLOB SHADER_SOURCES ${CHAPTER_SHADER}.frag ${CHAPTER_SHADER}.vert ${CHAPTER_SHADER}.comp)
if (SHADER_SOURCES)
add_shaders_target (${CHAPTER_SHADER_TARGET} CHAPTER_NAME ${CHAPTER_NAME} SOURCES ${SHADER_SOURCES})
add_dependencies (${CHAPTER_NAME} ${CHAPTER_SHADER_TARGET})
if(BINARY_LICENSE)
file(COPY ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_BINARY_DIR}/${BINARY_NAME})
endif()
set (CHAPTER_SHADER_SLANG_TARGET ${CHAPTER_NAME}_slang_shader)
file (GLOB SHADER_SLANG_SOURCES ${CHAPTER_SHADER}.slang)
if(SHADER_SLANG_SOURCES)
add_slang_shader_target( ${CHAPTER_SHADER_SLANG_TARGET} CHAPTER_NAME ${CHAPTER_NAME} SOURCES ${SHADER_SLANG_SOURCES})
add_dependencies(${CHAPTER_NAME} ${CHAPTER_SHADER_SLANG_TARGET})
if(DEFINED BINARY_SHADERS)
set(SHADER_OUTPUT_DIR ${CMAKE_BINARY_DIR}/${BINARY_NAME}/shaders)
set(ALL_SPV_FILES "")
set(EXPANDED_SHADERS "")
foreach(SHADER_PATTERN ${BINARY_SHADERS})
if(SHADER_PATTERN MATCHES "[*?]")
file(GLOB SHADER_FILES CONFIGURE_DEPENDS ${SHADER_PATTERN})
list(APPEND EXPANDED_SHADERS ${SHADER_FILES})
else()
list(APPEND EXPANDED_SHADERS ${SHADER_PATTERN})
endif()
endif ()
if (DEFINED CHAPTER_LIBS)
target_link_libraries (${CHAPTER_NAME} ${CHAPTER_LIBS})
endif ()
if (DEFINED CHAPTER_MODELS)
endforeach()
foreach(SHADER_SRC ${EXPANDED_SHADERS})
if(NOT IS_ABSOLUTE ${SHADER_SRC})
set(SHADER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_SRC})
endif()
get_filename_component(EXT ${SHADER_SRC} EXT)
if(EXT STREQUAL ".slang")
addSlangShader(${SHADER_SRC} "${BINARY_SLANG_ENTRIES}" ${SHADER_OUTPUT_DIR})
list(APPEND ALL_SPV_FILES ${SPV_FILE})
else()
addGlslShader(${SHADER_SRC} ${SHADER_OUTPUT_DIR})
list(APPEND ALL_SPV_FILES ${SPV_FILE})
endif()
endforeach()
add_custom_target(shaders_${BINARY_NAME} DEPENDS ${ALL_SPV_FILES})
add_dependencies(${BINARY_NAME} shaders_${BINARY_NAME})
endif()
if (DEFINED BINARY_LIBS)
target_link_libraries ( ${BINARY_NAME} ${BINARY_LIBS} )
endif()
if (DEFINED BINARY_MODELS) # Adds the 3D models in the binary folder
set(RESOLVED_MODELS "")
foreach(MODEL_PATTERN ${CHAPTER_MODELS})
foreach(MODEL_PATTERN ${BINARY_MODELS})
file(GLOB MATCHED_MODELS CONFIGURE_DEPENDS
"${CMAKE_SOURCE_DIR}/models/${MODEL_PATTERN}"
"${CMAKE_SOURCE_DIR}/assets/models/${MODEL_PATTERN}"
)
list(APPEND RESOLVED_MODELS ${MATCHED_MODELS})
endforeach()
if (RESOLVED_MODELS)
file(COPY ${RESOLVED_MODELS} DESTINATION ${CMAKE_BINARY_DIR}/${CHAPTER_NAME}/models)
file(COPY ${RESOLVED_MODELS} DESTINATION ${CMAKE_BINARY_DIR}/${BINARY_NAME}/models)
endif()
endif ()
if (DEFINED CHAPTER_TEXTURES)
endif()
if (DEFINED BINARY_TEXTURES) # Adds the textures in the binary folder
set(RESOLVED_TEXTURES "")
foreach(TEX_PATTERN ${CHAPTER_TEXTURES})
foreach(TEX_PATTERN ${BINARY_TEXTURES})
file(GLOB MATCHED_TEXTURES CONFIGURE_DEPENDS
"${CMAKE_SOURCE_DIR}/textures/${TEX_PATTERN}"
"${CMAKE_SOURCE_DIR}/assets/textures/${TEX_PATTERN}"
)
list(APPEND RESOLVED_TEXTURES ${MATCHED_TEXTURES})
endforeach()
if (RESOLVED_TEXTURES)
file(COPY ${RESOLVED_TEXTURES} DESTINATION ${CMAKE_BINARY_DIR}/${CHAPTER_NAME}/textures)
file(COPY ${RESOLVED_TEXTURES} DESTINATION ${CMAKE_BINARY_DIR}/${BINARY_NAME}/textures)
endif()
endif ()
endfunction ()
endfunction()
add_chapter (main
SHADER shaders/main
TEXTURES *
# Adds the main binary
list(
APPEND
lib_list
# Libs used
glfw
fmt
vk-bootstrap
vulkan
CLI11::CLI11
fastgltf
)
addBinary (
engine
SOURCE Engine/main
# Flags
IMGUI
LICENSE
SHADERS shaders/*
MODELS *
LIBS nlohmann_json::nlohmann_json KTX::ktx
LIBS ${lib_list}
)
#add_chapter (38_ray_tracing
# SHADER 38_ray_tracing
# MODELS plant_on_table.obj
# MODELS plant_on_table.mtl
# TEXTURES plant_on_table_textures/nettle_plant_diff_4k.png
# TEXTURES plant_on_table_textures/potted_plant_02_pot_diff_1k.png
# TEXTURES plant_on_table_textures/wooden_picnic_table_bottom_diff_1k.png
# TEXTURES plant_on_table_textures/wooden_picnic_table_top_diff_1k.png
# LIBS glm::glm tinyobjloader::tinyobjloader)
addBinary (
server
SOURCE Server/main
)

65
CMakePresets.json Normal file
View File

@ -0,0 +1,65 @@
{
"version": 6,
"cmakeMinimumRequired": { "major": 3 },
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/bin/${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "debug",
"displayName": "Debug",
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS_DEBUG": "-g"
}
},
{
"name": "debug-san",
"displayName": "Debug + Sanitizers",
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS_DEBUG": "-g -fsanitize=address,undefined"
}
},
{
"name": "release",
"displayName": "Release",
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_CXX_FLAGS_RELEASE": "-O3 -march=native -flto"
}
},
{
"name": "release-fast",
"displayName": "Release (Ofast, non-conformant)",
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_CXX_FLAGS_RELEASE": "-Ofast -march=native -flto"
}
}
],
"buildPresets": [
{
"name": "debug",
"displayName": "Build Debug",
"configurePreset": "debug"
},
{
"name": "release",
"displayName": "Build Release",
"configurePreset": "release"
}
]
}

View File

@ -2,3 +2,6 @@
A simple Vulkan tutorial.
Might expending it later into a game or engine.
Based from [vkguide](https://vkguide.dev/)
This has a very different philosophy than the main [Khronos Vulkan Tutorial](https://docs.vulkan.org/tutorial/latest/00_Introduction.html)

11
ROADMAP.md Normal file
View File

@ -0,0 +1,11 @@
# Roadmap
Finish vkguide.dev
Rewrite some part, for structure purposes
Configure offscreen rendering for imgui (docked viewport)
Separate tooling and core, for shipping
- #ifdef DEBUG for tools
- #ifdef NDEBUG for release

BIN
assets/models/basicmesh.glb Normal file

Binary file not shown.

View File

@ -1 +0,0 @@
slangc shaders/main.slang -target spirv -profile spirv_1_4 -emit-spirv-directly -fvk-use-entrypoint-name -entry vertMain -entry fragMain -o shaders/slang.spv

82
flake.nix Normal file
View File

@ -0,0 +1,82 @@
{
description = "General Vulkan dev environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in {
devShells.default = pkgs.mkShell {
name = "vulkan";
hardeningDisable = [ "fortify" ];
packages = with pkgs; [
# Shader compile
shader-slang
glslang
# Vulkan
vulkan-headers
vulkan-loader
vulkan-validation-layers
vulkan-tools
vulkan-utility-libraries
vk-bootstrap
vulkan-memory-allocator
vulkan-volk
# Wayland
wayland
wayland-protocols
wayland-scanner
libxkbcommon
# Miniaudio
libpulseaudio
libpulseaudio.dev
# Other libraries
glfw3
SDL2
sdl3
fmt
imgui
tinyobjloader
nlohmann_json
tinygltf
# fastgltf
stb
ktx-tools
glm
cmake
ninja
pkg-config
# Debug
gdb
renderdoc
# git
];
# Environment Variables
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.vulkan-loader
pkgs.shaderc.lib
pkgs.SDL2
pkgs.vk-bootstrap
#pkgs.sdl3
];
VK_LAYER_PATH = "${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d";
VULKAN_SDK = "${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d";
GIT="${pkgs.git}";
shellHook = ''
echo "Vulkan loaded"
unset SOURCE_DATE_EPOCH
echo $LD_LIBRARY_PATH
'';
};
});
}

1
include/CLI11 Submodule

@ -0,0 +1 @@
Subproject commit c1cfe00d2f3d862aecfe6e69ec810414d5f4c906

1
include/imgui Submodule

@ -0,0 +1 @@
Subproject commit c94bb90ff5c4bab7c1632996589b675ed5e81005

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
#version 450
//shader input
layout(location = 0) in vec3 inColor;
//output write
layout(location = 0) out vec4 outFragColor;
void main()
{
//return red
outFragColor = vec4(inColor, 1.0f);
}

View File

@ -0,0 +1,36 @@
#version 450
#extension GL_EXT_buffer_reference : require
layout(location = 0) out vec3 outColor;
layout(location = 1) out vec2 outUV;
struct Vertex {
vec3 position;
float uv_x;
vec3 normal;
float uv_y;
vec4 color;
};
layout(buffer_reference, std430) readonly buffer VertexBuffer {
Vertex vertices[];
};
//push constants block
layout(push_constant) uniform constants
{
mat4 render_matrix;
VertexBuffer vertexBuffer;
} PushConstants;
void main()
{
//load vertex data from device adress
Vertex v = PushConstants.vertexBuffer.vertices[gl_VertexIndex];
//output data
gl_Position = PushConstants.render_matrix * vec4(v.position, 1.0f);
outColor = v.color.xyz;
outUV.x = v.uv_x;
outUV.y = v.uv_y;
}

View File

@ -0,0 +1,24 @@
#version 450
layout (location = 0) out vec3 outColor;
void main()
{
//const array of positions for the triangle
const vec3 positions[3] = vec3[3](
vec3(1.f,1.f, 0.0f),
vec3(-1.f,1.f, 0.0f),
vec3(0.f,-1.f, 0.0f)
);
//const array of colors for the triangle
const vec3 colors[3] = vec3[3](
vec3(1.0f, 0.0f, 0.0f), //red
vec3(0.0f, 1.0f, 0.0f), //green
vec3(00.f, 0.0f, 1.0f) //blue
);
//output the position of each vertex
gl_Position = vec4(positions[gl_VertexIndex], 1.0f);
outColor = colors[gl_VertexIndex];
}

22
shaders/gradient.comp Normal file
View File

@ -0,0 +1,22 @@
// GLSL version
#version 460
layout ( local_size_x = 16, local_size_y = 16 ) in;
layout ( rgba16f, set = 0, binding = 0 ) uniform image2D image;
void main() {
ivec2 texelCoord = ivec2( gl_GlobalInvocationID.xy );
ivec2 size = imageSize( image );
if ( texelCoord.x < size.x && texelCoord.y < size.y ) {
vec4 color = vec4( 0.0, 0.0, 0.0, 1.0 );
if ( gl_LocalInvocationID.x != 0 && gl_LocalInvocationID.y != 0 ) {
color.x = float(texelCoord.x)/(size.x);
color.y = float(texelCoord.y)/(size.y);
}
imageStore(image, texelCoord, color);
}
}

View File

@ -0,0 +1,29 @@
#version 460
layout (local_size_x = 16, local_size_y = 16) in;
layout(rgba16f,set = 0, binding = 0) uniform image2D image;
//push constants block
layout( push_constant ) uniform constants
{
vec4 data1;
vec4 data2;
vec4 data3;
vec4 data4;
} PushConstants;
void main() {
ivec2 texelCoord = ivec2(gl_GlobalInvocationID.xy);
ivec2 size = imageSize(image);
vec4 topColor = PushConstants.data1;
vec4 bottomColor = PushConstants.data2;
if(texelCoord.x < size.x && texelCoord.y < size.y) {
float blend = float(texelCoord.y)/(size.y);
imageStore(image, texelCoord, mix(topColor,bottomColor, blend));
}
}

View File

@ -1,34 +0,0 @@
struct VSInput {
float3 inPosition;
float3 inColor;
float2 inTexCoord;
};
struct UniformBuffer {
float4x4 model;
float4x4 view;
float4x4 proj;
};
ConstantBuffer<UniformBuffer> ubo;
struct VSOutput {
float4 pos : SV_Position;
float3 fragColor;
float2 fragTexCoord;
};
[shader("vertex")]
VSOutput vertMain(VSInput input) {
VSOutput output;
output.pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(input.inPosition, 1.0))));
output.fragColor = input.inColor;
output.fragTexCoord = input.inTexCoord;
return output;
}
Sampler2D texture;
[shader("fragment")]
float4 fragMain(VSOutput vertIn) : SV_Target {
return texture.Sample(vertIn.fragTexCoord);
}

View File

@ -1,30 +0,0 @@
static float2 positions[3] = float2[](
float2(0.0, -0.5),
float2(0.5, 0.5),
float2(-0.5, 0.5)
);
static float3 colors[3] = float3[] (
float3(1.0, 0.0, 0.0),
float3(0.0, 1.0, 0.0),
float3(0.0, 0.0, 1.0)
);
struct VertexOutput {
float3 color;
float4 sv_position : SV_Position;
};
[shader("vertex")]
VertexOutput vertMain(uint vid : SV_VertexID) {
VertexOutput output;
output.sv_position = float4(positions[vid], 0.0, 1.0);
output.color = colors[vid];
return output;
}
[shader("fragment")]
float4 fragMain(VertexOutput inVert) : SV_Target {
float3 color = inVert.color;
return float4(color, 1.0);
}

91
shaders/sky.comp Normal file
View File

@ -0,0 +1,91 @@
#version 450
layout (local_size_x = 16, local_size_y = 16) in;
layout(rgba16f,set = 0, binding = 0) uniform image2D image;
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
//push constants block
layout( push_constant ) uniform constants
{
vec4 data1;
vec4 data2;
vec4 data3;
vec4 data4;
} PushConstants;
// Return random noise in the range [0.0, 1.0], as a function of x.
float Noise2d( in vec2 x )
{
float xhash = cos( x.x * 37.0 );
float yhash = cos( x.y * 57.0 );
return fract( 415.92653 * ( xhash + yhash ) );
}
// Convert Noise2d() into a "star field" by stomping everthing below fThreshhold to zero.
float NoisyStarField( in vec2 vSamplePos, float fThreshhold )
{
float StarVal = Noise2d( vSamplePos );
if ( StarVal >= fThreshhold )
StarVal = pow( (StarVal - fThreshhold)/(1.0 - fThreshhold), 6.0 );
else
StarVal = 0.0;
return StarVal;
}
// Stabilize NoisyStarField() by only sampling at integer values.
float StableStarField( in vec2 vSamplePos, float fThreshhold )
{
// Linear interpolation between four samples.
// Note: This approach has some visual artifacts.
// There must be a better way to "anti alias" the star field.
float fractX = fract( vSamplePos.x );
float fractY = fract( vSamplePos.y );
vec2 floorSample = floor( vSamplePos );
float v1 = NoisyStarField( floorSample, fThreshhold );
float v2 = NoisyStarField( floorSample + vec2( 0.0, 1.0 ), fThreshhold );
float v3 = NoisyStarField( floorSample + vec2( 1.0, 0.0 ), fThreshhold );
float v4 = NoisyStarField( floorSample + vec2( 1.0, 1.0 ), fThreshhold );
float StarVal = v1 * ( 1.0 - fractX ) * ( 1.0 - fractY )
+ v2 * ( 1.0 - fractX ) * fractY
+ v3 * fractX * ( 1.0 - fractY )
+ v4 * fractX * fractY;
return StarVal;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 iResolution = imageSize(image);
// Sky Background Color
//vec3 vColor = vec3( 0.1, 0.2, 0.4 ) * fragCoord.y / iResolution.y;
vec3 vColor = PushConstants.data1.xyz * fragCoord.y / iResolution.y;
// Note: Choose fThreshhold in the range [0.99, 0.9999].
// Higher values (i.e., closer to one) yield a sparser starfield.
float StarFieldThreshhold = PushConstants.data1.w;//0.97;
// Stars with a slow crawl.
float xRate = 0.2;
float yRate = -0.06;
vec2 vSamplePos = fragCoord.xy + vec2( xRate * float( 1 ), yRate * float( 1 ) );
float StarVal = StableStarField( vSamplePos, StarFieldThreshhold );
vColor += vec3( StarVal );
fragColor = vec4(vColor, 1.0);
}
void main()
{
vec4 value = vec4(0.0, 0.0, 0.0, 1.0);
ivec2 texelCoord = ivec2(gl_GlobalInvocationID.xy);
ivec2 size = imageSize(image);
if(texelCoord.x < size.x && texelCoord.y < size.y)
{
vec4 color;
mainImage(color,texelCoord);
imageStore(image, texelCoord, color);
}
}

Binary file not shown.

377
src/Common/Logger.h Normal file
View File

@ -0,0 +1,377 @@
#ifndef LOGGER_H
#define LOGGER_H
// Custom includes
// Enums
enum class LogModule {
ENGINE,
RENDERER,
GLFW,
CLEANUP
};
enum class LogLevel {
EDEBUG,
EINIT, // Initialization related
EINFO, // General infos
EWARN,
EERROR,
EFATAL
};
class NetLogger {
public:
struct Server{
int priority;
char* url[]; // Put the url at the end for bit optimization
};
void initNetLogger(Server server);
void logNet(char* body[], char* head, Server server);
void logNetAsync(); // Todo
private:
};
class Logger {
public:
// Members
std::string logBuffer; // Log is empty by default
std::vector<std::string_view> lines;
// Functions
template<typename... Args>
void logDisk(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
); // Logs to a file on disk
// Overload
void logDisk(std::string_view message);
template<typename... Args>
void logRAM(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
); // Logs to ram (ImGUI)
template<typename... Args>
void logConsole(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
); // Logs to the console (crashes, etc...)
template<typename... Args>
void logAll(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
); // Logs using all of the above, RAM then console and finally disk, maybe multithread (?)
template<typename... Args>
void logImportant(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
); // Logs to console and file, in cases of crashes or errors
template<typename... Args>
void logFatal(
LogModule module,
std::string_view message,
Args&&... args
); // Logs to console and file, then abort -> Core dump
// Utils functions
void merge(std::string_view source); // Merges a source dumped logs into this
void logSeparator();
void clear();
private:
// Helper functions
static std::string_view moduleToString(LogModule m);
static std::string_view levelToString(LogLevel l);
};
#endif // End of header
#ifdef LOGGER_IMPL
#ifndef LOGGER_IMPL_H
#define LOGGER_IMPL_H
// Implementation
// Includes
//#include <httplib.h> // Todo : add it in the flake
#include <iostream>
#include <fstream>
#include <chrono>
/*
void NetLogger::initNetLogger(Server server) {
httplib::Client cli(server.url)
// Todo : add error handling
}
*/
template<typename... Args>
void Logger::logRAM(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
) {
auto now = std::chrono::system_clock::now();
auto timestamp = std::format("{:%Y-%m-%d %H:%M}", now);
auto start = logBuffer.size();
fmt::format_to(
std::back_inserter(logBuffer),
"[{}] ",
timestamp
);
fmt::format_to(
std::back_inserter(logBuffer),
"[{}:{}] ",
moduleToString(module),
levelToString(level)
);
fmt::format_to(
std::back_inserter(logBuffer),
fmt::runtime(message),
std::forward<Args>(args)...
);
logBuffer.push_back('\n');
auto end = logBuffer.size();
lines.emplace_back(logBuffer.data() + start, end - start);
}
template<typename... Args>
void Logger::logConsole(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
) {
std::string tempBuffer;
auto now = std::chrono::system_clock::now();
auto timestamp = std::format("{:%Y-%m-%d %H:%M}", now);
fmt::format_to(
std::back_inserter(tempBuffer),
"[{}] ",
timestamp
);
fmt::format_to(
std::back_inserter(tempBuffer),
"[{}:{}] ",
moduleToString(module),
levelToString(level)
);
fmt::format_to(
std::back_inserter(tempBuffer),
fmt::runtime(message),
std::forward<Args>(args)...
);
std::cout.write(tempBuffer.data(), tempBuffer.size());
std::cout.put('\n');
}
template<typename... Args>
void Logger::logDisk(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
) {
// Open the logfile
std::ofstream logFile ("log.txt", std::ios::out | std::ios::app);
if (!logFile.good()) {
throw std::runtime_error("Failed to open logfile !");
}
// Create a temporary buffer
std::string tempBuffer;
auto now = std::chrono::system_clock::now();
auto timestamp = std::format("{:%Y-%m-%d %H:%M}", now);
fmt::format_to(
std::back_inserter(tempBuffer),
"[{}] ",
timestamp
);
fmt::format_to(
std::back_inserter(tempBuffer),
"[{}:{}] ",
moduleToString(module),
levelToString(level)
);
fmt::format_to(
std::back_inserter(tempBuffer),
fmt::runtime(message),
std::forward<Args>(args)...
);
logFile << tempBuffer << '\n';
logFile.close();
}
// Overload to inject a message
void Logger::logDisk(std::string_view message) {
std::ofstream logFile ("log.txt", std::ios::out | std::ios::app);
if (!logFile.good()) {
throw std::runtime_error("Failed to open logfile !");
}
logFile << message << '\n';
logFile.close();
}
template<typename... Args>
void Logger::logAll(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
) {
// Logs to all targets !
logRAM(
module,
level,
message,
args...
);
logConsole(
module,
level,
message,
args...
);
logDisk(
module,
level,
message,
args...
);
}
template<typename... Args>
void Logger::logImportant(
LogModule module,
LogLevel level,
std::string_view message,
Args&&... args
) {
logDisk(
module,
level,
message,
args...
);
logConsole(
module,
level,
message,
args...
);
}
template<typename... Args>
void Logger::logFatal(
LogModule module,
std::string_view message,
Args&&... args
) {
// Separator
logDisk("================================== CRASH LOGS ==================================");
logDisk(
module,
LogLevel::EFATAL,
message,
args...
);
logConsole(
module,
LogLevel::EFATAL,
message,
args...
);
logSeparator();
std::abort();
}
void Logger::merge(std::string_view source) {
/*
This merges a dumped logger into this one
Assumes the other logger is already formated.
This allows to add arbitrary strings into the logs
*/
logBuffer += source;
}
void Logger::logSeparator() {
logDisk("================================================================================");
}
void Logger::clear() {
logBuffer.clear();
}
std::string_view Logger::moduleToString(LogModule m) {
using enum LogModule;
switch (m) {
case ENGINE: return "Engine";
case RENDERER: return "Renderer";
case GLFW: return "GLFW";
case CLEANUP: return "CLEANUP";
default: return "Unkown";
}
}
std::string_view Logger::levelToString(LogLevel l) {
using enum LogLevel;
switch (l) {
case EDEBUG: return "Debug";
case EINFO: return "Info";
case EINIT: return "Init";
case EWARN: return "Warn";
case EERROR: return "Error";
case EFATAL: return "Fatal";
default: return "???";
}
}
#endif
#endif

41
src/Common/Timer.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef TIMER_H
#define TIMER_H
// Custom includes
#include <chrono>
class RunTimer {
public:
void startTimer();
int endTimer();
private:
// Aliases
using Clock = std::chrono::steady_clock;
using TimePoint = std::chrono::time_point<Clock>;
TimePoint startTime;
TimePoint endTime;
};
#endif // End of header
#ifdef TIMER_IMPL
#ifndef TIMER_IMPL_H
#define TIMER_IMPL_H
// Implementation
void RunTimer::startTimer(){
startTime = Clock::now();
}
int RunTimer::endTimer() {
endTime = Clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(endTime - startTime);
return elapsed.count();
}
#endif
#endif

121
src/Common/Types.h Normal file
View File

@ -0,0 +1,121 @@
#ifndef TYPES_H
#define TYPES_H
// Normal header
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <span>
#include <array>
#include <functional>
#include <deque>
#include <chrono>
#include <thread>
#include <fmt/base.h>
#include <stdexcept>
#include <cstdint>
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_core.h>
#include <vulkan/vk_enum_string_helper.h>
#include <vk_mem_alloc.h>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <glm/mat4x4.hpp>
#include <glm/vec4.hpp>
// Custom headers
//#include "callbacks.h"
#include "Timer.h"
#include "Logger.h"
// Custom macro
#define VK_CHECK(x) \
do { \
VkResult err = x; \
if (err) { \
fmt::println("[Engine:Error] Vulkan error : {}", string_VkResult(err)); \
abort(); \
} \
} while (0) \
// Custom types
struct DeletionQueue {
std::deque<std::function<void()>> deletors;
void pushFunction(
std::function<void()>&& function
) {
deletors.push_back(function);
}
void flush() {
// Reverse iterate the deletion queue to destroy in order
for (
auto it = deletors.rbegin();
it != deletors.rend();
it++
) {
(*it)();
}
deletors.clear();
}
};
struct AllocatedImage {
VkImage image;
VkImageView imageView;
VmaAllocation allocation;
VkExtent3D imageExtent;
VkFormat imageFormat;
};
struct AllocatedBuffer {
VkBuffer buffer;
VmaAllocation allocation;
VmaAllocationInfo info;
};
struct Vertex {
alignas(16) glm::vec3 position;
float uv_x;
alignas(16) glm::vec3 normal;
float uv_y;
glm::vec4 color;
};
// Holds the ressouces required for a mesh
struct GPUMeshBuffers {
AllocatedBuffer indexBuffer;
AllocatedBuffer vertexBuffer;
VkDeviceAddress vertexBufferAddress;
};
struct GPUDrawPushConstants {
glm::mat4 worldMatrix;
VkDeviceAddress vertexBuffer;
};
// Engine config
struct EngineConfig {
int gpuIndex;
};
// "Global" ? (I hope so) logger
Logger logger;
#endif
#ifdef TYPES_IMPL
#ifndef TYPES_IMPL_H
#define TYPES_IMPL_H
// Implementation
#endif
#endif

View File

@ -0,0 +1,25 @@
#ifndef CALLBACK_H
#define CALLBACK_H
// Header
// Other includes
#include "Common/Types.h"
class Callback {
public:
static void keyboardCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
};
#endif
#ifdef CALLBACK_IMPL
#ifndef CALLBACK_IMPL_H
#define CALLBACK_IMPL_H
void Callback::keyboardCallback(GLFWwindow* window, int key, int scancode, int action, int mods) {
#ifdef DEBUG
logger.logRAM(LogModule::GLFW, LogLevel::EINFO, "Key pressed, key {}", key);
#endif
}
#endif
#endif

View File

@ -0,0 +1,232 @@
#ifndef DESCRIPTORS_H
#define DESCRIPTORS_H
// Header
// Other includes
#include "Common/Types.h"
#include <cstdint>
#include <fmt/base.h>
#include <span>
#include <vulkan/vulkan_core.h>
struct DescriptorLayoutBuilder {
std::vector<VkDescriptorSetLayoutBinding> bindings;
void addBinding(
uint32_t binding,
VkDescriptorType type
);
void clear();
VkDescriptorSetLayout build (
VkDevice device,
VkShaderStageFlags shaderStages,
void* pNext = nullptr,
VkDescriptorSetLayoutCreateFlags flags = 0
);
};
struct DescriptorAllocator {
struct PoolSizeRatio {
VkDescriptorType type;
float ratio;
};
VkDescriptorPool pool;
void initPool(
VkDevice device,
uint32_t maxSets,
std::span<PoolSizeRatio> poolRatios
);
void clearDescriptors(
VkDevice device
);
void destroyPool(
VkDevice device
);
VkDescriptorSet allocate(
VkDevice device,
VkDescriptorSetLayout layout
);
};
#endif
#ifdef DESCRIPTORS_IMPL
#ifndef DESCRIPTORS_IMPL_H
#define DESCRIPTORS_IMPL_H
// The actual implementation
void DescriptorLayoutBuilder::addBinding(
uint32_t binding,
VkDescriptorType type
){
#ifdef DEBUG
fmt::println("[DescriptorLayoutBuilder] Adding a descriptor set binding...");
#endif
VkDescriptorSetLayoutBinding newBind {
.binding = binding,
.descriptorType = type,
.descriptorCount = 1
};
bindings.push_back(newBind);
#ifdef DEBUG
fmt::println("[DescriptorLayoutBuilder] Descriptor set binding added !");
#endif
}
void DescriptorLayoutBuilder::clear() {
#ifdef DEBUG
fmt::println("[DescriptorLayoutBuilder] Clearing a descriptor set...");
#endif
bindings.clear();
#ifdef DEBUG
fmt::println("[DescriptorLayoutBuilder] Descriptor set cleared !");
#endif
}
VkDescriptorSetLayout DescriptorLayoutBuilder::build (
VkDevice device,
VkShaderStageFlags shaderStages,
void* pNext,
VkDescriptorSetLayoutCreateFlags flags
) {
#ifdef DEBUG
fmt::println("[DescriptorLayoutBuilder] Building a descriptor set...");
#endif
for (auto& b : bindings) {
b.stageFlags |= shaderStages;
}
VkDescriptorSetLayoutCreateInfo info = {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
.pNext = pNext,
.flags = flags,
.bindingCount = (uint32_t)bindings.size(),
.pBindings = bindings.data(),
};
VkDescriptorSetLayout set;
VK_CHECK(
vkCreateDescriptorSetLayout(
device,
&info,
nullptr,
&set
)
);
#ifdef DEBUG
fmt::println("[DescriptorLayoutBuilder] Descriptor set built !");
#endif
return set;
}
void DescriptorAllocator::initPool(
VkDevice device,
uint32_t maxSets,
std::span<PoolSizeRatio> poolRatios
) {
#ifdef DEBUG
fmt::println("[DescriptorAllocator] Initializing a new pool..");
#endif
std::vector<VkDescriptorPoolSize> poolSizes;
for (PoolSizeRatio ratio : poolRatios) {
poolSizes.push_back(VkDescriptorPoolSize {
.type = ratio.type,
.descriptorCount = uint32_t(ratio.ratio * maxSets)
});
}
VkDescriptorPoolCreateInfo poolInfo = {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
.flags = 0,
.maxSets = maxSets,
.poolSizeCount = (uint32_t)poolSizes.size(),
.pPoolSizes = poolSizes.data()
};
vkCreateDescriptorPool(
device,
&poolInfo,
nullptr,
&pool
);
#ifdef DEBUG
fmt::println("[DescriptorAllocator] Descriptor pool initialized...");
#endif
}
void DescriptorAllocator::clearDescriptors(
VkDevice device
) {
#ifdef DEBUG
fmt::println("[DescriptorAllocator] Clearing a descriptor set...");
#endif
vkResetDescriptorPool(
device,
pool,
0
);
#ifdef DEBUG
fmt::println("[DescriptorAllocator] Descriptor set cleared !");
#endif
}
void DescriptorAllocator::destroyPool(
VkDevice device
) {
#ifdef DEBUG
fmt::println("[DescriptorAllocator] Destroying a descriptor pool...");
#endif
vkDestroyDescriptorPool(
device,
pool,
nullptr
);
#ifdef DEBUG
fmt::println("[DescriptorAllocator] Descriptor pool destroyed !");
#endif
}
VkDescriptorSet DescriptorAllocator::allocate(
VkDevice device,
VkDescriptorSetLayout layout
){
VkDescriptorSetAllocateInfo allocInfo = {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
.pNext = nullptr,
.descriptorPool = pool,
.descriptorSetCount = 1,
.pSetLayouts = &layout
};
VkDescriptorSet ds;
VK_CHECK(
vkAllocateDescriptorSets(
device,
&allocInfo,
&ds
)
);
return ds;
}
#endif
#endif

2236
src/Engine/engine/engine.h Normal file

File diff suppressed because it is too large Load Diff

127
src/Engine/engine/images.h Normal file
View File

@ -0,0 +1,127 @@
#ifndef IMAGES_H
#define IMAGES_H
// Normal header
#include "Common/Types.h"
namespace vkutil {
void transitionImage(
VkCommandBuffer cmd,
VkImage image,
VkImageLayout currentLayout,
VkImageLayout newLayout
);
void copyImageToImage(
VkCommandBuffer cmd,
VkImage source,
VkImage destination,
VkExtent2D srcSize,
VkExtent2D dstSize
);
}
#endif
#ifdef IMAGES_IMPL
#ifndef IMAGES_IMPL_H
#define IMAGES_IMPL_H
// Implementation
#include "initializers.h"
namespace vkutil {
void transitionImage(
VkCommandBuffer cmd,
VkImage image,
VkImageLayout currentLayout,
VkImageLayout newLayout
) {
VkImageMemoryBarrier2 imageBarrier {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
.pNext = nullptr,
.srcStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
.srcAccessMask = VK_ACCESS_2_MEMORY_WRITE_BIT,
.dstStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
.dstAccessMask = VK_ACCESS_2_MEMORY_WRITE_BIT | VK_ACCESS_2_MEMORY_READ_BIT,
.oldLayout = currentLayout,
.newLayout = newLayout
};
VkImageAspectFlags aspectMask = (newLayout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
imageBarrier.subresourceRange = vkinit::imageSubresourceRange(aspectMask);
imageBarrier.image = image;
VkDependencyInfo depInfo {
.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
.pNext = nullptr,
.imageMemoryBarrierCount = 1,
.pImageMemoryBarriers = &imageBarrier
};
vkCmdPipelineBarrier2(cmd, &depInfo);
}
void copyImageToImage(
VkCommandBuffer cmd,
VkImage source,
VkImage destination,
VkExtent2D srcSize,
VkExtent2D dstSize
) {
VkImageBlit2 blitRegion {
.sType = VK_STRUCTURE_TYPE_IMAGE_BLIT_2,
.pNext = nullptr,
.srcSubresource = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.mipLevel = 0,
.baseArrayLayer = 0,
.layerCount = 1,
},
.srcOffsets = {
VkOffset3D { 0, 0, 0 },
VkOffset3D {
(int32_t)srcSize.width,
(int32_t)srcSize.height,
1
}
},
.dstSubresource = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.mipLevel = 0,
.baseArrayLayer = 0,
.layerCount = 1
},
.dstOffsets = {
VkOffset3D { 0, 0, 0 },
VkOffset3D {
(int32_t)dstSize.width,
(int32_t)dstSize.height,
1
}
},
};
VkBlitImageInfo2 blitInfo = {
.sType = VK_STRUCTURE_TYPE_BLIT_IMAGE_INFO_2,
.pNext = nullptr,
.srcImage = source,
.srcImageLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
.dstImage = destination,
.dstImageLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
.regionCount = 1,
.pRegions = &blitRegion,
.filter = VK_FILTER_LINEAR,
};
vkCmdBlitImage2(cmd, &blitInfo);
}
}
#endif
#endif

View File

@ -0,0 +1,349 @@
#ifndef INITIALIZERS_H
#define INITIALIZERS_H
// Normal header
#include "Common/Types.h"
#include <vulkan/vulkan_core.h>
namespace vkinit {
VkCommandPoolCreateInfo commandPoolCreateInfo(
uint32_t queueFamilyIndex,
VkCommandPoolCreateFlags flags = 0
);
VkCommandBufferAllocateInfo commandBufferAllocateInfo(
VkCommandPool pool,
uint32_t count
);
VkFenceCreateInfo fenceCreateInfo(
VkFenceCreateFlags flags = 0
);
VkSemaphoreCreateInfo semaphoreCreateInfo (
VkSemaphoreCreateFlags flags = 0
);
VkCommandBufferBeginInfo commandBufferBeginInfo (
VkCommandBufferUsageFlags flags = 0
);
VkImageSubresourceRange imageSubresourceRange(
VkImageAspectFlags aspectMask
);
VkSemaphoreSubmitInfo semaphoreSubmitInfo(
VkPipelineStageFlags2 stageMask,
VkSemaphore semaphore
);
VkCommandBufferSubmitInfo commandBufferSubmitInfo (
VkCommandBuffer cmd
);
VkSubmitInfo2 submitInfo(
VkCommandBufferSubmitInfo* cmd,
VkSemaphoreSubmitInfo* signalSemaphoreInfo,
VkSemaphoreSubmitInfo* waitSemaphoreInfo
);
VkImageCreateInfo imageCreateInfo(
VkFormat format,
VkImageUsageFlags usageFlags,
VkExtent3D extent
);
VkImageViewCreateInfo imageViewCreateInfo(
VkFormat format,
VkImage image,
VkImageAspectFlags aspectFlags
);
VkRenderingAttachmentInfo attachmentInfo(
VkImageView view,
VkClearValue* clear,
VkImageLayout layout /*= VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL*/
);
VkRenderingInfo renderingInfo(
VkExtent2D renderExtent,
VkRenderingAttachmentInfo* colorAttachment,
VkRenderingAttachmentInfo* depthAttachment
);
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo();
VkPipelineShaderStageCreateInfo pipelineShaderStageCreateInfo(
VkShaderStageFlagBits stage,
VkShaderModule shaderModule,
const char * entry = "main"
);
}
#endif
#ifdef INITIALIZERS_IMPL
#ifndef INITIALIZERS_IMPL_H
#define INITIALIZERS_IMPL_H
// Implementation
namespace vkinit {
VkCommandPoolCreateInfo commandPoolCreateInfo(
uint32_t queueFamilyIndex,
VkCommandPoolCreateFlags flags
) {
VkCommandPoolCreateInfo info {
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.pNext = nullptr,
.flags = flags,
.queueFamilyIndex = queueFamilyIndex
};
return info;
}
VkCommandBufferAllocateInfo commandBufferAllocateInfo(
VkCommandPool pool,
uint32_t count
) {
VkCommandBufferAllocateInfo info {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
.pNext = nullptr,
.commandPool = pool,
.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
.commandBufferCount = count
};
return info;
}
VkFenceCreateInfo fenceCreateInfo(
VkFenceCreateFlags flags /*= 0 */
) {
VkFenceCreateInfo info {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
.pNext = nullptr,
.flags = flags
};
return info;
}
VkSemaphoreCreateInfo semaphoreCreateInfo (
VkSemaphoreCreateFlags flags /*= 0*/
) {
VkSemaphoreCreateInfo info {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
.pNext = nullptr,
.flags = flags,
};
return info;
}
VkCommandBufferBeginInfo commandBufferBeginInfo (
VkCommandBufferUsageFlags flags /*= 0*/
) {
VkCommandBufferBeginInfo info {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.pNext = nullptr,
.flags = flags,
.pInheritanceInfo = nullptr
};
return info;
}
VkImageSubresourceRange imageSubresourceRange(
VkImageAspectFlags aspectMask
) {
VkImageSubresourceRange subImage {
.aspectMask = aspectMask,
.baseMipLevel = 0,
.levelCount = VK_REMAINING_MIP_LEVELS,
.baseArrayLayer = 0,
.layerCount = VK_REMAINING_ARRAY_LAYERS,
};
return subImage;
}
VkSemaphoreSubmitInfo semaphoreSubmitInfo(
VkPipelineStageFlags2 stageMask,
VkSemaphore semaphore
) {
VkSemaphoreSubmitInfo submitInfo {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
.pNext = nullptr,
.semaphore = semaphore,
.value = 1,
.stageMask = stageMask,
.deviceIndex = 0
};
return submitInfo;
}
VkCommandBufferSubmitInfo commandBufferSubmitInfo (
VkCommandBuffer cmd
) {
VkCommandBufferSubmitInfo info {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO,
.pNext = nullptr,
.commandBuffer = cmd,
.deviceMask = 0
};
return info;
}
VkSubmitInfo2 submitInfo(
VkCommandBufferSubmitInfo* cmd,
VkSemaphoreSubmitInfo* signalSemaphoreInfo,
VkSemaphoreSubmitInfo* waitSemaphoreInfo
) {
VkSubmitInfo2 info {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO_2,
.pNext = nullptr,
.waitSemaphoreInfoCount = static_cast<uint32_t>(waitSemaphoreInfo == nullptr ? 0 : 1),
.pWaitSemaphoreInfos = waitSemaphoreInfo,
.commandBufferInfoCount = 1,
.pCommandBufferInfos = cmd,
.signalSemaphoreInfoCount = static_cast<uint32_t>(signalSemaphoreInfo == nullptr ? 0 : 1),
.pSignalSemaphoreInfos = signalSemaphoreInfo
};
return info;
}
VkImageCreateInfo imageCreateInfo(
VkFormat format,
VkImageUsageFlags usageFlags,
VkExtent3D extent
) {
VkImageCreateInfo info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = nullptr,
.imageType = VK_IMAGE_TYPE_2D,
.format = format,
.extent = extent,
.mipLevels = 1,
.arrayLayers = 1,
//for MSAA. I won't be using it, so only 1 sample per pixel
.samples = VK_SAMPLE_COUNT_1_BIT,
.tiling = VK_IMAGE_TILING_OPTIMAL,
.usage = usageFlags
};
return info;
}
VkImageViewCreateInfo imageViewCreateInfo(
VkFormat format,
VkImage image,
VkImageAspectFlags aspectFlags
) {
VkImageViewCreateInfo info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
.pNext = nullptr,
.image = image,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = format,
.subresourceRange = {
.aspectMask = aspectFlags,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = 1,
}
};
return info;
}
VkRenderingAttachmentInfo attachmentInfo(
VkImageView view,
VkClearValue* clear,
VkImageLayout layout /*= VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL*/
) {
VkRenderingAttachmentInfo colorAttachment {
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
.pNext = nullptr,
.imageView = view,
.imageLayout = layout,
.loadOp = clear ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE
};
if (clear) {
colorAttachment.clearValue = *clear;
}
return colorAttachment;
}
VkRenderingInfo renderingInfo(
VkExtent2D renderExtent,
VkRenderingAttachmentInfo* colorAttachment,
VkRenderingAttachmentInfo* depthAttachment
) {
VkRenderingInfo renderInfo {
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
.pNext = nullptr,
.renderArea = VkRect2D {
VkOffset2D {
0,
0
}, renderExtent
},
.layerCount = 1,
.colorAttachmentCount = 1,
.pColorAttachments = colorAttachment,
.pDepthAttachment = depthAttachment,
.pStencilAttachment = nullptr
};
return renderInfo;
}
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo() {
VkPipelineLayoutCreateInfo info {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.pNext = nullptr,
// Empty defaults
.flags = 0,
.setLayoutCount = 0,
.pSetLayouts = nullptr,
.pushConstantRangeCount = 0,
.pPushConstantRanges = nullptr,
};
return info;
}
VkPipelineShaderStageCreateInfo pipelineShaderStageCreateInfo(
VkShaderStageFlagBits stage,
VkShaderModule shaderModule,
const char * entry
) {
VkPipelineShaderStageCreateInfo info {
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.pNext = nullptr,
.stage = stage,
.module = shaderModule,
.pName = entry
};
return info;
}
}
#endif
#endif

114
src/Engine/engine/loader.h Normal file
View File

@ -0,0 +1,114 @@
#ifndef LOADER_H
#define LOADER_H
// Header
// Custom includes
#include "Common/Types.h"
// Other includes
#include <cstdint>
#include <unordered_map>
#include <filesystem>
// Stucts
struct GeoSurface {
uint32_t startIndex;
uint32_t count;
};
struct MeshAsset {
std::string name;
std::vector<GeoSurface> surfaces;
GPUMeshBuffers meshBuffers;
};
// Forward declaration
class Engine;
#endif
#ifdef LOADER_IMPL
#ifndef LOADER_IMPL_H
#define LOADER_IMPL_H
// Main code file
// Includes
#include <fastgltf/core.hpp>
#include <fastgltf/types.hpp>
#include <fastgltf/glm_element_traits.hpp>
#include <fastgltf/tools.hpp>
std::optional<std::vector<std::shared_ptr<MeshAsset>>> loadGltfMeshes(
Engine* engine,
std::filesystem::path filePath
) {
auto& logger = engine->_logger; // Uses the main logger
logger.logAll(LogModule::ENGINE, LogLevel::EINFO, "Loading GLTF: {}", filePath.string());
fastgltf::Parser parser;
fastgltf::Asset gltf;
auto data = fastgltf::GltfDataBuffer::FromPath(filePath);
constexpr auto gltfOptions {
fastgltf::Options::LoadExternalBuffers
};
auto load = parser.loadGltf(
data.get(),
filePath.parent_path(),
gltfOptions
);
if(load) {
gltf = std::move(load.get());
} else {
logger.logFatal(LogModule::ENGINE, "Failed to load gltf: {}", fastgltf::to_underlying(load.error()));
}
std::vector<std::shared_ptr<MeshAsset>> meshes;
// Use the same vectors for all meshes
// so that the memory doesn't reallocate
// as often
std::vector<uint32_t> indices;
std::vector<Vertex> vertices;
// Now, some gltf gymnastics to get data into the correct buffers.
/*
====================================
The following comments are notes,
to help me build the loader,
based on the new fastgltf api
(the vkguide is using an older api)
====================================
By reading the vkguide, I can see that
he's iterating on "gltf" which is an Asset.
In the official docs, it is stated we can get direct
references to the Asset class, using pointers (->)
For exemple with buffers: asset->buffers
But the guide is using asset.meshes ?
We'll need to validate if it's a real class member
Then, foreach meshes in the file, he creates a temporary mesh,
that he will fill with the model data.
He assign the model name from the big chunk (we'll call it the Origin)
He does some cleaning, to not merge meshes by error.
And...uh..another loop.
This time, it's using mesh.primitives, which is the iterator of the first loop.
It creates a new GeoSurface, foreach "primitives" ?
*/
// Debug things
return meshes;
}
#endif
#endif

View File

@ -0,0 +1,362 @@
#ifndef PIPELINES_H
#define PIPELINES_H
// Normal header
#include "Common/Types.h"
#include <cstddef>
#include <cstdint>
#include <fmt/base.h>
#include <vector>
#include <vulkan/vulkan_core.h>
namespace vkutil {
bool loadShaderModule(
const char* filePath,
VkDevice device,
VkShaderModule* outShaderModule
);
};
class PipelineBuilder {
public:
std::vector<VkPipelineShaderStageCreateInfo> _shaderStages;
VkPipelineInputAssemblyStateCreateInfo _inputAssembly;
VkPipelineRasterizationStateCreateInfo _rasterizer;
VkPipelineColorBlendAttachmentState _colorBlendAttachment;
VkPipelineMultisampleStateCreateInfo _multisampling;
VkPipelineLayout _pipelineLayout;
VkPipelineDepthStencilStateCreateInfo _depthStencil;
VkPipelineRenderingCreateInfo _renderInfo;
VkFormat _colorAttachmentFormat;
PipelineBuilder() { clear(); }
void clear();
VkPipeline buildPipeline(
VkDevice device
);
void setShaders(
VkShaderModule vertexShader,
VkShaderModule fragmentShader
);
void setInputTopology(
VkPrimitiveTopology topology
);
void setPolygonMode(
VkPolygonMode mode
);
void setCullMode(
VkCullModeFlags cullMode,
VkFrontFace frontFace
);
void setMultisamplingNone();
void disableBlending ();
void setColorAttachmentFormat(
VkFormat format
);
void setDepthFormat(
VkFormat format
);
void disableDepthtest();
};
#endif
#ifdef PIPELINES_IMPL
#ifndef PIPELINES_IMPL_H
#define PIPELINES_IMPL_H
// Implementation
// Imports
#include <fstream>
// Custom imports
#include "initializers.h"
bool vkutil::loadShaderModule(
const char* filePath,
VkDevice device,
VkShaderModule* outShaderModule
) {
#ifdef DEBUG
fmt::println("[Engine:Utils] Loading shader located at {}...", filePath);
#endif
// Open the file, with the cursor at the end
std::ifstream file(
filePath,
std::ios::ate | std::ios::binary
);
if (!file.is_open()) {
return false;
}
// Find the size of the file by looking
// at the cursor
size_t fileSize = (size_t)file.tellg();
// Allocate a big enough vector to suit SPIR-V
std::vector<uint32_t> buffer(fileSize/ sizeof(uint32_t));
file.seekg(0); // Put the cursor at the begining
// Load the file in the buffer
file.read((char*)buffer.data(), fileSize);
file.close();
// Create the shader module
VkShaderModuleCreateInfo createInfo {
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
.pNext = nullptr,
.codeSize = buffer.size() * sizeof(uint32_t), // Convert to bytes
.pCode = buffer.data()
};
// Check that everything went well
VkShaderModule shaderModule;
if (vkCreateShaderModule(
device,
&createInfo,
nullptr,
&shaderModule
) != VK_SUCCESS){
return false;
}
*outShaderModule = shaderModule;
#ifdef DEBUG
fmt::println("[Engine:Utils] Shader loaded from {} and size {}", filePath, fileSize);
#endif
return true;
}
void PipelineBuilder::clear() {
#ifdef DEBUG
fmt::println("[PipelineBuilder] Clearing pipeline...");
#endif
// Clear structs
_inputAssembly = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
};
_rasterizer = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO
};
_colorBlendAttachment = {};
_multisampling = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
};
_pipelineLayout = {};
_depthStencil = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO
};
_renderInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO
};
_shaderStages.clear();
#ifdef DEBUG
fmt::println("[PipelineBuilder] Pipeline cleared !");
#endif
}
VkPipeline PipelineBuilder::buildPipeline (
VkDevice device
) {
#ifdef DEBUG
fmt::println("[PipelineBuilder] Building rasterisation pipeline...");
#endif
// Make the viewport state from our stored viewport and scissor
// This makes it that it won't support multiple viewports or scissors
VkPipelineViewportStateCreateInfo viewportState {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
.pNext = nullptr,
.viewportCount = 1,
.scissorCount = 1
};
// Setup placeholder color blending.
// Need to be changed when using transparent objects, which we aren't rn
// The blending is "no blend", but we write it to the color attachment
VkPipelineColorBlendStateCreateInfo colorBlending {
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
.pNext = nullptr,
.logicOpEnable = VK_FALSE,
.logicOp = VK_LOGIC_OP_COPY,
.attachmentCount = 1,
.pAttachments = &_colorBlendAttachment
};
// Completely clear VertexInputStateCreateInfo, as we have no need for it
VkPipelineVertexInputStateCreateInfo _vertexInputInfo {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
};
// Dynamic Viewport
VkDynamicState state[] = {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR
};
VkPipelineDynamicStateCreateInfo dynamicInfo {
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
.dynamicStateCount = 2,
.pDynamicStates = &state[0]
};
// Build the pipeline
// Uses all the class members info structs
VkGraphicsPipelineCreateInfo pipelineInfo {
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
.pNext = &_renderInfo,
.stageCount = (uint32_t)_shaderStages.size(),
.pStages = _shaderStages.data(),
.pVertexInputState = &_vertexInputInfo,
.pInputAssemblyState = &_inputAssembly,
.pViewportState = &viewportState,
.pRasterizationState = &_rasterizer,
.pMultisampleState = &_multisampling,
.pDepthStencilState = &_depthStencil,
.pColorBlendState = &colorBlending,
.pDynamicState = &dynamicInfo,
.layout = _pipelineLayout
};
// Check the creation of the pipeline
// I don't use the VK_CHECK()
// 'cause there might be pipeline-specific options
VkPipeline newPipeline;
if(
vkCreateGraphicsPipelines(
device,
VK_NULL_HANDLE,
1,
&pipelineInfo,
nullptr,
&newPipeline
) != VK_SUCCESS
) {
fmt::println("[PipelineBuilder] Failed to create pipeline !");
return VK_NULL_HANDLE; // Graphics pipeline failed to be created
} else {
return newPipeline;
}
}
void PipelineBuilder::setShaders(
VkShaderModule vertexShader,
VkShaderModule fragmentShader
) {
_shaderStages.clear();
_shaderStages.push_back(
vkinit::pipelineShaderStageCreateInfo(
VK_SHADER_STAGE_VERTEX_BIT,
vertexShader
)
);
_shaderStages.push_back(
vkinit::pipelineShaderStageCreateInfo(
VK_SHADER_STAGE_FRAGMENT_BIT,
fragmentShader
)
);
}
void PipelineBuilder::setInputTopology(
VkPrimitiveTopology topology
) {
_inputAssembly.topology = topology;
// I am not going to use primitive restart rn
// so I leave it on false
_inputAssembly.primitiveRestartEnable = VK_FALSE;
}
void PipelineBuilder::setPolygonMode(
VkPolygonMode mode
) {
_rasterizer.polygonMode = mode;
_rasterizer.lineWidth = 1.0f;
}
void PipelineBuilder::setCullMode(
VkCullModeFlags cullMode,
VkFrontFace frontFace
) {
_rasterizer.cullMode = cullMode;
_rasterizer.frontFace = frontFace;
}
void PipelineBuilder::setMultisamplingNone() {
_multisampling.sampleShadingEnable = VK_FALSE;
// Multisampling defaulted to no multisampling (1 sample per pixel)
_multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
_multisampling.minSampleShading = 1.0f;
_multisampling.pSampleMask = nullptr;
// No alpha to coverage either
_multisampling.alphaToCoverageEnable = VK_FALSE;
_multisampling.alphaToOneEnable = VK_FALSE;
}
void PipelineBuilder::disableBlending() {
// Default write mask
_colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
// No blending
_colorBlendAttachment.blendEnable = VK_FALSE;
}
void PipelineBuilder::setColorAttachmentFormat(
VkFormat format
) {
_colorAttachmentFormat = format;
// connect the format to the renderInfo structure
_renderInfo.colorAttachmentCount = 1;
_renderInfo.pColorAttachmentFormats = &_colorAttachmentFormat;
}
void PipelineBuilder::setDepthFormat(
VkFormat format
) {
_renderInfo.depthAttachmentFormat = format;
}
void PipelineBuilder::disableDepthtest() {
_depthStencil.depthTestEnable = VK_FALSE;
_depthStencil.depthWriteEnable = VK_FALSE;
_depthStencil.depthCompareOp = VK_COMPARE_OP_NEVER;
_depthStencil.depthBoundsTestEnable = VK_FALSE;
_depthStencil.stencilTestEnable = VK_FALSE;
_depthStencil.front = {};
_depthStencil.back = {};
_depthStencil.minDepthBounds = 0.0f;
_depthStencil.maxDepthBounds = 1.0f;
}
#endif
#endif

100
src/Engine/main.cpp Normal file
View File

@ -0,0 +1,100 @@
/*
Copyright Alexandre Delcamp-Enache, 2026
Based on vkguide.dev
See engine.h for extensive documentation
Also, checkout the roadmap
*/
#define ENGINE_IMPL
#include "engine/engine.h"
#include "CLI/CLI.hpp"
class ArgHandler {
public:
CLI::App* _run;
// All options
bool _listGPU {false};
int _gpuIndex {-1};
std::string _modelPath;
void buildArgs() {
// Setup
// Subcommands
_run = _app.add_subcommand("run");
// Main options/flags
_app.add_flag("--list-gpu, -l", _listGPU, "Lists available Graphics cards, useful for debugging");
_app.set_version_flag("--version, -v", BUILD_ID);
// Help
//_app.set_help_all_flag("--help-all", "Expand all help");
_app.set_help_flag();
_app.set_help_all_flag("--help, -h", "Print help for all subcommands");
// Subcommand options/flags
// Run
_run->add_option("--gpu, -g", _gpuIndex, "Manually select a GPU");
_run->add_option("--model, -m", _modelPath, "Overwrites the default model");
}
int dispatch(int argc, char* argv[]) {
CLI11_PARSE(_app, argc, argv);
return 0;
}
void printHelp() {
fmt::println("{}", _app.help());
}
private:
CLI::App _app;
};
int main(int argc, char* argv[]) {
// Classes we need
Engine engine;
ArgHandler handler;
// Exemple of overwriting a class value
//engine._windowExtent = { 67, 67 };
handler.buildArgs();
if (argc == 1) {
handler.printHelp();
fmt::println("Please use -h or --help to see all available options.");
return 0;
}
// Checks for -h flag
int result = handler.dispatch(argc, argv);
if(result != 0) return result;
if (handler._run->parsed() &&
handler._run->get_help_ptr()->as<bool>()) {
return 0;
}
if(handler._listGPU) {
engine.getAvailableGPU();
return 0;
}
if(handler._run->parsed()){
engine.parseConfig(
handler._gpuIndex,
handler._modelPath
);
engine.init();
engine.run();
engine.cleanup();
}
return 0;
}

10
src/Server/main.cpp Normal file
View File

@ -0,0 +1,10 @@
#define SERVER_IMPL
#include "server/server.h"
int main() {
GameServer mainServer;
mainServer.init();
return 0;
}

43
src/Server/server/init.h Normal file
View File

@ -0,0 +1,43 @@
#ifndef SERVER_INIT_H
#define SERVER_INIT_H
// Normal header
class GameServerInit {
// This class groups all the code required for
// the server to initialize and start being
// usable
public:
bool init(); // Uses a bool to mark if init was sucessfull
void cleanup();
private:
};
#endif
#ifdef SERVER_INIT_IMPL
#ifndef SERVER_INIT_IMPL_H
#define SERVER_INIT_IMPL_H
// Implementation
#include "Common/Types.h"
bool GameServerInit::init() {
// Create the logger server object,
// to send messages
// Try to compile but I don't think it'll work in the current state
NetLogger::Server logServer {
.priority = 1,
.url = "https://ntfy.alexdelcamp.fr"
// clangd gives an error, fix it using the corrext type ig
// Todo : read the server from a file and fallback to my own
};
NetLogger::initNetLogger(logServer);
// Add error detection (no connectivity for exemple)
return true; // Everything went correctly
}
#endif
#endif

View File

@ -0,0 +1,28 @@
#ifndef SERVER_H
#define SERVER_H
// Normal header
class GameServer {
public:
void init(); // Wrapper to the init function in the init class
void cleanup(); // Wrapper to the cleanup function in the init class
private:
};
#endif
#ifdef SERVER_IMPL
#ifndef SERVER_IMPL_H
#define SERVER_IMPL_H
// Implementation
#include "init.h"
void GameServer::init(){
//GameServerInit::init();
}
#endif
#endif

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 940 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB