From 0ccbfc1cbe6ca7c1d4d11dea0e74f80fe16d4d42 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 13 Sep 2017 16:50:23 +1000 Subject: [PATCH] traits: use wrapper_traits for wrapper create/destroy indirection --- object.hpp | 12 ++++++------ traits.hpp | 12 ++++++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/object.hpp b/object.hpp index 769b34e..29b441f 100644 --- a/object.hpp +++ b/object.hpp @@ -58,7 +58,7 @@ namespace cruft::vk { root (Args &&...args): object ( cruft::vk::error::try_query ( - life_traits>::create, + wrapper_traits::create, std::forward (args)... ) ) @@ -66,7 +66,7 @@ namespace cruft::vk { ~root () { - life_traits>::destroy (this->native (), nullptr); + wrapper_traits::destroy (this->native (), nullptr); } }; @@ -81,7 +81,7 @@ namespace cruft::vk { descendant (ParentT &parent, Args &&...args): object ( cruft::vk::error::try_query( - life_traits>::create, + wrapper_traits::create, parent.native (), std::forward (args)... ) @@ -92,7 +92,7 @@ namespace cruft::vk { //--------------------------------------------------------------------- ~descendant () { - life_traits>::destroy (this->native (), nullptr); + wrapper_traits::destroy (this->native (), nullptr); } }; @@ -129,7 +129,7 @@ namespace cruft::vk { owned (OwnerT &owner, Args &&...args): object ( error::try_query ( - life_traits>::create, + wrapper_traits::create, owner.native (), std::forward (args)... ) @@ -154,7 +154,7 @@ namespace cruft::vk { void destroy (OwnerT &owner) { - life_traits>::destroy (owner.native (), this->native (), nullptr); + wrapper_traits::destroy (owner.native (), this->native (), nullptr); this->m_native = VK_NULL_HANDLE; } }; diff --git a/traits.hpp b/traits.hpp index cbff83e..08f70c5 100644 --- a/traits.hpp +++ b/traits.hpp @@ -170,6 +170,8 @@ namespace cruft::vk { template <> struct owner_traits { using type = device; }; template <> struct owner_traits { using type = instance; }; template <> struct owner_traits { using type = device; }; + template <> struct owner_traits> { using type = device; }; + template <> struct owner_traits> { using type = device; }; template using owner_t = typename owner_traits::type; @@ -314,16 +316,22 @@ namespace cruft::vk { }; + /////////////////////////////////////////////////////////////////////////// + template + struct wrapper_traits : public life_traits> { }; + + //------------------------------------------------------------------------- template <> - struct life_traits> { + struct wrapper_traits> { static constexpr auto &create = vkCreateGraphicsPipelines; static constexpr auto &destroy = vkDestroyPipeline; }; + //------------------------------------------------------------------------- template <> - struct life_traits> { + struct wrapper_traits> { static constexpr auto &create = vkCreateComputePipelines; static constexpr auto &destroy = vkDestroyPipeline; };