diff --git a/fwd.hpp b/fwd.hpp index e4ad036..4f6e76c 100644 --- a/fwd.hpp +++ b/fwd.hpp @@ -24,9 +24,9 @@ namespace cruft::vk { - template struct descendant; - template struct enumerated; - template struct owned; + template struct descendant; + template struct enumerated; + template struct owned; struct instance; struct physical_device; diff --git a/object.cpp b/object.cpp index 0811ba8..53fe23f 100644 --- a/object.cpp +++ b/object.cpp @@ -35,25 +35,3 @@ VK_TYPE_MAP (OBJECT) #define DESCENDANT(T) template struct cruft::vk::descendant; VK_DESCENDANT_TYPE_MAP (DESCENDANT) - -/////////////////////////////////////////////////////////////////////////////// -template -std::vector -cruft::vk::enumerated::find (const instance &parent) { - // find the total number of objects - uint32_t expected = 0; - error::try_code (enum_traits>::enumerate (parent.native (), &expected, nullptr)); - - // allocate an array of handles and fetch them - uint32_t found = expected; - native_t handles[expected]; - error::try_code (enum_traits>::enumerate (parent.native (), &found, handles)); - - // return an collection of objects from the handles - return std::vector (handles, handles + found); -} - - -//----------------------------------------------------------------------------- -#define ENUMERATED(T) template struct cruft::vk::enumerated; -VK_ENUMERATED_TYPE_MAP (ENUMERATED) diff --git a/object.hpp b/object.hpp index 1de83ed..011419b 100644 --- a/object.hpp +++ b/object.hpp @@ -97,12 +97,17 @@ namespace cruft::vk { /////////////////////////////////////////////////////////////////////////// /// a vulkan object that is obtained by listings from a parent object. - template + template struct enumerated : public object { using object::object; static std::vector - find (const instance &parent); + find (const ParentT &parent) + { + return error::try_handles ( + enum_traits>::enumerate, parent.native () + ); + } }; diff --git a/physical_device.hpp b/physical_device.hpp index d65ac8f..042b948 100644 --- a/physical_device.hpp +++ b/physical_device.hpp @@ -26,7 +26,7 @@ #include namespace cruft::vk { - struct physical_device : public enumerated { + struct physical_device : public enumerated { using enumerated::enumerated; std::set extensions (void) const; diff --git a/traits.hpp b/traits.hpp index d8490e1..70600ba 100644 --- a/traits.hpp +++ b/traits.hpp @@ -297,7 +297,7 @@ namespace cruft::vk { template struct enum_traits { }; template <> struct enum_traits { - static constexpr auto enumerate = vkEnumeratePhysicalDevices; + static constexpr auto &enumerate = vkEnumeratePhysicalDevices; }; }