-
Notifications
You must be signed in to change notification settings - Fork 0
/
lve_pipeline.hpp
90 lines (77 loc) · 2.4 KB
/
lve_pipeline.hpp
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
#pragma once
#include "lve_device.hpp"
// std
#include <string>
#include <vector>
namespace lve {
struct PipelineConfigInfo {
VkViewport viewport;
VkRect2D scissor;
VkPipelineViewportStateCreateInfo viewportInfo;
VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo;
VkPipelineRasterizationStateCreateInfo rasterizationInfo;
VkPipelineMultisampleStateCreateInfo multisampleInfo;
VkPipelineColorBlendAttachmentState colorBlendAttachment;
VkPipelineColorBlendStateCreateInfo colorBlendInfo;
VkPipelineDepthStencilStateCreateInfo depthStencilInfo;
std::vector<VkDynamicState> dynamicStateEnables;
VkPipelineDynamicStateCreateInfo dynamicStateInfo;
VkPipelineLayout pipelineLayout = nullptr;
VkRenderPass renderPass = nullptr;
uint32_t subpass = 0;
};
class LvePipeline {
public:
// vertex shader와 fragment shader 파일 경로를 받아서 pipeline 생성
LvePipeline(LveDevice &device, const std::string &vertFilepath,
const std::string &fragFilepath,
const PipelineConfigInfo &configInfo);
~LvePipeline();
LvePipeline(const LvePipeline &) = delete;
LvePipeline operator=(const LvePipeline &) = delete;
/**
* @brief graphics pipeline에 Command Buffer를 바인딩
*
* @param commandBuffer
*/
void bind(VkCommandBuffer commandBuffer);
/**
* @brief graphics pipeline 초기화
*
* @param configInfo
*/
static void defaultPipelineConfigInfo(PipelineConfigInfo &configInfo);
private:
/**
* @brief 바이너리 모드로 읽어와 그 데이터를 벡터 형태로 반환
*
* @param filepath
* @return std::vector<char>
*/
static std::vector<char> readFile(const std::string &filepath);
/**
* @brief Graphics Pipeline 생성
* shader 모듈들 생성
*
* @param vertFilepath
* @param fragFilepath
* @param configInfo
*/
void createGraphicsPipeline(const std::string &vertFilepath,
const std::string &fragFilepath,
const PipelineConfigInfo &configInfo);
/**
* @brief
* 바이너리 데이터를 Shader Module로 변환
*
* @param code
* @param shaderModule
*/
void createShaderModule(const std::vector<char> &code,
VkShaderModule *shaderModule);
LveDevice &lveDevice;
VkPipeline graphicsPipeline;
VkShaderModule vertShaderModule;
VkShaderModule fragShaderModule;
};
} // namespace lve