Hymn to Beauty
C++ 3D Engine
VulkanGraphicsPipeline.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../Interface/GraphicsPipeline.hpp"
5#include "VulkanTexture.hpp"
6
7#include <vulkan/vulkan.h>
8#include <vector>
9#include <map>
10
11namespace Video {
12
13class VulkanRenderer;
14class ShaderProgram;
15class VulkanShaderProgram;
16class VertexDescription;
17
20 public:
22
29 VulkanGraphicsPipeline(const VulkanRenderer& renderer, VkDevice device, const ShaderProgram* shaderProgram, const Configuration& configuration, const VertexDescription* vertexDescription = nullptr);
30
33
35
40 VkPipeline GetPipeline(const VulkanRenderPass* renderPass);
41
43
46 VkPipelineLayout GetPipelineLayout() const;
47
49
53
54 private:
56
57 VkDevice device;
58 VkPipelineLayout pipelineLayout;
59
60 const VulkanShaderProgram* vulkanShaderProgram;
61
62 // Pipeline creation info.
63 std::vector<VkPipelineShaderStageCreateInfo> shaderStages;
64 VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo;
65 VkPipelineInputAssemblyStateCreateInfo inputAssemblyCreateInfo;
66 VkPipelineViewportStateCreateInfo viewportStateCreateInfo;
67 VkPipelineRasterizationStateCreateInfo rasterizationStateCreateInfo;
68 VkPipelineRasterizationConservativeStateCreateInfoEXT conservativeRasterizationInfo;
69 VkPipelineMultisampleStateCreateInfo multisampleStateCreateInfo;
70 VkPipelineDepthStencilStateCreateInfo depthStencilState;
71 VkPipelineColorBlendAttachmentState blendAttachmentState;
72 VkPipelineColorBlendStateCreateInfo blendStateCreateInfo;
73 VkDynamicState dynamicState[3];
74 VkPipelineDynamicStateCreateInfo dynamicStateCreateInfo;
75 VkGraphicsPipelineCreateInfo pipelineCreateInfo;
76
77 // Pipeline cache.
78 struct RenderPassCompare {
79 bool operator()(const VulkanRenderPass::Compatibility& a, const VulkanRenderPass::Compatibility& b) const {
82 } else if (a.hasColorAttachment && b.hasColorAttachment) {
85 }
86 }
87
90 } else if (a.hasDepthAttachment && b.hasDepthAttachment) {
93 }
94 }
95
98 }
99
100 return false;
101 }
102 };
103
104 std::map<VulkanRenderPass::Compatibility, VkPipeline, RenderPassCompare> pipelines;
105};
106
107}
A graphics pipeline.
Definition: GraphicsPipeline.hpp:11
A shader program.
Definition: ShaderProgram.hpp:11
Describes how a vertex buffer is accessed by a shader.
Definition: VertexDescription.hpp:8
Vulkan implementation of GraphicsPipeline.
Definition: VulkanGraphicsPipeline.hpp:19
VkPipeline GetPipeline(const VulkanRenderPass *renderPass)
Get the Vulkan pipeline for a given render pass.
Definition: VulkanGraphicsPipeline.cpp:243
VkPipelineLayout GetPipelineLayout() const
Get the Vulkan pipeline layout.
Definition: VulkanGraphicsPipeline.cpp:266
~VulkanGraphicsPipeline() final
Destructor.
Definition: VulkanGraphicsPipeline.cpp:235
VulkanGraphicsPipeline(const VulkanRenderer &renderer, VkDevice device, const ShaderProgram *shaderProgram, const Configuration &configuration, const VertexDescription *vertexDescription=nullptr)
Create new Vulkan graphics pipeline.
Definition: VulkanGraphicsPipeline.cpp:13
const VulkanShaderProgram * GetShaderProgram() const
Get the Vulkan shader program.
Definition: VulkanGraphicsPipeline.cpp:270
Vulkan implementation of RenderPass.
Definition: VulkanRenderPass.hpp:14
Low-level renderer implementing Vulkan.
Definition: VulkanRenderer.hpp:24
Vulkan implementation of ShaderProgram.
Definition: VulkanShaderProgram.hpp:16
Definition: Editor.hpp:18
The configuration of the graphics pipeline.
Definition: GraphicsPipeline.hpp:14
Compatibility information about the render pass.
Definition: VulkanRenderPass.hpp:20
bool hasDepthAttachment
Whether the render pass has a depth attachment.
Definition: VulkanRenderPass.hpp:28
VkFormat depthAttachmentFormat
The format of the render pass' depth attachment.
Definition: VulkanRenderPass.hpp:31
VkFormat colorAttachmentFormat
The format of the render pass' color attachment.
Definition: VulkanRenderPass.hpp:25
uint32_t attachmentlessMsaa
MSAA sample count when doing attachmentless rendering.
Definition: VulkanRenderPass.hpp:34
bool hasColorAttachment
Whether the render pass has a color attachment.
Definition: VulkanRenderPass.hpp:22