diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b4d222..d898c1b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -92,7 +92,7 @@ jobs: echo Building with minimal Vulkan... FLAGS+=('-DVMA_HPP_VULKAN_REVISION=${{matrix.env.modules && 'min-modules' || 'min-headers'}}') - cmake "${FLAGS[@]}" -DCMAKE_CXX_FLAGS="$CXX_FLAGS" + cmake "${FLAGS[@]}" -DCMAKE_CXX_FLAGS="$CXX_FLAGS -DVULKAN_HPP_NO_SMART_HANDLE" cmake --build build --clean-first cmake "${FLAGS[@]}" -DCMAKE_CXX_FLAGS="$CXX_FLAGS -DVULKAN_HPP_NO_EXCEPTIONS -DVULKAN_HPP_USE_REFLECT" @@ -102,7 +102,7 @@ jobs: unset 'FLAGS[${#FLAGS[@]}-1]' FLAGS+=('-DVMA_HPP_VULKAN_REVISION=main') - cmake "${FLAGS[@]}" -DCMAKE_CXX_FLAGS="$CXX_FLAGS" + cmake "${FLAGS[@]}" -DCMAKE_CXX_FLAGS="$CXX_FLAGS -DVULKAN_HPP_NO_SMART_HANDLE" cmake --build build --clean-first cmake "${FLAGS[@]}" -DCMAKE_CXX_FLAGS="$CXX_FLAGS -DVULKAN_HPP_NO_EXCEPTIONS -DVULKAN_HPP_USE_REFLECT" diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a8e52c..8a88ea0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.8...3.30 FATAL_ERROR) project(VulkanMemoryAllocator-Hpp-Generator VERSION 3.3.0 LANGUAGES CXX) set(VMA_HPP_VULKAN_MIN_HEADERS "1.4.327" CACHE INTERNAL "Minimal Vulkan-Headers revision (headers)") -set(VMA_HPP_VULKAN_MIN_MODULES "1.4.336" CACHE INTERNAL "Minimal Vulkan-Headers revision (modules)") +set(VMA_HPP_VULKAN_MIN_MODULES "1.4.337" CACHE INTERNAL "Minimal Vulkan-Headers revision (modules)") if (CMAKE_VERSION VERSION_LESS "3.21") # https://cmake.org/cmake/help/latest/variable/PROJECT_IS_TOP_LEVEL.html diff --git a/README.md b/README.md index 44a6c64..7e47489 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ consistent and compatible with Vulkan C++ bindings ([Vulkan-Hpp](https://github. #### Requirements - C++11 or newer -- [Vulkan](https://github.com/KhronosGroup/Vulkan-Headers) **1.4.327** (headers) / **1.4.336** (module) or newer +- [Vulkan](https://github.com/KhronosGroup/Vulkan-Headers) **1.4.327** (headers) / **1.4.337** (module) or newer - [VulkanMemoryAllocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) - *[GitHub releases](https://github.com/YaaZ/VulkanMemoryAllocator-Hpp/releases) is the recommended way to get VMA-Hpp, they already include a compatible `vk_mem_alloc.h` header* diff --git a/VmaHppGenerator.cpp b/VmaHppGenerator.cpp index a7ed010..a80660b 100644 --- a/VmaHppGenerator.cpp +++ b/VmaHppGenerator.cpp @@ -2112,7 +2112,8 @@ void generateStaticAssertions(const ConditionalTree& tree, const Symbols& symbol } void generateModule(const ConditionalTree& tree, const Symbols& symbols) { - Segment exports, uniqueExports, raiiExports, specializations, raiiSpecializations; + Segment::Vector<6> segments; + auto& [exports, uniqueExports, raiiExports, specializations, uniqueSpecializations, raiiSpecializations] = *segments; // Generate export statements. for (const auto* list : { &symbols.enums, &symbols.structs, &symbols.handles, &symbols.functions }) @@ -2139,19 +2140,19 @@ void generateModule(const ConditionalTree& tree, const Symbols& symbols) { // error C2027: use of undefined type 'vk::UniqueHandleTraits' for (const Symbol& t : symbols.handles.unique) - specializations << n << navigate(t) << "template<> class UniqueHandleTraits;"; + uniqueSpecializations << n << navigate(t) << "template<> class UniqueHandleTraits;"; // error C2676: binary '==': 'const vma::raii::Allocator' does not define this operator or a conversion to a type acceptable to the predefined operator for (const Symbol& t : symbols.handles.raii) raiiSpecializations << n << navigate(t) << "template<> struct isVulkanRAIIHandleType;"; - (exports, raiiExports, specializations, raiiSpecializations) << navigate.reset; + segments << navigate.reset; // Don't forget Buffer and Image. uniqueExports << n << "using VMA_HPP_NAMESPACE::UniqueBuffer;" << n << "using VMA_HPP_NAMESPACE::UniqueImage;"; - specializations << n << "template<> class UniqueHandleTraits;" << - n << "template<> class UniqueHandleTraits;"; + uniqueSpecializations << n << "template<> class UniqueHandleTraits;" << + n << "template<> class UniqueHandleTraits;"; R"(// Generated from the Vulkan Memory Allocator (vk_mem_alloc.h). module; @@ -2200,13 +2201,16 @@ void generateModule(const ConditionalTree& tree, const Symbols& symbols) { namespace VULKAN_HPP_NAMESPACE { // This is needed for template specializations to be visible outside the module when importing vulkan (is this a MSVC bug?). $3 + #ifndef VULKAN_HPP_NO_SMART_HANDLE + $4 + #endif #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE namespace VULKAN_HPP_RAII_NAMESPACE { - $4 + $5 } #endif } - )"_seg.replace(exports, uniqueExports, raiiExports, specializations, raiiSpecializations).resolve(tree).generate("vk_mem_alloc.cppm"); + )"_seg.replace(exports, uniqueExports, raiiExports, specializations, uniqueSpecializations, raiiSpecializations).resolve(tree).generate("vk_mem_alloc.cppm"); } std::string readSource() { diff --git a/include/vk_mem_alloc.cppm b/include/vk_mem_alloc.cppm index 87e068a..0a58d93 100644 --- a/include/vk_mem_alloc.cppm +++ b/include/vk_mem_alloc.cppm @@ -117,6 +117,7 @@ namespace VULKAN_HPP_NAMESPACE { template<> struct isVulkanHandleType; template<> struct isVulkanHandleType; template<> struct isVulkanHandleType; +#ifndef VULKAN_HPP_NO_SMART_HANDLE template<> class UniqueHandleTraits; template<> class UniqueHandleTraits; template<> class UniqueHandleTraits; @@ -124,6 +125,7 @@ namespace VULKAN_HPP_NAMESPACE { template<> class UniqueHandleTraits; template<> class UniqueHandleTraits; template<> class UniqueHandleTraits; +#endif #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE namespace VULKAN_HPP_RAII_NAMESPACE { template<> struct isVulkanRAIIHandleType; diff --git a/samples/CompileCheck.cpp b/samples/CompileCheck.cpp index 4a51d40..7bd4d07 100644 --- a/samples/CompileCheck.cpp +++ b/samples/CompileCheck.cpp @@ -101,8 +101,10 @@ void checkHandles() { if (al == ar) {} if (al != ar) throw; +#ifndef VULKAN_HPP_NO_SMART_HANDLE vma::UniqueAllocator unique; vma::UniqueBuffer buffer; +#endif vma::raii::Allocator raii = nullptr; allocator = raii; diff --git a/samples/Init.cpp b/samples/Init.cpp index 24d30f6..68d07b4 100644 --- a/samples/Init.cpp +++ b/samples/Init.cpp @@ -4,6 +4,7 @@ int main(int, char**) { Vulkan vulkan; auto functions = vma::functionsFromDispatchers(*vulkan.device.getDispatcher(), *vulkan.instance.getDispatcher()); +#ifndef VULKAN_HPP_NO_SMART_HANDLE auto allocator = value(vma::createAllocatorUnique(vma::AllocatorCreateInfo { {}, vulkan.physicalDevice, vulkan.device }.setInstance(vulkan.instance).setPVulkanFunctions(&functions))); @@ -11,6 +12,7 @@ int main(int, char**) { auto buffer = value(allocator->createBufferUnique( vk::BufferCreateInfo { {}, 1024, vk::BufferUsageFlagBits::eTransferSrc }, vma::AllocationCreateInfo { vma::AllocationCreateFlagBits::eHostAccessSequentialWrite, vma::MemoryUsage::eAuto })); +#endif return 0; }