mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Fix function StructureChain::unlink().
This commit is contained in:
parent
a82ea0f9b0
commit
8a21c2e0eb
@ -10688,14 +10688,13 @@ int main( int argc, char ** argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ClassType, size_t Which = 0>
|
template <typename ClassType, size_t Which = 0>
|
||||||
void relink() VULKAN_HPP_NOEXCEPT
|
typename std::enable_if<
|
||||||
|
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
|
||||||
|
( Which != 0 ),
|
||||||
|
void>::type relink() VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
||||||
"Can't relink Structure that's not part of this StructureChain!" );
|
"Can't relink Structure that's not part of this StructureChain!" );
|
||||||
static_assert(
|
|
||||||
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value || (Which != 0),
|
|
||||||
"It's not allowed to have the first element unlinked!" );
|
|
||||||
|
|
||||||
auto pNext = reinterpret_cast<VkBaseInStructure *>( &get<ClassType, Which>() );
|
auto pNext = reinterpret_cast<VkBaseInStructure *>( &get<ClassType, Which>() );
|
||||||
VULKAN_HPP_ASSERT( !isLinked( pNext ) );
|
VULKAN_HPP_ASSERT( !isLinked( pNext ) );
|
||||||
auto & headElement = std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) );
|
auto & headElement = std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) );
|
||||||
@ -10704,15 +10703,14 @@ int main( int argc, char ** argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ClassType, size_t Which = 0>
|
template <typename ClassType, size_t Which = 0>
|
||||||
void unlink() VULKAN_HPP_NOEXCEPT
|
typename std::enable_if<
|
||||||
|
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
|
||||||
|
( Which != 0 ),
|
||||||
|
void>::type unlink() VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
||||||
"Can't unlink Structure that's not part of this StructureChain!" );
|
"Can't unlink Structure that's not part of this StructureChain!" );
|
||||||
static_assert(
|
unlink( reinterpret_cast<VkBaseOutStructure const *>( &get<ClassType, Which>() ) );
|
||||||
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value || (Which != 0),
|
|
||||||
"It's not allowed to unlink the first element!" );
|
|
||||||
|
|
||||||
unlink<sizeof...( ChainElements ) - 1>( reinterpret_cast<VkBaseOutStructure const *>( &get<ClassType, Which>() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -10774,27 +10772,17 @@ 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
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <size_t Index>
|
void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
|
||||||
typename std::enable_if<Index != 0, void>::type unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
|
|
||||||
{
|
{
|
||||||
auto & element = std::get<Index>( static_cast<std::tuple<ChainElements...>&>( *this ) );
|
VkBaseOutStructure * elementPtr = reinterpret_cast<VkBaseOutStructure *>(
|
||||||
if ( element.pNext == pNext )
|
&std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) ) );
|
||||||
|
while ( elementPtr && ( elementPtr->pNext != pNext ) )
|
||||||
{
|
{
|
||||||
element.pNext = pNext->pNext;
|
elementPtr = elementPtr->pNext;
|
||||||
}
|
}
|
||||||
else
|
if ( elementPtr )
|
||||||
{
|
{
|
||||||
unlink<Index - 1>( pNext );
|
elementPtr->pNext = pNext->pNext;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t Index>
|
|
||||||
typename std::enable_if<Index == 0, void>::type unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
|
|
||||||
{
|
|
||||||
auto & element = std::get<0>( static_cast<std::tuple<ChainElements...>&>( *this ) );
|
|
||||||
if ( element.pNext == pNext )
|
|
||||||
{
|
|
||||||
element.pNext = pNext->pNext;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -167,6 +167,18 @@ int main( int /*argc*/, char ** /*argv*/ )
|
|||||||
dci2.unlink<vk::DevicePrivateDataCreateInfoEXT, 1>();
|
dci2.unlink<vk::DevicePrivateDataCreateInfoEXT, 1>();
|
||||||
dci2.relink<vk::DevicePrivateDataCreateInfoEXT, 1>();
|
dci2.relink<vk::DevicePrivateDataCreateInfoEXT, 1>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
vk::StructureChain<vk::InstanceCreateInfo,
|
||||||
|
vk::DebugReportCallbackCreateInfoEXT,
|
||||||
|
vk::ValidationFlagsEXT,
|
||||||
|
vk::ValidationFeaturesEXT,
|
||||||
|
vk::DebugUtilsMessengerCreateInfoEXT>
|
||||||
|
chain;
|
||||||
|
chain.unlink<vk::DebugReportCallbackCreateInfoEXT>();
|
||||||
|
chain.unlink<vk::ValidationFlagsEXT>();
|
||||||
|
chain.unlink<vk::ValidationFeaturesEXT>();
|
||||||
|
chain.unlink<vk::DebugUtilsMessengerCreateInfoEXT>();
|
||||||
|
chain.relink<vk::DebugUtilsMessengerCreateInfoEXT>();
|
||||||
}
|
}
|
||||||
catch ( vk::SystemError const & err )
|
catch ( vk::SystemError const & err )
|
||||||
{
|
{
|
||||||
|
@ -1066,15 +1066,14 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ClassType, size_t Which = 0>
|
template <typename ClassType, size_t Which = 0>
|
||||||
void relink() VULKAN_HPP_NOEXCEPT
|
typename std::enable_if<
|
||||||
|
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
|
||||||
|
( Which != 0 ),
|
||||||
|
void>::type
|
||||||
|
relink() VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
||||||
"Can't relink Structure that's not part of this StructureChain!" );
|
"Can't relink Structure that's not part of this StructureChain!" );
|
||||||
static_assert(
|
|
||||||
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
|
|
||||||
( Which != 0 ),
|
|
||||||
"It's not allowed to have the first element unlinked!" );
|
|
||||||
|
|
||||||
auto pNext = reinterpret_cast<VkBaseInStructure *>( &get<ClassType, Which>() );
|
auto pNext = reinterpret_cast<VkBaseInStructure *>( &get<ClassType, Which>() );
|
||||||
VULKAN_HPP_ASSERT( !isLinked( pNext ) );
|
VULKAN_HPP_ASSERT( !isLinked( pNext ) );
|
||||||
auto & headElement = std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) );
|
auto & headElement = std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) );
|
||||||
@ -1083,17 +1082,15 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ClassType, size_t Which = 0>
|
template <typename ClassType, size_t Which = 0>
|
||||||
void unlink() VULKAN_HPP_NOEXCEPT
|
typename std::enable_if<
|
||||||
|
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
|
||||||
|
( Which != 0 ),
|
||||||
|
void>::type
|
||||||
|
unlink() VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
||||||
"Can't unlink Structure that's not part of this StructureChain!" );
|
"Can't unlink Structure that's not part of this StructureChain!" );
|
||||||
static_assert(
|
unlink( reinterpret_cast<VkBaseOutStructure const *>( &get<ClassType, Which>() ) );
|
||||||
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
|
|
||||||
( Which != 0 ),
|
|
||||||
"It's not allowed to unlink the first element!" );
|
|
||||||
|
|
||||||
unlink<sizeof...( ChainElements ) - 1>(
|
|
||||||
reinterpret_cast<VkBaseOutStructure const *>( &get<ClassType, Which>() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1155,27 +1152,17 @@ 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
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <size_t Index>
|
void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
|
||||||
typename std::enable_if<Index != 0, void>::type unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
|
|
||||||
{
|
{
|
||||||
auto & element = std::get<Index>( static_cast<std::tuple<ChainElements...> &>( *this ) );
|
VkBaseOutStructure * elementPtr =
|
||||||
if ( element.pNext == pNext )
|
reinterpret_cast<VkBaseOutStructure *>( &std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) ) );
|
||||||
|
while ( elementPtr && ( elementPtr->pNext != pNext ) )
|
||||||
{
|
{
|
||||||
element.pNext = pNext->pNext;
|
elementPtr = elementPtr->pNext;
|
||||||
}
|
}
|
||||||
else
|
if ( elementPtr )
|
||||||
{
|
{
|
||||||
unlink<Index - 1>( pNext );
|
elementPtr->pNext = pNext->pNext;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t Index>
|
|
||||||
typename std::enable_if<Index == 0, void>::type unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
|
|
||||||
{
|
|
||||||
auto & element = std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) );
|
|
||||||
if ( element.pNext == pNext )
|
|
||||||
{
|
|
||||||
element.pNext = pNext->pNext;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user