minecraftvulkan/engine/xe_pipeline.hpp

67 lines
2 KiB
C++
Raw Normal View History

2022-09-19 01:20:51 +00:00
#pragma once
#include "xe_device.hpp"
#include <cstdint>
#include <string>
#include <vector>
#include <vulkan/vulkan_core.h>
namespace xe {
struct PipelineConfigInfo {
PipelineConfigInfo(const PipelineConfigInfo&) = delete;
PipelineConfigInfo& operator=(const PipelineConfigInfo&) = delete;
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;
};
2022-09-25 01:16:13 +00:00
class Pipeline {
2022-09-19 01:20:51 +00:00
public:
2022-09-25 01:16:13 +00:00
Pipeline(
Device &device,
2022-09-19 01:20:51 +00:00
const std::string& vertFilepath,
const std::string& fragFilepath,
2022-09-25 16:07:49 +00:00
const PipelineConfigInfo& configInfo,
std::vector<VkVertexInputAttributeDescription> &attributeDescptions,
uint32_t vertexSize
);
2022-09-25 01:16:13 +00:00
~Pipeline();
2022-09-19 01:20:51 +00:00
2022-09-25 01:16:13 +00:00
Pipeline(const Pipeline&) = delete;
Pipeline operator=(const Pipeline&) = delete;
2022-09-19 01:20:51 +00:00
void bind(VkCommandBuffer commandBuffer);
static void defaultPipelineConfigInfo(PipelineConfigInfo& configInfo);
private:
static std::vector<char> readFile(const std::string& filePath);
void createGraphicsPipeline(
const std::string& vertFilePath,
const std::string& fragFilepath,
2022-09-25 16:07:49 +00:00
const PipelineConfigInfo& configInfo,
std::vector<VkVertexInputAttributeDescription> &attributeDescptions,
uint32_t vertexSize
);
2022-09-19 01:20:51 +00:00
void createShaderModule(const std::vector<char>& code, VkShaderModule* shaderModule);
2022-09-25 01:16:13 +00:00
Device& xeDevice;
2022-09-19 01:20:51 +00:00
VkPipeline graphicsPipeline;
VkShaderModule vertShaderModule;
VkShaderModule fragShaderModule;
};
}