#pragma once #include <stdafx.h> #include "Device.h" #include "Vertex.h" namespace fpr { //Pipelines have many different possible options. //All of these are contained in this struct. This struct can be passed into a Pipeline constructor instead of all of the members individually. struct PipelineOptions { std::vector<std::pair<vk::ShaderModule, vk::ShaderStageFlagBits>> modules; vk::PipelineInputAssemblyStateCreateInfo input_assembly; vk::PipelineViewportStateCreateInfo viewport; vk::PipelineRasterizationStateCreateInfo rasterizer; std::vector<vk::DynamicState> dynamic_states; vk::PipelineMultisampleStateCreateInfo multisample; std::vector<vk::PipelineColorBlendAttachmentState> blend_attach_states; vk::PipelineDepthStencilStateCreateInfo depth_stencil; std::vector<vk::DescriptorSetLayout> layouts; vk::PipelineCreateFlags flags; vk::RenderPass render_pass; uint32_t subpass = 0; vk::Pipeline base_pipeline_handle = nullptr; //most pipelines don't have a parent int32_t base_pipeline_index = -1; // thus they don't have a pipeline index. std::vector<vk::PushConstantRange> push_constant_ranges; }; enum class EPipelineType : uint8_t { EPT_Graphics, EPT_Compute }; class Pipeline { vk::UniquePipeline m_pipeline; vk::UniquePipelineCache m_cache; vk::UniquePipelineLayout m_layout; PipelineOptions m_options; Pipeline* m_parent = nullptr; public: static PipelineOptions GetDefaultGraphicsPipeline(); static PipelineOptions GetDepthPassPipeline(); static PipelineOptions GetLightCullingPipeline(); vk::Pipeline& GetPipeline(); vk::PipelineLayout& GetLayout(); Pipeline(const PipelineOptions& options, Pipeline* parent = nullptr, EPipelineType type = EPipelineType::EPT_Graphics); Pipeline(const Pipeline& other) = delete; Pipeline(const Pipeline&& other) = delete; Pipeline operator=(const Pipeline& other) = delete; Pipeline operator=(const Pipeline&& other) = delete; }; vk::ShaderModule CreateShaderModule(const std::vector<char>& shader); } // namespace fpr