pipeline: parameterise on bindpoint
This commit is contained in:
parent
93b3fdedd8
commit
47bcb065c5
@ -86,13 +86,18 @@ command_buffer::next_subpass (const VkSubpassContents contents)
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <cruft::vk::bindpoint BindpointV>
|
||||||
void
|
void
|
||||||
command_buffer::bind (VkPipelineBindPoint point, const pipeline &p)
|
command_buffer::bind (const pipeline<BindpointV> &p)
|
||||||
{
|
{
|
||||||
vkCmdBindPipeline (native (), point, p.native ());
|
vkCmdBindPipeline (native (), static_cast<VkPipelineBindPoint> (BindpointV), p.native ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template void command_buffer::bind(const pipeline<bindpoint::GRAPHICS>&);
|
||||||
|
template void command_buffer::bind(const pipeline<bindpoint::COMPUTE>&);
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void
|
void
|
||||||
command_buffer::set (const event &ev, VkPipelineStageFlags flags)
|
command_buffer::set (const event &ev, VkPipelineStageFlags flags)
|
||||||
|
@ -36,7 +36,8 @@ namespace cruft::vk {
|
|||||||
|
|
||||||
void next_subpass (VkSubpassContents);
|
void next_subpass (VkSubpassContents);
|
||||||
|
|
||||||
void bind (VkPipelineBindPoint, const pipeline&);
|
template <bindpoint BindpointV>
|
||||||
|
void bind (const pipeline<BindpointV>&);
|
||||||
|
|
||||||
void set (const event&, VkPipelineStageFlags);
|
void set (const event&, VkPipelineStageFlags);
|
||||||
void reset (const event&, VkPipelineStageFlags);
|
void reset (const event&, VkPipelineStageFlags);
|
||||||
|
18
fwd.hpp
18
fwd.hpp
@ -28,6 +28,11 @@ namespace cruft::vk {
|
|||||||
template <typename SelfT, typename ParentT> struct enumerated;
|
template <typename SelfT, typename ParentT> struct enumerated;
|
||||||
template <typename SelfT, typename OwnerT> struct owned;
|
template <typename SelfT, typename OwnerT> struct owned;
|
||||||
|
|
||||||
|
enum class bindpoint {
|
||||||
|
GRAPHICS = VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
|
COMPUTE = VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||||
|
};
|
||||||
|
|
||||||
struct buffer;
|
struct buffer;
|
||||||
struct buffer_view;
|
struct buffer_view;
|
||||||
struct command_buffer;
|
struct command_buffer;
|
||||||
@ -41,7 +46,7 @@ namespace cruft::vk {
|
|||||||
struct image;
|
struct image;
|
||||||
struct image_view;
|
struct image_view;
|
||||||
struct physical_device;
|
struct physical_device;
|
||||||
struct pipeline;
|
template <bindpoint> struct pipeline;
|
||||||
struct pipeline_cache;
|
struct pipeline_cache;
|
||||||
struct pipeline_layout;
|
struct pipeline_layout;
|
||||||
struct queue;
|
struct queue;
|
||||||
@ -54,6 +59,8 @@ namespace cruft::vk {
|
|||||||
class error;
|
class error;
|
||||||
template <VkResult> class error_code;
|
template <VkResult> class error_code;
|
||||||
|
|
||||||
|
#define VK_BINDPOINT_MAP(FUNC) MAP0(FUNC, bindpoint::GRAPHICS, bindpoint::COMPUTE)
|
||||||
|
|
||||||
#define VK_ENUMERATED_TYPE_MAP(FUNC) \
|
#define VK_ENUMERATED_TYPE_MAP(FUNC) \
|
||||||
MAP0(FUNC, \
|
MAP0(FUNC, \
|
||||||
physical_device)
|
physical_device)
|
||||||
@ -62,6 +69,12 @@ namespace cruft::vk {
|
|||||||
MAP0(FUNC, \
|
MAP0(FUNC, \
|
||||||
device)
|
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) \
|
#define VK_OWNED_TYPE_MAP(FUNC) \
|
||||||
MAP0(FUNC, \
|
MAP0(FUNC, \
|
||||||
buffer, \
|
buffer, \
|
||||||
@ -75,7 +88,8 @@ namespace cruft::vk {
|
|||||||
semaphore, \
|
semaphore, \
|
||||||
shader_module, \
|
shader_module, \
|
||||||
surface, \
|
surface, \
|
||||||
swapchain)
|
swapchain) \
|
||||||
|
VK_ARRAY_TYPE_MAP(FUNC)
|
||||||
|
|
||||||
#define VK_TYPE_MAP(FUNC) \
|
#define VK_TYPE_MAP(FUNC) \
|
||||||
MAP0(FUNC,instance) \
|
MAP0(FUNC,instance) \
|
||||||
|
@ -22,8 +22,11 @@
|
|||||||
#include "./fwd.hpp"
|
#include "./fwd.hpp"
|
||||||
|
|
||||||
namespace cruft::vk {
|
namespace cruft::vk {
|
||||||
struct pipeline : public owned<pipeline,device> {
|
template <bindpoint BindpointV>
|
||||||
using owned::owned;
|
struct pipeline : public owned<pipeline<BindpointV>,device> {
|
||||||
|
static constexpr bindpoint point = BindpointV;
|
||||||
|
|
||||||
|
using owned<pipeline<BindpointV>,device>::owned;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
traits.hpp
43
traits.hpp
@ -47,7 +47,7 @@ namespace cruft::vk {
|
|||||||
template <> struct native_traits<physical_device> { using type = VkPhysicalDevice; };
|
template <> struct native_traits<physical_device> { using type = VkPhysicalDevice; };
|
||||||
template <> struct native_traits<pipeline_cache> { using type = VkPipelineCache; };
|
template <> struct native_traits<pipeline_cache> { using type = VkPipelineCache; };
|
||||||
template <> struct native_traits<pipeline_layout> { using type = VkPipelineLayout; };
|
template <> struct native_traits<pipeline_layout> { using type = VkPipelineLayout; };
|
||||||
template <> struct native_traits<pipeline> { using type = VkPipeline; };
|
|
||||||
template <> struct native_traits<queue> { using type = VkQueue; };
|
template <> struct native_traits<queue> { using type = VkQueue; };
|
||||||
template <> struct native_traits<render_pass> { using type = VkRenderPass; };
|
template <> struct native_traits<render_pass> { using type = VkRenderPass; };
|
||||||
template <> struct native_traits<semaphore> { using type = VkSemaphore; };
|
template <> struct native_traits<semaphore> { using type = VkSemaphore; };
|
||||||
@ -55,6 +55,15 @@ namespace cruft::vk {
|
|||||||
template <> struct native_traits<surface> { using type = VkSurfaceKHR; };
|
template <> struct native_traits<surface> { using type = VkSurfaceKHR; };
|
||||||
template <> struct native_traits<swapchain> { using type = VkSwapchainKHR; };
|
template <> struct native_traits<swapchain> { using type = VkSwapchainKHR; };
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
template <>
|
||||||
|
struct native_traits<pipeline<bindpoint::GRAPHICS>>
|
||||||
|
{ using type = VkPipeline; };
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct native_traits<pipeline<bindpoint::COMPUTE>>
|
||||||
|
{ using type = VkPipeline; };
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -274,23 +283,6 @@ namespace cruft::vk {
|
|||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <VkPipelineBindPoint> struct create_traits { };
|
|
||||||
template <> struct create_traits<VK_PIPELINE_BIND_POINT_COMPUTE> {
|
|
||||||
static constexpr auto func = vkCreateComputePipelines;
|
|
||||||
};
|
|
||||||
template <> struct create_traits<VK_PIPELINE_BIND_POINT_GRAPHICS> {
|
|
||||||
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<pipeline> {
|
|
||||||
// template <VkPipelineBindPoint P>
|
|
||||||
// static constexpr auto create = create_traits<P>::func;
|
|
||||||
// static constexpr auto destroy = vkDestroyPipeline;
|
|
||||||
//};
|
|
||||||
|
|
||||||
template <> struct life_traits<VkPipelineLayout> {
|
template <> struct life_traits<VkPipelineLayout> {
|
||||||
static constexpr auto& create = vkCreatePipelineLayout;
|
static constexpr auto& create = vkCreatePipelineLayout;
|
||||||
static constexpr auto& destroy = vkDestroyPipelineLayout;
|
static constexpr auto& destroy = vkDestroyPipelineLayout;
|
||||||
@ -322,6 +314,21 @@ namespace cruft::vk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
template <>
|
||||||
|
struct life_traits<pipeline<bindpoint::GRAPHICS>> {
|
||||||
|
static constexpr auto &create = vkCreateGraphicsPipelines;
|
||||||
|
static constexpr auto &destroy = vkDestroyPipeline;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct life_traits<pipeline<bindpoint::COMPUTE>> {
|
||||||
|
static constexpr auto &create = vkCreateComputePipelines;
|
||||||
|
static constexpr auto &destroy = vkDestroyPipeline;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
/// describes the functions required to enumerate native types
|
/// describes the functions required to enumerate native types
|
||||||
template <typename> struct enum_traits { };
|
template <typename> struct enum_traits { };
|
||||||
|
Loading…
Reference in New Issue
Block a user