mirror of
https://github.com/KhronosGroup/Vulkan-Hpp
synced 2024-12-24 01:30:14 +00:00
Introduce new function StructureChain::isLinked<>()
This commit is contained in:
parent
b9ec269ab2
commit
2e2782448c
@ -10665,6 +10665,28 @@ int main( int argc, char ** argv )
|
||||
return std::tie( get<T0>(), get<T1>(), get<Ts>()... );
|
||||
}
|
||||
|
||||
template <typename ClassType, size_t Which = 0>
|
||||
typename std::enable_if<
|
||||
std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value &&
|
||||
( Which == 0 ),
|
||||
bool>::type
|
||||
isLinked() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename ClassType, size_t Which = 0>
|
||||
typename std::enable_if<
|
||||
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
|
||||
( Which != 0 ),
|
||||
bool>::type
|
||||
isLinked() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
||||
"Can't unlink Structure that's not part of this StructureChain!" );
|
||||
return isLinked( reinterpret_cast<VkBaseInStructure const *>( &get<ClassType, Which>() ) );
|
||||
}
|
||||
|
||||
template <typename ClassType, size_t Which = 0>
|
||||
void relink() VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
@ -10725,9 +10747,10 @@ int main( int argc, char ** argv )
|
||||
Types...> : std::integral_constant<int, Index>
|
||||
{};
|
||||
|
||||
bool isLinked( VkBaseInStructure const * pNext )
|
||||
bool isLinked( VkBaseInStructure const * pNext ) const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
VkBaseInStructure const * elementPtr = reinterpret_cast<VkBaseInStructure const*>(&std::get<0>( static_cast<std::tuple<ChainElements...>&>( *this ) ) );
|
||||
VkBaseInStructure const * elementPtr = reinterpret_cast<VkBaseInStructure const *>(
|
||||
&std::get<0>( static_cast<std::tuple<ChainElements...> const &>( *this ) ) );
|
||||
while ( elementPtr )
|
||||
{
|
||||
if ( elementPtr->pNext == pNext )
|
||||
|
@ -74,6 +74,10 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::PhysicalDevicePushDescriptorPropertiesKHR>
|
||||
sc7;
|
||||
|
||||
// some checks on unmodified chains
|
||||
assert( sc7.isLinked<vk::PhysicalDeviceProperties2>() );
|
||||
assert( sc7.isLinked<vk::PhysicalDeviceMaintenance3Properties>() );
|
||||
|
||||
// some invalid StructureChains
|
||||
// clang-format off
|
||||
//vk::StructureChain<vk::PhysicalDeviceIDProperties, vk::PhysicalDeviceMaintenance3Properties> x;
|
||||
@ -91,6 +95,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
// unlink a struct from a StructureChain
|
||||
sc7.unlink<vk::PhysicalDeviceMaintenance3Properties>();
|
||||
assert( !sc7.isLinked<vk::PhysicalDeviceMaintenance3Properties>() );
|
||||
|
||||
// some invalid unlink calls
|
||||
// clang-format off
|
||||
@ -102,6 +107,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
|
||||
// re-link a struct
|
||||
sc7.relink<vk::PhysicalDeviceMaintenance3Properties>();
|
||||
assert( sc7.isLinked<vk::PhysicalDeviceMaintenance3Properties>() );
|
||||
|
||||
// invalid re-linking
|
||||
// clang-format off
|
||||
|
@ -1043,6 +1043,28 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
return std::tie( get<T0>(), get<T1>(), get<Ts>()... );
|
||||
}
|
||||
|
||||
template <typename ClassType, size_t Which = 0>
|
||||
typename std::enable_if<
|
||||
std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value &&
|
||||
( Which == 0 ),
|
||||
bool>::type
|
||||
isLinked() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename ClassType, size_t Which = 0>
|
||||
typename std::enable_if<
|
||||
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
|
||||
( Which != 0 ),
|
||||
bool>::type
|
||||
isLinked() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
|
||||
"Can't unlink Structure that's not part of this StructureChain!" );
|
||||
return isLinked( reinterpret_cast<VkBaseInStructure const *>( &get<ClassType, Which>() ) );
|
||||
}
|
||||
|
||||
template <typename ClassType, size_t Which = 0>
|
||||
void relink() VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
@ -1106,10 +1128,10 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
Types...> : std::integral_constant<int, Index>
|
||||
{};
|
||||
|
||||
bool isLinked( VkBaseInStructure const * pNext )
|
||||
bool isLinked( VkBaseInStructure const * pNext ) const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
VkBaseInStructure const * elementPtr = reinterpret_cast<VkBaseInStructure const *>(
|
||||
&std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) ) );
|
||||
&std::get<0>( static_cast<std::tuple<ChainElements...> const &>( *this ) ) );
|
||||
while ( elementPtr )
|
||||
{
|
||||
if ( elementPtr->pNext == pNext )
|
||||
|
Loading…
Reference in New Issue
Block a user