#pragma once #include "cve_device.hpp" #include #include namespace cve { struct PipelineConfigInfo { VkViewport viewport; VkRect2D scissor; VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo; VkPipelineRasterizationStateCreateInfo rasterizationInfo; VkPipelineMultisampleStateCreateInfo multisampleInfo; VkPipelineColorBlendAttachmentState colorBlendAttachment; VkPipelineColorBlendStateCreateInfo colorBlendInfo; VkPipelineDepthStencilStateCreateInfo depthStencilInfo; VkPipelineLayout pipelineLayout = nullptr; VkRenderPass renderPass = nullptr; uint32_t subpass = 0; }; class CvePipeline { public: CvePipeline(CveDevice &device, const std::string& vertFilepath, const std::string& fragFilepath, const PipelineConfigInfo &configInfo); ~CvePipeline(); CvePipeline(const CvePipeline&) = delete; CvePipeline& operator=(const CvePipeline&) = delete; void bind(VkCommandBuffer commandBuffer); static PipelineConfigInfo defaultPipelineConfigInfo(uint32_t width, uint32_t height); private: static std::vector readFile(const std::string& filepath); void createGraphicsPipeline(const std::string& vertFilepath, const std::string& fragFilepath, const PipelineConfigInfo &configInfo); void createShaderModule(const std::vector& code, VkShaderModule *shaderModule); CveDevice& cveDevice; VkPipeline graphicsPipeline; VkShaderModule vertShaderModule; VkShaderModule fragShaderModule; }; }