traits: more consistent traits naming scheme

This commit is contained in:
Danny Robson 2017-09-08 17:13:57 +10:00
parent b4e5689f87
commit 665a61a98e

View File

@ -21,6 +21,8 @@
#include "./fwd.hpp"
#include "./vk.hpp"
#include <cruft/util/tuple.hpp>
#include <type_traits>
@ -84,24 +86,41 @@ namespace cruft::vk {
///////////////////////////////////////////////////////////////////////////
template <typename T> struct id_traits { };
template <> struct id_traits<instance> { using id_t = VkInstance; };
template <> struct id_traits<physical_device> { using id_t = VkPhysicalDevice; };
template <> struct id_traits<device> { using id_t = VkDevice; };
template <> struct id_traits<queue> { using id_t = VkQueue; };
template <> struct id_traits<command_pool> { using id_t = VkCommandPool; };
template <> struct id_traits<command_buffer> { using id_t = VkCommandBuffer; };
template <> struct id_traits<fence> { using id_t = VkFence; };
template <> struct id_traits<semaphore> { using id_t = VkSemaphore; };
template <> struct id_traits<event> { using id_t = VkEvent; };
template <> struct id_traits<render_pass> { using id_t = VkRenderPass; };
template <> struct id_traits<framebuffer> { using id_t = VkFramebuffer; };
template <> struct id_traits<shader_module> { using id_t = VkShaderModule; };
template <> struct id_traits<pipeline> { using id_t = VkPipeline; };
template <> struct id_traits<pipeline_cache> { using id_t = VkPipelineCache; };
template <> struct id_traits<device_memory> { using id_t = VkDeviceMemory; };
template <> struct id_traits<buffer> { using id_t = VkBuffer; };
template <> struct id_traits<buffer_view> { using id_t = VkBufferView; };
template <> struct id_traits<surface> { using id_t = VkSurfaceKHR; };
//-------------------------------------------------------------------------
template <> struct id_traits<instance> { using type = VkInstance; };
template <> struct id_traits<physical_device> { using type = VkPhysicalDevice; };
template <> struct id_traits<device> { using type = VkDevice; };
template <> struct id_traits<queue> { using type = VkQueue; };
template <> struct id_traits<command_pool> { using type = VkCommandPool; };
template <> struct id_traits<command_buffer> { using type = VkCommandBuffer; };
template <> struct id_traits<fence> { using type = VkFence; };
template <> struct id_traits<semaphore> { using type = VkSemaphore; };
template <> struct id_traits<event> { using type = VkEvent; };
template <> struct id_traits<render_pass> { using type = VkRenderPass; };
template <> struct id_traits<framebuffer> { using type = VkFramebuffer; };
template <> struct id_traits<shader_module> { using type = VkShaderModule; };
template <> struct id_traits<pipeline> { using type = VkPipeline; };
template <> struct id_traits<pipeline_cache> { using type = VkPipelineCache; };
template <> struct id_traits<device_memory> { using type = VkDeviceMemory; };
template <> struct id_traits<buffer> { using type = VkBuffer; };
template <> struct id_traits<buffer_view> { using type = VkBufferView; };
template <> struct id_traits<surface> { using type = VkSurfaceKHR; };
//-------------------------------------------------------------------------
template <typename T>
using id_t = typename id_traits<T>::type;
///////////////////////////////////////////////////////////////////////////
template <typename> struct owner_traits {};
template <> struct owner_traits<queue> { using type = device; };
template <> struct owner_traits<surface> { using type = instance; };
template <typename T>
using owner_t = typename owner_traits<T>::type;
///////////////////////////////////////////////////////////////////////////
@ -158,7 +177,17 @@ namespace cruft::vk {
template <>
struct life_traits<queue> {
static constexpr auto get = vkGetDeviceQueue;
// clang#18781: we work around an ODR bug in clang which causes
// undefined references by explicitly using a temporary here. ideally
// this causes minimal difference in the generated output.
using create_t = decltype(vkGetDeviceQueue);
static constexpr create_t& create = vkGetDeviceQueue;
static constexpr auto destroy = ::util::tuple::ignore<
id_t<owner_t<queue>>,
id_t<queue>,
const VkAllocationCallbacks*
>;
};
template <VkPipelineBindPoint> struct create_traits { };