diff --git a/command_buffer.cpp b/command_buffer.cpp index 05839db..16dda31 100644 --- a/command_buffer.cpp +++ b/command_buffer.cpp @@ -86,13 +86,18 @@ command_buffer::next_subpass (const VkSubpassContents contents) /////////////////////////////////////////////////////////////////////////////// +template void -command_buffer::bind (VkPipelineBindPoint point, const pipeline &p) +command_buffer::bind (const pipeline &p) { - vkCmdBindPipeline (native (), point, p.native ()); + vkCmdBindPipeline (native (), static_cast (BindpointV), p.native ()); } +template void command_buffer::bind(const pipeline&); +template void command_buffer::bind(const pipeline&); + + /////////////////////////////////////////////////////////////////////////////// void command_buffer::set (const event &ev, VkPipelineStageFlags flags) diff --git a/command_buffer.hpp b/command_buffer.hpp index 876dd61..ca04ab7 100644 --- a/command_buffer.hpp +++ b/command_buffer.hpp @@ -36,7 +36,8 @@ namespace cruft::vk { void next_subpass (VkSubpassContents); - void bind (VkPipelineBindPoint, const pipeline&); + template + void bind (const pipeline&); void set (const event&, VkPipelineStageFlags); void reset (const event&, VkPipelineStageFlags); diff --git a/fwd.hpp b/fwd.hpp index 64b018e..aed9626 100644 --- a/fwd.hpp +++ b/fwd.hpp @@ -27,7 +27,12 @@ namespace cruft::vk { template struct descendant; template struct enumerated; template struct owned; - + + enum class bindpoint { + GRAPHICS = VK_PIPELINE_BIND_POINT_GRAPHICS, + COMPUTE = VK_PIPELINE_BIND_POINT_COMPUTE, + }; + struct buffer; struct buffer_view; struct command_buffer; @@ -41,7 +46,7 @@ namespace cruft::vk { struct image; struct image_view; struct physical_device; - struct pipeline; + template struct pipeline; struct pipeline_cache; struct pipeline_layout; struct queue; @@ -54,6 +59,8 @@ namespace cruft::vk { class error; template class error_code; + #define VK_BINDPOINT_MAP(FUNC) MAP0(FUNC, bindpoint::GRAPHICS, bindpoint::COMPUTE) + #define VK_ENUMERATED_TYPE_MAP(FUNC) \ MAP0(FUNC, \ physical_device) @@ -62,6 +69,12 @@ namespace cruft::vk { MAP0(FUNC, \ device) + #define VK_ARRAY_TYPE_MAP(FUNC) \ + MAP0(FUNC, \ + pipeline<::cruft::vk::bindpoint::GRAPHICS>, \ + pipeline<::cruft::vk::bindpoint::COMPUTE> \ + ) + #define VK_OWNED_TYPE_MAP(FUNC) \ MAP0(FUNC, \ buffer, \ @@ -75,7 +88,8 @@ namespace cruft::vk { semaphore, \ shader_module, \ surface, \ - swapchain) + swapchain) \ + VK_ARRAY_TYPE_MAP(FUNC) #define VK_TYPE_MAP(FUNC) \ MAP0(FUNC,instance) \ diff --git a/pipeline.hpp b/pipeline.hpp index 7eb03d9..db7a13c 100644 --- a/pipeline.hpp +++ b/pipeline.hpp @@ -22,8 +22,11 @@ #include "./fwd.hpp" namespace cruft::vk { - struct pipeline : public owned { - using owned::owned; + template + struct pipeline : public owned,device> { + static constexpr bindpoint point = BindpointV; + + using owned,device>::owned; }; } diff --git a/traits.hpp b/traits.hpp index 6328bd4..534f093 100644 --- a/traits.hpp +++ b/traits.hpp @@ -47,7 +47,7 @@ namespace cruft::vk { template <> struct native_traits { using type = VkPhysicalDevice; }; template <> struct native_traits { using type = VkPipelineCache; }; template <> struct native_traits { using type = VkPipelineLayout; }; - template <> struct native_traits { using type = VkPipeline; }; + template <> struct native_traits { using type = VkQueue; }; template <> struct native_traits { using type = VkRenderPass; }; template <> struct native_traits { using type = VkSemaphore; }; @@ -55,6 +55,15 @@ namespace cruft::vk { template <> struct native_traits { using type = VkSurfaceKHR; }; template <> struct native_traits { using type = VkSwapchainKHR; }; + //------------------------------------------------------------------------- + template <> + struct native_traits> + { using type = VkPipeline; }; + + template <> + struct native_traits> + { using type = VkPipeline; }; + //------------------------------------------------------------------------- template @@ -274,23 +283,6 @@ namespace cruft::vk { >; }; - template struct create_traits { }; - template <> struct create_traits { - static constexpr auto func = vkCreateComputePipelines; - }; - template <> struct create_traits { - static constexpr auto func = vkCreateGraphicsPipelines; - }; - - // XXX: Currently causes a segfault under gcc-5.3.0 when stabs debgging is - // enabled. See gcc#71058 - // - //template <> struct life_traits { - // template - // static constexpr auto create = create_traits

::func; - // static constexpr auto destroy = vkDestroyPipeline; - //}; - template <> struct life_traits { static constexpr auto& create = vkCreatePipelineLayout; static constexpr auto& destroy = vkDestroyPipelineLayout; @@ -322,6 +314,21 @@ namespace cruft::vk { }; + //------------------------------------------------------------------------- + template <> + struct life_traits> { + static constexpr auto &create = vkCreateGraphicsPipelines; + static constexpr auto &destroy = vkDestroyPipeline; + }; + + + template <> + struct life_traits> { + static constexpr auto &create = vkCreateComputePipelines; + static constexpr auto &destroy = vkDestroyPipeline; + }; + + /////////////////////////////////////////////////////////////////////////// /// describes the functions required to enumerate native types template struct enum_traits { };