Skip to content

Commit

Permalink
return of assert
Browse files Browse the repository at this point in the history
  • Loading branch information
Agrael1 committed Jul 23, 2024
1 parent 85c2ae4 commit 055bac6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
4 changes: 2 additions & 2 deletions snippets/SharedDestroy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class PoolFreeShared
public:
void destroy( DestructorType parent, HandleType handle ) const VULKAN_HPP_NOEXCEPT
{
if ( m_destroy && m_dispatch && m_pool )
( parent.*m_destroy )( m_pool.get(), 1u, &handle, *m_dispatch );
VULKAN_HPP_ASSERT( m_destroy && m_dispatch && m_pool );
( parent.*m_destroy )( m_pool.get(), 1u, &handle, *m_dispatch );
}

private:
Expand Down
4 changes: 2 additions & 2 deletions vulkan/vulkan_shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ namespace VULKAN_HPP_NAMESPACE
public:
void destroy( DestructorType parent, HandleType handle ) const VULKAN_HPP_NOEXCEPT
{
if ( m_destroy && m_dispatch && m_pool )
( parent.*m_destroy )( m_pool.get(), 1u, &handle, *m_dispatch );
VULKAN_HPP_ASSERT( m_destroy && m_dispatch && m_pool );
( parent.*m_destroy )( m_pool.get(), 1u, &handle, *m_dispatch );
}

private:
Expand Down
43 changes: 39 additions & 4 deletions vulkan/vulkansc_shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ namespace VULKAN_HPP_NAMESPACE
{
};

template <typename HandleType, typename = void>
struct HasPoolType : std::false_type
{
};

template <typename HandleType>
struct HasPoolType<HandleType, decltype( (void)typename SharedHandleTraits<HandleType>::deleter::PoolTypeExport() )> : std::true_type
{
};

template <typename HandleType, typename Enable = void>
struct GetPoolType
{
using type = NoDestructor;
};

template <typename HandleType>
struct GetPoolType<HandleType, typename std::enable_if<HasPoolType<HandleType>::value>::type>
{
using type = typename SharedHandleTraits<HandleType>::deleter::PoolTypeExport;
};

//=====================================================================================================================

template <typename HandleType>
Expand Down Expand Up @@ -257,12 +279,23 @@ namespace VULKAN_HPP_NAMESPACE
public:
SharedHandle() = default;

template <typename T = HandleType, typename = typename std::enable_if<HasDestructor<T>::value>::type>
template <typename T = HandleType, typename = typename std::enable_if<HasDestructor<T>::value && !HasPoolType<T>::value>::type>
explicit SharedHandle( HandleType handle, SharedHandle<DestructorTypeOf<HandleType>> parent, DeleterType deleter = DeleterType() ) VULKAN_HPP_NOEXCEPT
: BaseType( handle, std::move( parent ), std::move( deleter ) )
{
}

template <typename Dispatcher = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
typename T = HandleType,
typename = typename std::enable_if<HasDestructor<T>::value && HasPoolType<T>::value>::type>
explicit SharedHandle( HandleType handle,
SharedHandle<DestructorTypeOf<HandleType>> parent,
SharedHandle<typename GetPoolType<HandleType>::type> pool,
const Dispatcher & dispatch VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) VULKAN_HPP_NOEXCEPT
: BaseType( handle, std::move( parent ), DeleterType{ std::move( pool ), dispatch } )
{
}

template <typename T = HandleType, typename = typename std::enable_if<!HasDestructor<T>::value>::type>
explicit SharedHandle( HandleType handle, DeleterType deleter = DeleterType() ) VULKAN_HPP_NOEXCEPT : BaseType( handle, std::move( deleter ) )
{
Expand Down Expand Up @@ -346,8 +379,8 @@ namespace VULKAN_HPP_NAMESPACE
public:
void destroy( DestructorType parent, HandleType handle ) const VULKAN_HPP_NOEXCEPT
{
if ( m_destroy && m_dispatch )
( parent.*m_destroy )( handle, m_allocationCallbacks, *m_dispatch );
VULKAN_HPP_ASSERT( m_destroy && m_dispatch );
( parent.*m_destroy )( handle, m_allocationCallbacks, *m_dispatch );
}

private:
Expand Down Expand Up @@ -390,6 +423,8 @@ namespace VULKAN_HPP_NAMESPACE
public:
using DestructorType = typename SharedHandleTraits<HandleType>::DestructorType;

using PoolTypeExport = PoolType;

template <class Dispatcher>
using ReturnType = decltype( std::declval<DestructorType>().free( PoolType(), 0u, nullptr, Dispatcher() ) );

Expand All @@ -409,7 +444,7 @@ namespace VULKAN_HPP_NAMESPACE
public:
void destroy( DestructorType parent, HandleType handle ) const VULKAN_HPP_NOEXCEPT
{
VULKAN_HPP_ASSERT( m_destroy && m_dispatch );
VULKAN_HPP_ASSERT( m_destroy && m_dispatch && m_pool );
( parent.*m_destroy )( m_pool.get(), 1u, &handle, *m_dispatch );
}

Expand Down

0 comments on commit 055bac6

Please sign in to comment.