Merge pull request #1137 from asuessenbach/link

Fix wrong linking in copied StructureChains with unlinked elements
This commit is contained in:
Andreas Süßenbach 2021-11-16 08:40:42 +01:00 committed by GitHub
commit 9b94931267
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 6 deletions

View File

@ -16696,7 +16696,10 @@ int main( int argc, char ** argv )
{ {
static_assert( StructureChainValidation<sizeof...( ChainElements ) - 1, ChainElements...>::valid, static_assert( StructureChainValidation<sizeof...( ChainElements ) - 1, ChainElements...>::valid,
"The structure chain is not valid!" ); "The structure chain is not valid!" );
link<sizeof...( ChainElements ) - 1>(); link( &std::get<0>( *this ),
&std::get<0>( rhs ),
reinterpret_cast<VkBaseOutStructure *>( &std::get<0>( *this ) ),
reinterpret_cast<VkBaseInStructure const *>( &std::get<0>( rhs ) ) );
} }
StructureChain( StructureChain && rhs ) VULKAN_HPP_NOEXCEPT StructureChain( StructureChain && rhs ) VULKAN_HPP_NOEXCEPT
@ -16704,7 +16707,10 @@ int main( int argc, char ** argv )
{ {
static_assert( StructureChainValidation<sizeof...( ChainElements ) - 1, ChainElements...>::valid, static_assert( StructureChainValidation<sizeof...( ChainElements ) - 1, ChainElements...>::valid,
"The structure chain is not valid!" ); "The structure chain is not valid!" );
link<sizeof...( ChainElements ) - 1>(); link( &std::get<0>( *this ),
&std::get<0>( rhs ),
reinterpret_cast<VkBaseOutStructure *>( &std::get<0>( *this ) ),
reinterpret_cast<VkBaseInStructure const *>( &std::get<0>( rhs ) ) );
} }
StructureChain( ChainElements const &... elems ) VULKAN_HPP_NOEXCEPT : std::tuple<ChainElements...>( elems... ) StructureChain( ChainElements const &... elems ) VULKAN_HPP_NOEXCEPT : std::tuple<ChainElements...>( elems... )
@ -16717,7 +16723,10 @@ int main( int argc, char ** argv )
StructureChain & operator=( StructureChain const & rhs ) VULKAN_HPP_NOEXCEPT StructureChain & operator=( StructureChain const & rhs ) VULKAN_HPP_NOEXCEPT
{ {
std::tuple<ChainElements...>::operator=( rhs ); std::tuple<ChainElements...>::operator=( rhs );
link<sizeof...( ChainElements ) - 1>(); link( &std::get<0>( *this ),
&std::get<0>( rhs ),
reinterpret_cast<VkBaseOutStructure *>( &std::get<0>( *this ) ),
reinterpret_cast<VkBaseInStructure const *>( &std::get<0>( rhs ) ) );
return *this; return *this;
} }
@ -16856,6 +16865,19 @@ int main( int argc, char ** argv )
typename std::enable_if<Index == 0, void>::type link() VULKAN_HPP_NOEXCEPT typename std::enable_if<Index == 0, void>::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<char const *>( src->pNext ) - reinterpret_cast<char const *>( srcBase );
dst->pNext = reinterpret_cast<VkBaseOutStructure *>( reinterpret_cast<char *>( dstBase ) + offset );
dst = dst->pNext;
src = src->pNext;
}
dst->pNext = nullptr;
}
void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
{ {
VkBaseOutStructure * elementPtr = VkBaseOutStructure * elementPtr =

View File

@ -1076,7 +1076,10 @@ namespace VULKAN_HPP_NAMESPACE
{ {
static_assert( StructureChainValidation<sizeof...( ChainElements ) - 1, ChainElements...>::valid, static_assert( StructureChainValidation<sizeof...( ChainElements ) - 1, ChainElements...>::valid,
"The structure chain is not valid!" ); "The structure chain is not valid!" );
link<sizeof...( ChainElements ) - 1>(); link( &std::get<0>( *this ),
&std::get<0>( rhs ),
reinterpret_cast<VkBaseOutStructure *>( &std::get<0>( *this ) ),
reinterpret_cast<VkBaseInStructure const *>( &std::get<0>( rhs ) ) );
} }
StructureChain( StructureChain && rhs ) VULKAN_HPP_NOEXCEPT StructureChain( StructureChain && rhs ) VULKAN_HPP_NOEXCEPT
@ -1084,7 +1087,10 @@ namespace VULKAN_HPP_NAMESPACE
{ {
static_assert( StructureChainValidation<sizeof...( ChainElements ) - 1, ChainElements...>::valid, static_assert( StructureChainValidation<sizeof...( ChainElements ) - 1, ChainElements...>::valid,
"The structure chain is not valid!" ); "The structure chain is not valid!" );
link<sizeof...( ChainElements ) - 1>(); link( &std::get<0>( *this ),
&std::get<0>( rhs ),
reinterpret_cast<VkBaseOutStructure *>( &std::get<0>( *this ) ),
reinterpret_cast<VkBaseInStructure const *>( &std::get<0>( rhs ) ) );
} }
StructureChain( ChainElements const &... elems ) VULKAN_HPP_NOEXCEPT : std::tuple<ChainElements...>( elems... ) StructureChain( ChainElements const &... elems ) VULKAN_HPP_NOEXCEPT : std::tuple<ChainElements...>( elems... )
@ -1097,7 +1103,10 @@ namespace VULKAN_HPP_NAMESPACE
StructureChain & operator=( StructureChain const & rhs ) VULKAN_HPP_NOEXCEPT StructureChain & operator=( StructureChain const & rhs ) VULKAN_HPP_NOEXCEPT
{ {
std::tuple<ChainElements...>::operator=( rhs ); std::tuple<ChainElements...>::operator=( rhs );
link<sizeof...( ChainElements ) - 1>(); link( &std::get<0>( *this ),
&std::get<0>( rhs ),
reinterpret_cast<VkBaseOutStructure *>( &std::get<0>( *this ) ),
reinterpret_cast<VkBaseInStructure const *>( &std::get<0>( rhs ) ) );
return *this; return *this;
} }
@ -1238,6 +1247,19 @@ namespace VULKAN_HPP_NAMESPACE
typename std::enable_if<Index == 0, void>::type link() VULKAN_HPP_NOEXCEPT typename std::enable_if<Index == 0, void>::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<char const *>( src->pNext ) - reinterpret_cast<char const *>( srcBase );
dst->pNext = reinterpret_cast<VkBaseOutStructure *>( reinterpret_cast<char *>( dstBase ) + offset );
dst = dst->pNext;
src = src->pNext;
}
dst->pNext = nullptr;
}
void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
{ {
VkBaseOutStructure * elementPtr = VkBaseOutStructure * elementPtr =