OpenGL: Implement RenderPipeline

This commit is contained in:
Lynix
2020-05-11 14:01:17 +02:00
parent 49c68e581a
commit 3cf53c4d9a
5 changed files with 177 additions and 298 deletions

View File

@@ -11,9 +11,7 @@
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Renderer/RenderPipeline.hpp>
#include <Nazara/OpenGLRenderer/Config.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Device.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Pipeline.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/RenderPass.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Program.hpp>
#include <vector>
namespace Nz
@@ -21,58 +19,16 @@ namespace Nz
class NAZARA_OPENGLRENDERER_API OpenGLRenderPipeline : public RenderPipeline
{
public:
struct CreateInfo;
OpenGLRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo);
OpenGLRenderPipeline(OpenGLDevice& device, RenderPipelineInfo pipelineInfo);
~OpenGLRenderPipeline() = default;
VkPipeline Get(const Vk::RenderPass& renderPass) const;
void Apply(const GL::Context& context) const;
static std::vector<VkPipelineColorBlendAttachmentState> BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo);
static VkPipelineColorBlendStateCreateInfo BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkPipelineColorBlendAttachmentState>& attachmentState);
static VkPipelineDepthStencilStateCreateInfo BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo);
static VkPipelineDynamicStateCreateInfo BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkDynamicState>& dynamicStates);
static std::vector<VkDynamicState> BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo);
static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo);
static VkPipelineMultisampleStateCreateInfo BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo);
static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo);
static VkPipelineViewportStateCreateInfo BuildViewportInfo(const RenderPipelineInfo& pipelineInfo);
static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front);
static std::vector<VkPipelineShaderStageCreateInfo> BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo);
static std::vector<VkVertexInputAttributeDescription> BuildVertexAttributeDescription(const RenderPipelineInfo& pipelineInfo);
static std::vector<VkVertexInputBindingDescription> BuildVertexBindingDescription(const RenderPipelineInfo& pipelineInfo);
static VkPipelineVertexInputStateCreateInfo BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkVertexInputAttributeDescription>& vertexAttributes, const std::vector<VkVertexInputBindingDescription>& bindingDescription);
static CreateInfo BuildCreateInfo(const RenderPipelineInfo& pipelineInfo);
struct CreateInfo
{
struct StateData
{
VkPipelineColorBlendStateCreateInfo colorBlendState;
VkPipelineDepthStencilStateCreateInfo depthStencilState;
VkPipelineDynamicStateCreateInfo dynamicState;
VkPipelineMultisampleStateCreateInfo multiSampleState;
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState;
VkPipelineRasterizationStateCreateInfo rasterizationState;
VkPipelineVertexInputStateCreateInfo vertexInputState;
VkPipelineViewportStateCreateInfo viewportState;
};
std::vector<VkPipelineColorBlendAttachmentState> colorBlendAttachmentState;
std::vector<VkDynamicState> dynamicStates;
std::vector<VkPipelineShaderStageCreateInfo> shaderStages;
std::vector<VkVertexInputAttributeDescription> vertexAttributesDescription;
std::vector<VkVertexInputBindingDescription> vertexBindingDescription;
std::unique_ptr<StateData> stateData;
VkGraphicsPipelineCreateInfo pipelineInfo;
};
inline const RenderPipelineInfo& GetPipelineInfo() const;
private:
mutable std::unordered_map<VkRenderPass, Vk::Pipeline> m_pipelines;
MovablePtr<Vk::Device> m_device;
CreateInfo m_pipelineCreateInfo;
RenderPipelineInfo m_pipelineInfo;
GL::Program m_program;
};
}