From 5009b39f57e9d4a148e8cf6bbd922b9ea9ed01b9 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Mon, 15 Nov 2021 17:00:15 +0100 Subject: [PATCH] Fix wrong linking in copied StructureChains with unlinked elements --- VulkanHppGenerator.cpp | 28 +++++++++++++++++++++++++--- vulkan/vulkan.hpp | 28 +++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 6adddb9..870835b 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -16456,7 +16456,10 @@ int main( int argc, char ** argv ) { static_assert( StructureChainValidation::valid, "The structure chain is not valid!" ); - link(); + link( &std::get<0>( *this ), + &std::get<0>( rhs ), + reinterpret_cast( &std::get<0>( *this ) ), + reinterpret_cast( &std::get<0>( rhs ) ) ); } StructureChain( StructureChain && rhs ) VULKAN_HPP_NOEXCEPT @@ -16464,7 +16467,10 @@ int main( int argc, char ** argv ) { static_assert( StructureChainValidation::valid, "The structure chain is not valid!" ); - link(); + link( &std::get<0>( *this ), + &std::get<0>( rhs ), + reinterpret_cast( &std::get<0>( *this ) ), + reinterpret_cast( &std::get<0>( rhs ) ) ); } StructureChain( ChainElements const &... elems ) VULKAN_HPP_NOEXCEPT : std::tuple( elems... ) @@ -16477,7 +16483,10 @@ int main( int argc, char ** argv ) StructureChain & operator=( StructureChain const & rhs ) VULKAN_HPP_NOEXCEPT { std::tuple::operator=( rhs ); - link(); + link( &std::get<0>( *this ), + &std::get<0>( rhs ), + reinterpret_cast( &std::get<0>( *this ) ), + reinterpret_cast( &std::get<0>( rhs ) ) ); return *this; } @@ -16616,6 +16625,19 @@ int main( int argc, char ** argv ) typename std::enable_if::type link() VULKAN_HPP_NOEXCEPT {} + void link( void * dstBase, void const * srcBase, VkBaseOutStructure * dst, VkBaseInStructure const * src ) + { + while ( src->pNext ) + { + std::ptrdiff_t offset = + reinterpret_cast( src->pNext ) - reinterpret_cast( srcBase ); + dst->pNext = reinterpret_cast( reinterpret_cast( dstBase ) + offset ); + dst = dst->pNext; + src = src->pNext; + } + dst->pNext = nullptr; + } + void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT { VkBaseOutStructure * elementPtr = diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 406253a..ecddb34 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -1076,7 +1076,10 @@ namespace VULKAN_HPP_NAMESPACE { static_assert( StructureChainValidation::valid, "The structure chain is not valid!" ); - link(); + link( &std::get<0>( *this ), + &std::get<0>( rhs ), + reinterpret_cast( &std::get<0>( *this ) ), + reinterpret_cast( &std::get<0>( rhs ) ) ); } StructureChain( StructureChain && rhs ) VULKAN_HPP_NOEXCEPT @@ -1084,7 +1087,10 @@ namespace VULKAN_HPP_NAMESPACE { static_assert( StructureChainValidation::valid, "The structure chain is not valid!" ); - link(); + link( &std::get<0>( *this ), + &std::get<0>( rhs ), + reinterpret_cast( &std::get<0>( *this ) ), + reinterpret_cast( &std::get<0>( rhs ) ) ); } StructureChain( ChainElements const &... elems ) VULKAN_HPP_NOEXCEPT : std::tuple( elems... ) @@ -1097,7 +1103,10 @@ namespace VULKAN_HPP_NAMESPACE StructureChain & operator=( StructureChain const & rhs ) VULKAN_HPP_NOEXCEPT { std::tuple::operator=( rhs ); - link(); + link( &std::get<0>( *this ), + &std::get<0>( rhs ), + reinterpret_cast( &std::get<0>( *this ) ), + reinterpret_cast( &std::get<0>( rhs ) ) ); return *this; } @@ -1238,6 +1247,19 @@ namespace VULKAN_HPP_NAMESPACE typename std::enable_if::type link() VULKAN_HPP_NOEXCEPT {} + void link( void * dstBase, void const * srcBase, VkBaseOutStructure * dst, VkBaseInStructure const * src ) + { + while ( src->pNext ) + { + std::ptrdiff_t offset = + reinterpret_cast( src->pNext ) - reinterpret_cast( srcBase ); + dst->pNext = reinterpret_cast( reinterpret_cast( dstBase ) + offset ); + dst = dst->pNext; + src = src->pNext; + } + dst->pNext = nullptr; + } + void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT { VkBaseOutStructure * elementPtr =