Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,10 @@ if( VULKAN_HPP_BUILD_CXX_MODULE )
# create targets providing VulkanHpp and VulkanVideoHpp as C++ named modules
vulkan_hpp__setup_vulkan_module( NAME VulkanHppModule
FILE_SET_NAME vulkan_module_file
FILE_SET vulkan/vulkan.cppm
FILE_SET
vulkan/vulkan.cppm
vulkan/vulkan_video.cppm
ALIAS Vulkan::HppModule ) # TODO: respect VULKAN_HPP_BUILD_WITH_LOCAL_VULKAN_HPP
vulkan_hpp__setup_vulkan_module( NAME VulkanVideoHppModule
FILE_SET_NAME vulkan_video_module_file
FILE_SET vulkan/vulkan_video.cppm
ALIAS Vulkan::VideoHppModule )
endif()

function( vulkan_hpp__setup_platform )
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ Some functions might provide information that depends on the vulkan version. As

#### Overview <a id='named_module_overview'>

Vulkan-Hpp provides a [C++ named module](https://en.cppreference.com/w/cpp/language/modules), `vulkan_hpp` in [`vulkan.cppm`](vulkan/vulkan.cppm).
Vulkan-Hpp provides a [C++ named module](https://en.cppreference.com/w/cpp/language/modules), `vulkan` in [`vulkan.cppm`](vulkan/vulkan.cppm).
C++ modules are intended to supersede header files. Modules have potential to drastically improve compilation times for large projects, as declarations and definitions may be easily shared across translation units without repeatedly parsing headers.
Vulkan-Hpp has some extremely long headers (e.g. [`vulkan_structs.hpp`](vulkan/vulkan_structs.hpp)), and the C++ module is likely to shorten compile times for projects currently using it.

Expand Down Expand Up @@ -882,7 +882,7 @@ target_link_libraries( VulkanHppModule PUBLIC Vulkan::Headers )
Finally, supply the macro `VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE` exactly once in your source code, just as in the non-module case. In order to have that macro available, include [`vulkan_hpp_macros.hpp`](vulkan/vulkan_hpp_macros.hpp), a lightweight header providing all Vulkan-Hpp related macros and defines. And as explained above, you need to initialize that dispatcher in two or three steps:

```cpp
import vulkan_hpp;
import vulkan;

#include <vulkan/vulkan_hpp_macros.hpp>

Expand Down
10 changes: 5 additions & 5 deletions snippets/CppmTemplate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ module;

#if !defined( VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING )
# define VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING \
"The Vulkan-Hpp C++ named module is experimental. " \
"It is subject to change without prior notice.\n" \
"To silence this warning, define the VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING macro.\n\n" \
"For feedback, go to: https://github.com/KhronosGroup/Vulkan-Hpp/issues"
"\n\tThe Vulkan-Hpp C++ named module is experimental. It is subject to change without prior notice.\n" \
"\tTo silence this warning, define the VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING macro.\n" \
"\tFor feedback, go to: https://github.com/KhronosGroup/Vulkan-Hpp/issues"

VULKAN_HPP_COMPILE_WARNING( VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING )
#endif
Expand All @@ -23,7 +22,8 @@ module;
#include <vulkan/${api}_raii.hpp>
#include <vulkan/${api}_shared.hpp>

export module ${api}_hpp;
export module ${api};
export import :video;
export import std;

export namespace VULKAN_HPP_NAMESPACE
Expand Down
23 changes: 14 additions & 9 deletions snippets/VideoCppmTemplate.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
${copyrightMessage}

// Note: This module is still in an experimental state.
// Any feedback is welcome on https://github.com/KhronosGroup/Vulkan-Hpp/issues.

module;

#define VULKAN_HPP_CXX_MODULE 1

#include <vulkan/vulkan_hpp_macros.hpp>

#if !defined( VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING )
# define VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING \
"\n\tThe Vulkan-Hpp C++ named module is experimental. It is subject to change without prior notice.\n" \
"\tTo silence this warning, define the VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING macro.\n" \
"\tFor feedback, go to: https://github.com/KhronosGroup/Vulkan-Hpp/issues"

VULKAN_HPP_COMPILE_WARNING( VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING )
#endif

#include <vulkan/vulkan_video.hpp>

export module vulkan_video_hpp;
export module vulkan:video;

export namespace VULKAN_HPP_NAMESPACE
{
namespace VULKAN_HPP_VIDEO_NAMESPACE
export namespace VULKAN_HPP_NAMESPACE::VULKAN_HPP_VIDEO_NAMESPACE
{
${usings}
} // namespace VULKAN_HPP_VIDEO_NAMESPACE
} // namespace VULKAN_HPP_NAMESPACE
} // namespace VULKAN_HPP_NAMESPACE::VULKAN_HPP_VIDEO_NAMESPACE
2 changes: 1 addition & 1 deletion tests/ArrayProxy/ArrayProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# ifdef VULKAN_HPP_SUPPORT_SPAN
# include <span>
# endif
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
#endif
Expand Down
8 changes: 4 additions & 4 deletions tests/ArrayProxyNoTemporaries/ArrayProxyNoTemporaries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <iostream>
#ifdef VULKAN_HPP_USE_CXX_MODULE
# include <vulkan/vulkan_hpp_macros.hpp>
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
#endif
Expand Down Expand Up @@ -208,9 +208,9 @@ int main( int /*argc*/, char ** /*argv*/ )
fctc( sv1 );

// getVector
// fct( getConstVector() ); // not supported: cannot convert argument 1 from 'const std::vector<int,std::allocator<int>>' to 'vk::ArrayProxyNoTemporaries<int>'
// fctc( getConstVector() ); // not supported: cannot convert argument 1 from 'const std::vector<int,std::allocator<int>>' to 'vk::ArrayProxyNoTemporaries<const int32_t>'
// fct( getVector() ); // not supported: cannot convert argument 1 from 'std::vector<int,std::allocator<int>>' to 'vk::ArrayProxyNoTemporaries<int>'
// fct( getConstVector() ); // not supported: cannot convert argument 1 from 'const std::vector<int,std::allocator<int>>' to 'vk::ArrayProxyNoTemporaries<int>'
// fctc( getConstVector() ); // not supported: cannot convert argument 1 from 'const std::vector<int,std::allocator<int>>' to 'vk::ArrayProxyNoTemporaries<const int32_t>'
// fct( getVector() ); // not supported: cannot convert argument 1 from 'std::vector<int,std::allocator<int>>' to 'vk::ArrayProxyNoTemporaries<int>'
// fctc( getVector() ); // not supported: cannot convert argument 1 from 'std::vector<int,std::allocator<int>>' to 'vk::ArrayProxyNoTemporaries<const int32_t>'

vk::ArrayProxyNoTemporaries<int> apnt18 = sv0;
Expand Down
2 changes: 1 addition & 1 deletion tests/ArrayWrapper/ArrayWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#endif

#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/Cpp20Modules/Cpp20Modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <string> // std::string
#include <iostream> // std::cout

import vulkan_hpp;
import vulkan;

static std::string AppName = "Cpp20Modules";
static std::string EngineName = "Vulkan.cppm";
Expand Down
2 changes: 1 addition & 1 deletion tests/CppStdModule/CppStdModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Compile test on using c++20 modules

import std;
import vulkan_hpp;
import vulkan;

#if defined( _MSC_VER )
# pragma warning( disable : 4189 ) // local variable is initialized but not referenced
Expand Down
2 changes: 1 addition & 1 deletion tests/CppType/CppType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifdef VULKAN_HPP_USE_CXX_MODULE
# include <vulkan/vulkan.h>
# include <vulkan/vulkan_hpp_macros.hpp>
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
# include <vulkan/vulkan_raii.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/DesignatedInitializers/DesignatedInitializers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <vector>
#ifdef VULKAN_HPP_USE_CXX_MODULE
# include <vulkan/vulkan_hpp_macros.hpp>
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/DeviceFunctions/DeviceFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <iostream>
#include <algorithm>
#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/DispatchLoaderDynamic/DispatchLoaderDynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <cassert>
#include <iostream>
#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/EnableBetaExtensions/EnableBetaExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#endif

#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/ExtensionInspection/ExtensionInspection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#endif

#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan_extension_inspection.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/Flags/Flags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#ifdef VULKAN_HPP_USE_CXX_MODULE
# include <compare> // necessary due to MSVC "design": https://developercommunity.visualstudio.com/t/Template-exports-requiring-importing-of-/1425979#T-N1435887
# include <vulkan/vulkan_core.h>
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/FormatTraits/FormatTraits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <map>
#include <set>
#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan_format_traits.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/Handles/Handles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <iostream>
#ifdef VULKAN_HPP_USE_CXX_MODULE
#include <vulkan/vulkan.h>
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan_raii.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/HandlesMoveExchange/HandlesMoveExchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <cassert>
#include <iostream>
#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/Hash/Hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <unordered_set>
#ifdef VULKAN_HPP_USE_CXX_MODULE
#include <vulkan/vulkan_hpp_macros.hpp>
import vulkan_hpp;
import vulkan;
#else
# include "vulkan/vulkan_hash.hpp"
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/NoDefaultDispatcher/NoDefaultDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define VULKAN_HPP_NO_DEFAULT_DISPATCHER

#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include <vulkan/vulkan.hpp>
# include <vulkan/vulkan_raii.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/NoExceptions/NoExceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <iostream>
#include <algorithm>
#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include "vulkan/vulkan.hpp"
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/NoExceptionsRAII/NoExceptionsRAII.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <cstdint>
#include <algorithm>
#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include "vulkan/vulkan_raii.hpp"
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/StridedArrayProxy/StridedArrayProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <iostream>
#ifdef VULKAN_HPP_USE_CXX_MODULE
# include <vulkan/vulkan_hpp_macros.hpp>
import vulkan_hpp;
import vulkan;
#else
# include "vulkan/vulkan.hpp"
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/StructureChain/StructureChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <cassert>
#include <iostream>
#ifdef VULKAN_HPP_USE_CXX_MODULE
import vulkan_hpp;
import vulkan;
#else
# include "vulkan/vulkan.hpp"
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#ifdef VULKAN_HPP_USE_CXX_MODULE
#include <vulkan/vulkan.h>
import vulkan_hpp;
import vulkan;
#else
# include "vulkan/vulkan.hpp"
#endif
Expand Down
13 changes: 6 additions & 7 deletions vulkan/vulkan.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ module;

#if !defined( VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING )
# define VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING \
"The Vulkan-Hpp C++ named module is experimental. " \
"It is subject to change without prior notice.\n" \
"To silence this warning, define the VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING macro.\n\n" \
"For feedback, go to: https://github.com/KhronosGroup/Vulkan-Hpp/issues"
"\n\tThe Vulkan-Hpp C++ named module is experimental. It is subject to change without prior notice.\n" \
"\tTo silence this warning, define the VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING macro.\n" \
"\tFor feedback, go to: https://github.com/KhronosGroup/Vulkan-Hpp/issues"

VULKAN_HPP_COMPILE_WARNING( VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING )
#endif
Expand All @@ -28,7 +27,8 @@ VULKAN_HPP_COMPILE_WARNING( VULKAN_HPP_CXX_MODULE_EXPERIMENTAL_WARNING )
#include <vulkan/vulkan_raii.hpp>
#include <vulkan/vulkan_shared.hpp>

export module vulkan_hpp;
export module vulkan;
export import :video;
export import std;

export namespace VULKAN_HPP_NAMESPACE
Expand Down Expand Up @@ -9418,8 +9418,7 @@ export namespace std
#endif
} // namespace std

export
{
export {
// This VkFlags type is used as part of a bitfield in some structures.
// As it can't be mimicked by vk-data types, we need to export just that.
using ::VkGeometryInstanceFlagsKHR;
Expand Down
Loading