-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipeline.h
More file actions
100 lines (81 loc) · 3.06 KB
/
pipeline.h
File metadata and controls
100 lines (81 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifdef _MSC_VER
# pragma once
#endif
#ifndef PIPELINE_H
#define PIPELINE_H
#include <vulkan/vulkan.hpp>
struct CompleteGraphicsPipelineCreateInfo
{
CompleteGraphicsPipelineCreateInfo() = default;
template<class Default>
constexpr CompleteGraphicsPipelineCreateInfo(Default) :
m_vertexInputState(Default::vertexInputState),
m_inputAssemblyState(Default::inputAssemblyState),
m_tessellationState(Default::tessellationState),
m_viewportState(Default::viewportState),
m_rasterizationState(Default::rasterizationState),
m_multisampleState(Default::multisampleState),
m_depthStencilState(Default::depthStencilState),
m_colorBlendState(Default::colorBlendState),
m_dynamicState(Default::dynamicState)
{
}
std::vector<vk::PipelineShaderStageCreateInfo> m_shaderStages;
vk::PipelineVertexInputStateCreateInfo m_vertexInputState;
vk::PipelineInputAssemblyStateCreateInfo m_inputAssemblyState;
vk::PipelineTessellationStateCreateInfo m_tessellationState;
vk::PipelineViewportStateCreateInfo m_viewportState;
vk::PipelineRasterizationStateCreateInfo m_rasterizationState;
vk::PipelineMultisampleStateCreateInfo m_multisampleState;
vk::PipelineDepthStencilStateCreateInfo m_depthStencilState;
vk::PipelineColorBlendStateCreateInfo m_colorBlendState;
vk::PipelineDynamicStateCreateInfo m_dynamicState;
vk::GraphicsPipelineCreateInfo m_pipelineCreateInfo{ {},
0, nullptr, // Filled out later
&m_vertexInputState,
&m_inputAssemblyState,
nullptr, //&m_tessellationState,
&m_viewportState,
&m_rasterizationState,
&m_multisampleState,
&m_depthStencilState,
&m_colorBlendState,
nullptr, //&m_dynamicState,
nullptr, nullptr, 0
};
};
class Pipeline
{
public:
#pragma region Creation Stuff
Pipeline() = default;
Pipeline(Pipeline&& other) = default;
Pipeline(const Pipeline& other) = delete;
template<typename T>
Pipeline(T&& DefaultSettings) : m_createInfo(std::make_unique<CompleteGraphicsPipelineCreateInfo>(std::forward<T>(DefaultSettings)))
{
}
void create(bool keepCreateInfo = false);
void addShaderStage(const std::string& shaderPath);
vk::PipelineVertexInputStateCreateInfo& getVertexInputState();
vk::PipelineInputAssemblyStateCreateInfo& getInputAssemblyState();
vk::PipelineTessellationStateCreateInfo& getTessellationState();
vk::PipelineViewportStateCreateInfo& getViewportState();
vk::PipelineRasterizationStateCreateInfo& getRasterizationState();
vk::PipelineMultisampleStateCreateInfo& getMultisampleState();
vk::PipelineDepthStencilStateCreateInfo& getDepthStencilState();
vk::PipelineColorBlendStateCreateInfo& getColorBlendState();
vk::PipelineDynamicStateCreateInfo& getDynamicState();
Pipeline& setLayout(vk::PipelineLayout layout);
Pipeline& setRenderPass(vk::RenderPass renderPass, uint32_t subpass);
Pipeline& setBasePipeline(vk::Pipeline basePipelineHandle);
Pipeline& setBasePipeline(int32_t basePipelineIndex);
#pragma endregion
#pragma region Runtime Stuff
void bind(vk::CommandBuffer cb);
#pragma endregion
private:
vk::UniquePipeline m_pipeline;
std::unique_ptr<CompleteGraphicsPipelineCreateInfo> m_createInfo;
};
#endif