From 6abd3f42a867271b710a888d28a5b31892f7839f Mon Sep 17 00:00:00 2001 From: Sharadh Rajaraman Date: Thu, 5 Sep 2024 07:48:19 +0100 Subject: [PATCH] Use `import std;` guarded by macro (#1932) * Initial build and tests setup * Enable the `CppStdModule` test * Snippets and generator changes * Generated files changes * Enable std module with macro * Unconditionally use `import std` with C++23 * Add support for external `import std` control with `VULKAN_HPP_ENABLE_STD_MODULE` - Rewrite `includes.hpp` and `macros.hpp` - Unconditionally set `VULKAN_HPP_ENABLE_STD_MODULE` for `vulkan.cppm` to bug-fix - Generated necessary files again * Top-level CMake changes * Reorganise logic, and propagate external macro correctly * RAII: vulkan_hpp before ifdef * Define `VK_USE_64_BIT_PTR_DEFINES` in `vulkan_hpp_macros.hpp` * Generate the `VK_USE_64_BIT_PTR_DEFINES` clause from the XML instead of hardcoding it * Refactored handling for `VK_USE_64_BIT_PTR_DEFINES` - Updated condition to positive test for `#ifndef VK_USE_64_BIT_PTR_DEFINES` in `completeMacro` * Added `#include ` to resolve `strnlen` missing in the module * Use only `std.compat` * FIx after rebase --- CMakeLists.txt | 8 +++- VulkanHppGenerator.cpp | 52 ++++++++++++++++----- snippets/includes.hpp | 28 ++++++----- snippets/macros.hpp | 11 ++++- tests/CMakeLists.txt | 3 ++ tests/Cpp20Modules/CMakeLists.txt | 5 +- tests/CppStdModule/CMakeLists.txt | 18 ++++++++ tests/CppStdModule/CppStdModule.cpp | 59 ++++++++++++++++++++++++ vulkan/vulkan.cppm | 7 +++ vulkan/vulkan.hpp | 31 ++++++++----- vulkan/vulkan_extension_inspection.hpp | 14 ++++-- vulkan/vulkan_hpp_macros.hpp | 17 ++++++- vulkan/vulkan_raii.hpp | 6 ++- vulkan/vulkan_shared.hpp | 5 +- vulkan/vulkan_to_string.hpp | 10 ++-- vulkan/vulkansc.cppm | 7 +++ vulkan/vulkansc.hpp | 29 +++++++----- vulkan/vulkansc_extension_inspection.hpp | 14 ++++-- vulkan/vulkansc_hpp_macros.hpp | 17 ++++++- vulkan/vulkansc_raii.hpp | 6 ++- vulkan/vulkansc_shared.hpp | 5 +- vulkan/vulkansc_to_string.hpp | 10 ++-- 22 files changed, 286 insertions(+), 76 deletions(-) create mode 100644 tests/CppStdModule/CMakeLists.txt create mode 100644 tests/CppStdModule/CppStdModule.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d57aac1..c5ec65e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ option( VULKAN_HPP_SAMPLES_BUILD_ONLY_DYNAMIC "Build only dynamic. Required in c option( VULKAN_HPP_TESTS_BUILD_ONLY_DYNAMIC "Build only dynamic" OFF ) option( VULKAN_HPP_BUILD_WITH_LOCAL_VULKAN_HPP "Build with local Vulkan headers" ON ) option( VULKAN_HPP_ENABLE_CPP20_MODULES "Build Vulkan-Hpp as C++20 module; requires minimum CMake version 3.28" OFF ) +option( VULKAN_HPP_ENABLE_STD_MODULE "Build Vulkan-Hpp with import std; requires minimum CMake version 3.30" OFF ) option( VULKAN_HPP_CPP20_MODULE_DYNAMIC_DISPATCHER "Build C++20 module with dynamic Dispatcher" ON ) if ( VULKAN_HPP_ENABLE_CPP20_MODULES ) @@ -346,7 +347,12 @@ if( VULKAN_HPP_ENABLE_CPP20_MODULES ) else() target_compile_definitions( VulkanHppModule PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=0 ) endif() - target_compile_features( VulkanHppModule PUBLIC cxx_std_20 ) + if( VULKAN_HPP_ENABLE_STD_MODULE ) + target_compile_features( VulkanHppModule PUBLIC cxx_std_23 ) + set_target_properties( VulkanHppModule PROPERTIES CXX_MODULE_STD ON ) + else() + target_compile_features( VulkanHppModule PUBLIC cxx_std_20 ) + endif() target_sources( VulkanHppModule PUBLIC FILE_SET vulkan_module_file BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} TYPE CXX_MODULES FILES vulkan/vulkan.cppm ) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 6c97951..d3de0b0 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -130,11 +130,15 @@ void VulkanHppGenerator::generateExtensionInspectionFile() const #ifndef VULKAN_EXTENSION_INSPECTION_HPP # define VULKAN_EXTENSION_INSPECTION_HPP -#include -#include -#include -#include -#include +#if defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) +import VULKAN_HPP_STD_MODULE; +#else +# include +# include +# include +# include +# include +#endif namespace VULKAN_HPP_NAMESPACE { @@ -578,7 +582,11 @@ ${macros} std::string str = replaceWithMap( macrosTemplate, - { { "licenseHeader", m_vulkanLicenseHeader }, { "macros", replaceWithMap( readSnippet( "macros.hpp" ), { { "vulkan_hpp", m_api + ".hpp" } } ) } } ); + { { "licenseHeader", m_vulkanLicenseHeader }, + { "macros", + replaceWithMap( readSnippet( "macros.hpp" ), + { { "vulkan_hpp", m_api + ".hpp" }, + { "vulkan_64_bit_ptr_defines", m_defines.at( "VK_USE_64_BIT_PTR_DEFINES" ).possibleDefinition } } ) } } ); writeToFile( str, macros_hpp ); } @@ -592,9 +600,11 @@ void VulkanHppGenerator::generateRAIIHppFile() const #ifndef VULKAN_RAII_HPP #define VULKAN_RAII_HPP -#include // std::unique_ptr -#include // std::forward #include +#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) +# include // std::unique_ptr +# include // std::forward +#endif #if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) namespace VULKAN_HPP_NAMESPACE @@ -668,8 +678,10 @@ void VulkanHppGenerator::generateSharedHppFile() const #define VULKAN_SHARED_HPP #include -#include // std::atomic_size_t +#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) +#include // std::atomic_size_t +#endif namespace VULKAN_HPP_NAMESPACE { @@ -769,10 +781,14 @@ void VulkanHppGenerator::generateToStringHppFile() const # pragma warning( disable : 4996 ) #endif -#if __cpp_lib_format -# include // std::format +#if defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) +import VULKAN_HPP_STD_MODULE; #else -# include // std::stringstream +# if __cpp_lib_format +# include // std::format +# else +# include // std::stringstream +# endif #endif namespace VULKAN_HPP_NAMESPACE @@ -811,6 +827,12 @@ void VulkanHppGenerator::generateCppModuleFile() const module; +#include + +#if defined( __cpp_lib_modules ) +#define VULKAN_HPP_ENABLE_STD_MODULE +#endif + #include #include #include @@ -16417,6 +16439,12 @@ namespace std::erase( rawComment, '/' ); auto const strippedComment = trim( stripPostfix( stripPrefix( rawComment, " DEPRECATED:" ), "#define " ) ); + // special case for VK_USE_64_BIT_PTR_DEFINES + if ( completeMacro.size() == 1 && completeMacro.front().find( "#ifndef VK_USE_64_BIT_PTR_DEFINES" ) != std::string::npos ) + { + return { {}, {}, {}, strippedComment }; + } + // macro with parameters and implementation if ( completeMacro.size() == 3 ) { diff --git a/snippets/includes.hpp b/snippets/includes.hpp index 3433ad0..f363988 100644 --- a/snippets/includes.hpp +++ b/snippets/includes.hpp @@ -1,21 +1,27 @@ -#include -#include // ArrayWrapperND -#include // strnlen -#include // std::string -#include // std::exchange -#include #include -#if 17 <= VULKAN_HPP_CPP_VERSION +#if defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) +#include +import VULKAN_HPP_STD_MODULE; +#else +# include +# include // ArrayWrapperND +# include // strnlen +# include // std::string +# include // std::exchange +#endif +#include + +#if 17 <= VULKAN_HPP_CPP_VERSION && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) +#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::tie # include // std::vector #endif -#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) +#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::is_error_code_enum #endif @@ -39,10 +45,10 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h # endif #endif -#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) +#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if defined( VULKAN_HPP_SUPPORT_SPAN ) +#if defined( VULKAN_HPP_SUPPORT_SPAN ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif diff --git a/snippets/macros.hpp b/snippets/macros.hpp index c4a0268..a0f943e 100644 --- a/snippets/macros.hpp +++ b/snippets/macros.hpp @@ -77,6 +77,12 @@ # define VULKAN_HPP_SUPPORT_SPAN #endif +#if defined( __cpp_lib_modules ) && !defined( VULKAN_HPP_STD_MODULE ) && defined( VULKAN_HPP_ENABLE_STD_MODULE ) +# define VULKAN_HPP_STD_MODULE std.compat +#endif + +${vulkan_64_bit_ptr_defines} + // 32-bit vulkan is not typesafe for non-dispatchable handles, so don't allow copy constructors on this platform by default. // To enable this feature on 32-bit platforms please #define VULKAN_HPP_TYPESAFE_CONVERSION 1 // To disable this feature on 64-bit platforms please #define VULKAN_HPP_TYPESAFE_CONVERSION 0 @@ -86,7 +92,6 @@ # endif #endif - #if defined( __GNUC__ ) # define GCC_VERSION ( __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ ) #endif @@ -276,7 +281,9 @@ namespace VULKAN_HPP_NAMESPACE #endif #if !defined( VULKAN_HPP_EXPECTED ) && ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_expected ) -# include +# if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) +# include +# endif # define VULKAN_HPP_EXPECTED std::expected # define VULKAN_HPP_UNEXPECTED std::unexpected #endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d5252e5..cd02654 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,6 +15,9 @@ add_subdirectory( ArrayProxy ) add_subdirectory( ArrayProxyNoTemporaries ) add_subdirectory( ArrayWrapper ) +if( VULKAN_HPP_ENABLE_STD_MODULE ) + add_subdirectory( CppStdModule ) +endif() if( VULKAN_HPP_ENABLE_CPP20_MODULES ) add_subdirectory( Cpp20Modules ) endif() diff --git a/tests/Cpp20Modules/CMakeLists.txt b/tests/Cpp20Modules/CMakeLists.txt index 7c1e782..d5f29fa 100644 --- a/tests/Cpp20Modules/CMakeLists.txt +++ b/tests/Cpp20Modules/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required( VERSION 3.25 ) +cmake_minimum_required( VERSION 3.28 ) vulkan_hpp__setup_test( NAME Cpp20Modules CXX_STANDARD 20 LIBRARIES VulkanHppModule NO_UTILS ) @@ -9,6 +9,5 @@ if( NOT VULKAN_HPP_SAMPLES_BUILD_ONLY_DYNAMIC ) target_compile_definitions( Cpp20Modules PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=0 ) endif() target_link_libraries( Cpp20Modules PRIVATE Vulkan::Vulkan ) - set_target_properties( Cpp20Modules PROPERTIES CXX_EXTENSIONS OFF - ) + set_target_properties( Cpp20Modules PROPERTIES CXX_EXTENSIONS OFF ) endif() \ No newline at end of file diff --git a/tests/CppStdModule/CMakeLists.txt b/tests/CppStdModule/CMakeLists.txt new file mode 100644 index 0000000..95b9fb6 --- /dev/null +++ b/tests/CppStdModule/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required( VERSION 3.30 ) + +target_compile_features( VulkanHppModule PUBLIC cxx_std_23 ) +target_compile_definitions( VulkanHppModule PUBLIC VULKAN_HPP_ENABLE_STD_MODULE ) + +vulkan_hpp__setup_test( NAME CppStdModule CXX_STANDARD 23 LIBRARIES VulkanHppModule NO_UTILS ) + +target_compile_features( CppStdModule PUBLIC cxx_std_23 ) + +if( NOT VULKAN_HPP_SAMPLES_BUILD_ONLY_DYNAMIC ) + if ( VULKAN_HPP_CPP20_MODULE_DYNAMIC_DISPATCHER ) + target_compile_definitions( CppStdModule PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 ) + else() + target_compile_definitions( CppStdModule PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=0 ) + endif() + target_link_libraries( CppStdModule PRIVATE Vulkan::Vulkan ) + set_target_properties( CppStdModule PROPERTIES CXX_EXTENSIONS OFF ) +endif() \ No newline at end of file diff --git a/tests/CppStdModule/CppStdModule.cpp b/tests/CppStdModule/CppStdModule.cpp new file mode 100644 index 0000000..f0f92c5 --- /dev/null +++ b/tests/CppStdModule/CppStdModule.cpp @@ -0,0 +1,59 @@ +import std; +import vulkan_hpp; + +#include + +static std::string AppName = "CppStdModule"; +static std::string EngineName = "Vulkan.cppm"; + +#if VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 +VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE +#endif + +int main(int /*argc*/, char** /*argv*/) +{ + /* VULKAN_HPP_KEY_START */ + try + { +#if ( VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 ) + // initialize minimal set of function pointers + VULKAN_HPP_DEFAULT_DISPATCHER.init(); +#endif + + // initialize the vk::ApplicationInfo structure + vk::ApplicationInfo applicationInfo(AppName.c_str(), 1, EngineName.c_str(), 1, vk::makeApiVersion(1, 0, 0, 0)); + + // initialize the vk::InstanceCreateInfo + vk::InstanceCreateInfo instanceCreateInfo({}, &applicationInfo); + + // create an Instance + vk::Instance instance = vk::createInstance(instanceCreateInfo); + +#if ( VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 ) + // initialize function pointers for instance + VULKAN_HPP_DEFAULT_DISPATCHER.init(instance); +#endif + + // destroy it again + instance.destroy(); + } + catch (vk::SystemError& err) + { + std::cout << "vk::SystemError: " << err.what() << std::endl; + exit(-1); + } + catch (std::exception& err) + { + std::cout << "std::exception: " << err.what() << std::endl; + exit(-1); + } + catch (...) + { + std::cout << "unknown error\n"; + exit(-1); + } + + /* VULKAN_HPP_KEY_END */ + + return 0; +} diff --git a/vulkan/vulkan.cppm b/vulkan/vulkan.cppm index 60b70f0..c95e0ed 100644 --- a/vulkan/vulkan.cppm +++ b/vulkan/vulkan.cppm @@ -10,6 +10,12 @@ module; +#include + +#if defined( __cpp_lib_modules ) +# define VULKAN_HPP_ENABLE_STD_MODULE +#endif + #include #include #include @@ -2580,6 +2586,7 @@ export namespace VULKAN_HPP_NAMESPACE //=== CONSTEXPR VALUEs === //======================== using VULKAN_HPP_NAMESPACE::HeaderVersion; + using VULKAN_HPP_NAMESPACE::Use64BitPtrDefines; //========================= //=== CONSTEXPR CALLEEs === diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index d5744c1..ef9d4a3 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -8,24 +8,30 @@ #ifndef VULKAN_HPP #define VULKAN_HPP -#include -#include // ArrayWrapperND -#include // strnlen -#include // std::string -#include // std::exchange -#include #include -#if 17 <= VULKAN_HPP_CPP_VERSION +#if defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) +# include +import VULKAN_HPP_STD_MODULE; +#else +# include +# include // ArrayWrapperND +# include // strnlen +# include // std::string +# include // std::exchange +#endif +#include + +#if 17 <= VULKAN_HPP_CPP_VERSION && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) +#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::tie # include // std::vector #endif -#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) +#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::is_error_code_enum #endif @@ -49,11 +55,11 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h # endif #endif -#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) +#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if defined( VULKAN_HPP_SUPPORT_SPAN ) +#if defined( VULKAN_HPP_SUPPORT_SPAN ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif @@ -6875,7 +6881,8 @@ namespace VULKAN_HPP_NAMESPACE //======================== //=== CONSTEXPR VALUEs === //======================== - VULKAN_HPP_CONSTEXPR_INLINE uint32_t HeaderVersion = VK_HEADER_VERSION; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t HeaderVersion = VK_HEADER_VERSION; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t Use64BitPtrDefines = VK_USE_64_BIT_PTR_DEFINES; //========================= //=== CONSTEXPR CALLEEs === diff --git a/vulkan/vulkan_extension_inspection.hpp b/vulkan/vulkan_extension_inspection.hpp index da405d5..970bd11 100644 --- a/vulkan/vulkan_extension_inspection.hpp +++ b/vulkan/vulkan_extension_inspection.hpp @@ -8,11 +8,15 @@ #ifndef VULKAN_EXTENSION_INSPECTION_HPP #define VULKAN_EXTENSION_INSPECTION_HPP -#include -#include -#include -#include -#include +#if defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) +import VULKAN_HPP_STD_MODULE; +#else +# include +# include +# include +# include +# include +#endif namespace VULKAN_HPP_NAMESPACE { diff --git a/vulkan/vulkan_hpp_macros.hpp b/vulkan/vulkan_hpp_macros.hpp index dd017c6..0ad04dd 100644 --- a/vulkan/vulkan_hpp_macros.hpp +++ b/vulkan/vulkan_hpp_macros.hpp @@ -87,6 +87,19 @@ # define VULKAN_HPP_SUPPORT_SPAN #endif +#if defined( __cpp_lib_modules ) && !defined( VULKAN_HPP_STD_MODULE ) && defined( VULKAN_HPP_ENABLE_STD_MODULE ) +# define VULKAN_HPP_STD_MODULE std.compat +#endif + +#ifndef VK_USE_64_BIT_PTR_DEFINES +# if defined( __LP64__ ) || defined( _WIN64 ) || ( defined( __x86_64__ ) && !defined( __ILP32__ ) ) || defined( _M_X64 ) || defined( __ia64 ) || \ + defined( _M_IA64 ) || defined( __aarch64__ ) || defined( __powerpc64__ ) || ( defined( __riscv ) && __riscv_xlen == 64 ) +# define VK_USE_64_BIT_PTR_DEFINES 1 +# else +# define VK_USE_64_BIT_PTR_DEFINES 0 +# endif +#endif + // 32-bit vulkan is not typesafe for non-dispatchable handles, so don't allow copy constructors on this platform by default. // To enable this feature on 32-bit platforms please #define VULKAN_HPP_TYPESAFE_CONVERSION 1 // To disable this feature on 64-bit platforms please #define VULKAN_HPP_TYPESAFE_CONVERSION 0 @@ -285,7 +298,9 @@ namespace VULKAN_HPP_NAMESPACE #endif #if !defined( VULKAN_HPP_EXPECTED ) && ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_expected ) -# include +# if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) +# include +# endif # define VULKAN_HPP_EXPECTED std::expected # define VULKAN_HPP_UNEXPECTED std::unexpected #endif diff --git a/vulkan/vulkan_raii.hpp b/vulkan/vulkan_raii.hpp index ac672bf..f389fa0 100644 --- a/vulkan/vulkan_raii.hpp +++ b/vulkan/vulkan_raii.hpp @@ -8,9 +8,11 @@ #ifndef VULKAN_RAII_HPP #define VULKAN_RAII_HPP -#include // std::unique_ptr -#include // std::forward #include +#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) +# include // std::unique_ptr +# include // std::forward +#endif #if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) namespace VULKAN_HPP_NAMESPACE diff --git a/vulkan/vulkan_shared.hpp b/vulkan/vulkan_shared.hpp index 1bff517..16918b8 100644 --- a/vulkan/vulkan_shared.hpp +++ b/vulkan/vulkan_shared.hpp @@ -8,9 +8,12 @@ #ifndef VULKAN_SHARED_HPP #define VULKAN_SHARED_HPP -#include // std::atomic_size_t #include +#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) +# include // std::atomic_size_t +#endif + namespace VULKAN_HPP_NAMESPACE { #if !defined( VULKAN_HPP_NO_SMART_HANDLE ) diff --git a/vulkan/vulkan_to_string.hpp b/vulkan/vulkan_to_string.hpp index b7c0177..b3590ed 100644 --- a/vulkan/vulkan_to_string.hpp +++ b/vulkan/vulkan_to_string.hpp @@ -19,10 +19,14 @@ # pragma warning( disable : 4996 ) #endif -#if __cpp_lib_format -# include // std::format +#if defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) +import VULKAN_HPP_STD_MODULE; #else -# include // std::stringstream +# if __cpp_lib_format +# include // std::format +# else +# include // std::stringstream +# endif #endif namespace VULKAN_HPP_NAMESPACE diff --git a/vulkan/vulkansc.cppm b/vulkan/vulkansc.cppm index a1708b0..36f0bfc 100644 --- a/vulkan/vulkansc.cppm +++ b/vulkan/vulkansc.cppm @@ -10,6 +10,12 @@ module; +#include + +#if defined( __cpp_lib_modules ) +# define VULKAN_HPP_ENABLE_STD_MODULE +#endif + #include #include #include @@ -841,6 +847,7 @@ export namespace VULKAN_HPP_NAMESPACE //=== CONSTEXPR VALUEs === //======================== using VULKAN_HPP_NAMESPACE::HeaderVersion; + using VULKAN_HPP_NAMESPACE::Use64BitPtrDefines; //========================= //=== CONSTEXPR CALLEEs === diff --git a/vulkan/vulkansc.hpp b/vulkan/vulkansc.hpp index 54746f0..c0716cc 100644 --- a/vulkan/vulkansc.hpp +++ b/vulkan/vulkansc.hpp @@ -8,24 +8,30 @@ #ifndef VULKAN_HPP #define VULKAN_HPP -#include -#include // ArrayWrapperND -#include // strnlen -#include // std::string -#include // std::exchange #include + +#if defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) +# include +import VULKAN_HPP_STD_MODULE; +#else +# include +# include // ArrayWrapperND +# include // strnlen +# include // std::string +# include // std::exchange +#endif #include -#if 17 <= VULKAN_HPP_CPP_VERSION +#if 17 <= VULKAN_HPP_CPP_VERSION && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) +#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::tie # include // std::vector #endif -#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) +#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include // std::is_error_code_enum #endif @@ -49,11 +55,11 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h # endif #endif -#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) +#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif -#if defined( VULKAN_HPP_SUPPORT_SPAN ) +#if defined( VULKAN_HPP_SUPPORT_SPAN ) && !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) # include #endif @@ -3952,7 +3958,8 @@ namespace VULKAN_HPP_NAMESPACE //======================== //=== CONSTEXPR VALUEs === //======================== - VULKAN_HPP_CONSTEXPR_INLINE uint32_t HeaderVersion = VK_HEADER_VERSION; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t HeaderVersion = VK_HEADER_VERSION; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t Use64BitPtrDefines = VK_USE_64_BIT_PTR_DEFINES; //========================= //=== CONSTEXPR CALLEEs === diff --git a/vulkan/vulkansc_extension_inspection.hpp b/vulkan/vulkansc_extension_inspection.hpp index a4fd845..9b35b72 100644 --- a/vulkan/vulkansc_extension_inspection.hpp +++ b/vulkan/vulkansc_extension_inspection.hpp @@ -8,11 +8,15 @@ #ifndef VULKAN_EXTENSION_INSPECTION_HPP #define VULKAN_EXTENSION_INSPECTION_HPP -#include -#include -#include -#include -#include +#if defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) +import VULKAN_HPP_STD_MODULE; +#else +# include +# include +# include +# include +# include +#endif namespace VULKAN_HPP_NAMESPACE { diff --git a/vulkan/vulkansc_hpp_macros.hpp b/vulkan/vulkansc_hpp_macros.hpp index b808f5e..d9a8b0a 100644 --- a/vulkan/vulkansc_hpp_macros.hpp +++ b/vulkan/vulkansc_hpp_macros.hpp @@ -87,6 +87,19 @@ # define VULKAN_HPP_SUPPORT_SPAN #endif +#if defined( __cpp_lib_modules ) && !defined( VULKAN_HPP_STD_MODULE ) && defined( VULKAN_HPP_ENABLE_STD_MODULE ) +# define VULKAN_HPP_STD_MODULE std.compat +#endif + +#ifndef VK_USE_64_BIT_PTR_DEFINES +# if defined( __LP64__ ) || defined( _WIN64 ) || ( defined( __x86_64__ ) && !defined( __ILP32__ ) ) || defined( _M_X64 ) || defined( __ia64 ) || \ + defined( _M_IA64 ) || defined( __aarch64__ ) || defined( __powerpc64__ ) || ( defined( __riscv ) && __riscv_xlen == 64 ) +# define VK_USE_64_BIT_PTR_DEFINES 1 +# else +# define VK_USE_64_BIT_PTR_DEFINES 0 +# endif +#endif + // 32-bit vulkan is not typesafe for non-dispatchable handles, so don't allow copy constructors on this platform by default. // To enable this feature on 32-bit platforms please #define VULKAN_HPP_TYPESAFE_CONVERSION 1 // To disable this feature on 64-bit platforms please #define VULKAN_HPP_TYPESAFE_CONVERSION 0 @@ -285,7 +298,9 @@ namespace VULKAN_HPP_NAMESPACE #endif #if !defined( VULKAN_HPP_EXPECTED ) && ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_expected ) -# include +# if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) +# include +# endif # define VULKAN_HPP_EXPECTED std::expected # define VULKAN_HPP_UNEXPECTED std::unexpected #endif diff --git a/vulkan/vulkansc_raii.hpp b/vulkan/vulkansc_raii.hpp index 996501f..5647bb0 100644 --- a/vulkan/vulkansc_raii.hpp +++ b/vulkan/vulkansc_raii.hpp @@ -8,9 +8,11 @@ #ifndef VULKAN_RAII_HPP #define VULKAN_RAII_HPP -#include // std::unique_ptr -#include // std::forward #include +#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) +# include // std::unique_ptr +# include // std::forward +#endif #if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) namespace VULKAN_HPP_NAMESPACE diff --git a/vulkan/vulkansc_shared.hpp b/vulkan/vulkansc_shared.hpp index 2034790..896116b 100644 --- a/vulkan/vulkansc_shared.hpp +++ b/vulkan/vulkansc_shared.hpp @@ -8,9 +8,12 @@ #ifndef VULKAN_SHARED_HPP #define VULKAN_SHARED_HPP -#include // std::atomic_size_t #include +#if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) ) +# include // std::atomic_size_t +#endif + namespace VULKAN_HPP_NAMESPACE { #if !defined( VULKAN_HPP_NO_SMART_HANDLE ) diff --git a/vulkan/vulkansc_to_string.hpp b/vulkan/vulkansc_to_string.hpp index 7820a9b..5e1f63f 100644 --- a/vulkan/vulkansc_to_string.hpp +++ b/vulkan/vulkansc_to_string.hpp @@ -19,10 +19,14 @@ # pragma warning( disable : 4996 ) #endif -#if __cpp_lib_format -# include // std::format +#if defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) +import VULKAN_HPP_STD_MODULE; #else -# include // std::stringstream +# if __cpp_lib_format +# include // std::format +# else +# include // std::stringstream +# endif #endif namespace VULKAN_HPP_NAMESPACE