Created pipeline builder and wrapper
basalt::Pipeline is mainly just a wrapper around VkPipeline however there is no cast operator provided (yet)
This commit is contained in:
70
include/vulkan/basalt_pipeline.h
Normal file
70
include/vulkan/basalt_pipeline.h
Normal file
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
#include "vulkan/basalt_render_pass.h"
|
||||
|
||||
namespace basalt
|
||||
{
|
||||
class Pipeline
|
||||
{
|
||||
public:
|
||||
Pipeline(const Pipeline& src) = delete;
|
||||
Pipeline& operator =(const Pipeline& src) = delete;
|
||||
Pipeline(Pipeline&& other) noexcept;
|
||||
Pipeline& operator =(Pipeline&& other) noexcept;
|
||||
|
||||
Pipeline(basalt::Device& device, VkPipeline pipeline, VkPipelineLayout layout);
|
||||
~Pipeline();
|
||||
|
||||
void swap(Pipeline& other) noexcept;
|
||||
|
||||
VkPipeline vk = VK_NULL_HANDLE;
|
||||
VkPipelineLayout layout = VK_NULL_HANDLE;
|
||||
basalt::Device* device = nullptr;
|
||||
bool should_free = true;
|
||||
};
|
||||
|
||||
class PipelineBuilder
|
||||
{
|
||||
public:
|
||||
PipelineBuilder(basalt::Device& device, VkExtent2D extent, VkPipeline previous_pipeline=VK_NULL_HANDLE);
|
||||
~PipelineBuilder();
|
||||
|
||||
PipelineBuilder& add_shader(const char* fpath, VkShaderStageFlagBits stage, const char* entry="main");
|
||||
PipelineBuilder& add_dynamic_state(const VkDynamicState state);
|
||||
PipelineBuilder& add_dynamic_states(const VkDynamicState* states, const u32 num_states);
|
||||
PipelineBuilder& add_dynamic_states(const basalt::darray<VkDynamicState>& states);
|
||||
PipelineBuilder& set_render_pass(VkRenderPass render_pass);
|
||||
PipelineBuilder& add_colour_attachment(VkPipelineColorBlendAttachmentState attachment);
|
||||
|
||||
Pipeline build();
|
||||
|
||||
basalt::darray<VkShaderModule> shader_modules;
|
||||
basalt::darray<VkPipelineShaderStageCreateInfo> shader_stages;
|
||||
|
||||
VkPipelineRasterizationStateCreateInfo raster_ci;
|
||||
VkPipelineColorBlendStateCreateInfo colour_blend_ci;
|
||||
VkPipelineLayoutCreateInfo layout_ci;
|
||||
VkPipelineVertexInputStateCreateInfo vertex_ci;
|
||||
VkPipelineMultisampleStateCreateInfo multisample_ci;
|
||||
VkPipelineViewportStateCreateInfo viewport_ci;
|
||||
VkPipelineInputAssemblyStateCreateInfo assembly_ci;
|
||||
VkPipelineDynamicStateCreateInfo dynamic_state_ci;
|
||||
basalt::darray<VkPipelineColorBlendAttachmentState> colour_attachments;
|
||||
basalt::darray<VkDynamicState> dynamic_states;
|
||||
VkViewport viewport;
|
||||
VkRect2D scissor;
|
||||
basalt::Device& device;
|
||||
VkRenderPass render_pass = VK_NULL_HANDLE;
|
||||
VkPipeline previous_pipeline = VK_NULL_HANDLE;
|
||||
protected:
|
||||
/// <summary>
|
||||
/// Will read all of the contents of a file into outptr
|
||||
/// Should outptr not be big enough or nullptr, it will be allocated
|
||||
/// If it is not big enough it will be reallocated
|
||||
/// </summary>
|
||||
/// <param name="fpath">Path to the file to read</param>
|
||||
/// <param name="outptr">A reference to a pointer that may be updated</param>
|
||||
/// <param name="size">Size of an existing allocation associated with outptr</param>
|
||||
/// <returns>Number of bytes read from the file</returns>
|
||||
static size_t read_file(const char* fpath, char*& outptr, size_t& outptr_size);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user