2024-02-21 13:28:50 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "hk_device.hpp"
|
|
|
|
|
|
|
|
// std
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace hk
|
|
|
|
{
|
|
|
|
struct PipelineConfigInfo
|
|
|
|
{
|
2024-02-21 21:01:49 +08:00
|
|
|
PipelineConfigInfo(const PipelineConfigInfo&) = delete;
|
|
|
|
PipelineConfigInfo &operator=(const PipelineConfigInfo&) = delete;
|
|
|
|
|
|
|
|
VkPipelineViewportStateCreateInfo viewportInfo;
|
2024-02-21 13:28:50 +08:00
|
|
|
VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo;
|
|
|
|
VkPipelineRasterizationStateCreateInfo rasterizationInfo;
|
|
|
|
VkPipelineMultisampleStateCreateInfo multisampleInfo;
|
|
|
|
VkPipelineColorBlendAttachmentState colorBlendAttachment;
|
|
|
|
VkPipelineColorBlendStateCreateInfo colorBlendInfo;
|
|
|
|
VkPipelineDepthStencilStateCreateInfo depthStencilInfo;
|
2024-02-21 21:01:49 +08:00
|
|
|
std::vector<VkDynamicState> dynamicStateEnables;
|
|
|
|
VkPipelineDynamicStateCreateInfo dynamicStateInfo;
|
2024-02-21 13:28:50 +08:00
|
|
|
VkPipelineLayout pipelineLayout = nullptr;
|
|
|
|
VkRenderPass renderPass = nullptr;
|
|
|
|
uint32_t subpass = 0;
|
|
|
|
};
|
|
|
|
class Pipeline
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Pipeline(
|
|
|
|
Device& device,
|
|
|
|
const std::string &vertFilePath,
|
|
|
|
const std::string &fragFilePath,
|
|
|
|
const PipelineConfigInfo& configInfo);
|
|
|
|
|
|
|
|
~Pipeline();
|
|
|
|
|
|
|
|
Pipeline(const Pipeline&) = delete;
|
|
|
|
Pipeline &operator=(const Pipeline&) = delete;
|
|
|
|
|
|
|
|
void bind(VkCommandBuffer commandBuffer);
|
|
|
|
|
2024-02-21 21:01:49 +08:00
|
|
|
static void defaultPipelineConfigInfo(PipelineConfigInfo& configInfo);
|
2024-02-21 13:28:50 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
static std::vector<char> readFile(const std::string &filePath);
|
|
|
|
void createGraphicPipeline(
|
|
|
|
const std::string &vertFilePath,
|
|
|
|
const std::string &fragFilePath,
|
|
|
|
const PipelineConfigInfo& configInfo);
|
|
|
|
|
|
|
|
void createShaderModule(const std::vector<char>& code, VkShaderModule* shaderModule);
|
|
|
|
|
|
|
|
Device& device;
|
|
|
|
VkPipeline graphicPipeline;
|
|
|
|
VkShaderModule vertShaderModule;
|
|
|
|
VkShaderModule fragShaderModule;
|
|
|
|
};
|
|
|
|
}
|