traits: use wrapper_traits for wrapper create/destroy indirection
This commit is contained in:
parent
4ecac0648b
commit
0ccbfc1cbe
12
object.hpp
12
object.hpp
@ -58,7 +58,7 @@ namespace cruft::vk {
|
||||
root (Args &&...args):
|
||||
object<SelfT> (
|
||||
cruft::vk::error::try_query (
|
||||
life_traits<native_t<SelfT>>::create,
|
||||
wrapper_traits<SelfT>::create,
|
||||
std::forward<Args> (args)...
|
||||
)
|
||||
)
|
||||
@ -66,7 +66,7 @@ namespace cruft::vk {
|
||||
|
||||
~root ()
|
||||
{
|
||||
life_traits<native_t<SelfT>>::destroy (this->native (), nullptr);
|
||||
wrapper_traits<SelfT>::destroy (this->native (), nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
@ -81,7 +81,7 @@ namespace cruft::vk {
|
||||
descendant (ParentT &parent, Args &&...args):
|
||||
object<SelfT> (
|
||||
cruft::vk::error::try_query(
|
||||
life_traits<native_t<SelfT>>::create,
|
||||
wrapper_traits<SelfT>::create,
|
||||
parent.native (),
|
||||
std::forward<Args> (args)...
|
||||
)
|
||||
@ -92,7 +92,7 @@ namespace cruft::vk {
|
||||
//---------------------------------------------------------------------
|
||||
~descendant ()
|
||||
{
|
||||
life_traits<native_t<SelfT>>::destroy (this->native (), nullptr);
|
||||
wrapper_traits<SelfT>::destroy (this->native (), nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
@ -129,7 +129,7 @@ namespace cruft::vk {
|
||||
owned (OwnerT &owner, Args &&...args):
|
||||
object<SelfT> (
|
||||
error::try_query (
|
||||
life_traits<native_t<SelfT>>::create,
|
||||
wrapper_traits<SelfT>::create,
|
||||
owner.native (),
|
||||
std::forward<Args> (args)...
|
||||
)
|
||||
@ -154,7 +154,7 @@ namespace cruft::vk {
|
||||
void
|
||||
destroy (OwnerT &owner)
|
||||
{
|
||||
life_traits<native_t<SelfT>>::destroy (owner.native (), this->native (), nullptr);
|
||||
wrapper_traits<SelfT>::destroy (owner.native (), this->native (), nullptr);
|
||||
this->m_native = VK_NULL_HANDLE;
|
||||
}
|
||||
};
|
||||
|
12
traits.hpp
12
traits.hpp
@ -170,6 +170,8 @@ namespace cruft::vk {
|
||||
template <> struct owner_traits<shader_module> { using type = device; };
|
||||
template <> struct owner_traits<surface> { using type = instance; };
|
||||
template <> struct owner_traits<swapchain> { using type = device; };
|
||||
template <> struct owner_traits<pipeline<bindpoint::GRAPHICS>> { using type = device; };
|
||||
template <> struct owner_traits<pipeline<bindpoint::COMPUTE>> { using type = device; };
|
||||
|
||||
template <typename T>
|
||||
using owner_t = typename owner_traits<T>::type;
|
||||
@ -314,16 +316,22 @@ namespace cruft::vk {
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
struct wrapper_traits : public life_traits<native_t<T>> { };
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
template <>
|
||||
struct life_traits<pipeline<bindpoint::GRAPHICS>> {
|
||||
struct wrapper_traits<pipeline<bindpoint::GRAPHICS>> {
|
||||
static constexpr auto &create = vkCreateGraphicsPipelines;
|
||||
static constexpr auto &destroy = vkDestroyPipeline;
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
template <>
|
||||
struct life_traits<pipeline<bindpoint::COMPUTE>> {
|
||||
struct wrapper_traits<pipeline<bindpoint::COMPUTE>> {
|
||||
static constexpr auto &create = vkCreateComputePipelines;
|
||||
static constexpr auto &destroy = vkDestroyPipeline;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user