Make C++20 modules work with the defaultDispatchLoaderDynamic. (#1651)

* Make C++20 modules work with the defaultDispatchLoaderDynamic.

* Add vulkan_hpp_macros.hpp to list of installed files.

* Adjust the text on module in the readme.

* Rename module from vulkan to vulkan_hpp

* Adjust some comments.

* Add a little disclaimer to vulkan.cppm.
This commit is contained in:
Andreas Süßenbach
2023-09-07 15:20:10 +02:00
committed by GitHub
parent a2e240c7e7
commit d4704cce01
25 changed files with 1084 additions and 834 deletions

View File

@@ -1,10 +1,14 @@
cmake_minimum_required( VERSION 3.25 )
vulkan_hpp__setup_test( NAME Cpp20Modules CXX_STANDARD 20 LIBRARIES VulkanHppModule )
vulkan_hpp__setup_test( NAME Cpp20Modules CXX_STANDARD 20 LIBRARIES VulkanHppModule NO_UTILS )
if( NOT VULKAN_HPP_SAMPLES_BUILD_ONLY_DYNAMIC )
if ( VULKAN_HPP_CPP20_MODULE_DYNAMIC_DISPATCHER )
target_compile_definitions( Cpp20Modules PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 )
else()
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()

View File

@@ -1,15 +1,25 @@
import vulkan;
import vulkan_hpp;
#include <iostream>
#include <vulkan/vulkan_hpp_macros.hpp>
static std::string AppName = "01_InitInstance";
static std::string EngineName = "Vulkan.hpp";
static std::string AppName = "Cpp20Modules";
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 ) );
@@ -19,6 +29,11 @@ int main( int /*argc*/, char ** /*argv*/ )
// 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();
}