-
Notifications
You must be signed in to change notification settings - Fork 0
/
spock_pipeline.hpp
62 lines (49 loc) · 1.85 KB
/
spock_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
#pragma once
#include "spock_device.hpp"
#include <cstdint>
#include <string>
#include <vector>
#include <vulkan/vulkan_core.h>
namespace spock {
struct PipelineConfigInfo {
VkViewport viewport;
VkRect2D scissor;
// VkPipelineViewportStateCreateInfo viewportInfo;
VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo;
VkPipelineRasterizationStateCreateInfo rasterizationInfo;
VkPipelineMultisampleStateCreateInfo multisampleInfo;
VkPipelineColorBlendAttachmentState colorBlendAttachment;
VkPipelineColorBlendStateCreateInfo colorBlendInfo;
VkPipelineDepthStencilStateCreateInfo depthStencilInfo;
VkPipelineLayout pipelineLayout = nullptr;
VkRenderPass renderPass = nullptr;
uint32_t subpass = 1;
};
class SpockPipeline {
public:
SpockPipeline(
SpockDevice& device,
const std::string& vertFilepath,
const std::string& fragFilepath,
const PipelineConfigInfo& configInfo
);
~SpockPipeline();
SpockPipeline(const SpockPipeline&) = delete;
void operator=(const SpockPipeline) = delete;
static PipelineConfigInfo defaultPipelineConfigInfo(uint32_t width, uint32_t height);
void bind(VkCommandBuffer commandBuffer);
private:
static std::vector<char> readFile(const std::string& filepath);
void createGraphicsPipeline(
const std::string& vertFilepat,
const std::string& fragFilepath,
const PipelineConfigInfo& configInfo
);
void createShaderModule(const std::vector<char>& code, VkShaderModule* shaderModule);
// potentially unsafe
SpockDevice& spockDevice;
VkPipeline graphicsPipeline;
VkShaderModule vertShaderModule;
VkShaderModule fragShaderModule;
};
}