Hymn to Beauty
C++ 3D Engine
WebGPUGraphicsPipeline.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../Interface/GraphicsPipeline.hpp"
4
5#include "WebGPU.hpp"
6#include <map>
7
8namespace Video {
9
10class WebGPURenderer;
11class ShaderProgram;
12class WebGPUShaderProgram;
13class VertexDescription;
14
17 public:
22
24 WGPUTextureFormat colorAttachmentFormat;
25
28
30 WGPUTextureFormat depthAttachmentFormat;
31
34 };
35
37
43 WebGPUGraphicsPipeline(WebGPURenderer& renderer, const ShaderProgram* shaderProgram, const Configuration& configuration, const VertexDescription* vertexDescription = nullptr);
44
47
49
54 WGPURenderPipeline GetRenderPipeline(const RenderPassDescription& renderPassDescription);
55
57
61
62 private:
64
65 const WebGPUShaderProgram* webGPUShaderProgram;
66
67 WGPUDevice device;
68 WGPUPipelineLayout pipelineLayout;
69 WGPUVertexBufferLayout vertexBufferLayout;
70 WGPURenderPipelineDescriptor pipelineDescriptor;
71 WGPUPrimitiveDepthClipControl depthClipControl;
72 WGPUDepthStencilState depthStencilState;
73 WGPUFragmentState fragmentState;
74 WGPUColorTargetState colorTargetState;
75 WGPUBlendState blendState;
76
77 // Pipeline cache.
78 struct RenderPassCompare {
79 bool operator()(const RenderPassDescription& a, const RenderPassDescription& 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<RenderPassDescription, WGPURenderPipeline, 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
WebGPU implementation of GraphicsPipeline.
Definition: WebGPUGraphicsPipeline.hpp:16
const WebGPUShaderProgram * GetShaderProgram() const
Get the shader program.
Definition: WebGPUGraphicsPipeline.cpp:212
~WebGPUGraphicsPipeline() final
Destructor.
Definition: WebGPUGraphicsPipeline.cpp:158
WebGPUGraphicsPipeline(WebGPURenderer &renderer, const ShaderProgram *shaderProgram, const Configuration &configuration, const VertexDescription *vertexDescription=nullptr)
Create new WebGPU graphics pipeline.
Definition: WebGPUGraphicsPipeline.cpp:14
WGPURenderPipeline GetRenderPipeline(const RenderPassDescription &renderPassDescription)
Get the WebGPU pipeline for a given render pass.
Definition: WebGPUGraphicsPipeline.cpp:165
Low-level renderer implementing WebGPU.
Definition: WebGPURenderer.hpp:22
WebGPU implementation of ShaderProgram.
Definition: WebGPUShaderProgram.hpp:16
Definition: Editor.hpp:18
The configuration of the graphics pipeline.
Definition: GraphicsPipeline.hpp:14
A description of a render pass.
Definition: WebGPUGraphicsPipeline.hpp:19
bool hasColorAttachment
Whether the render pass has a color attachment.
Definition: WebGPUGraphicsPipeline.hpp:21
bool hasDepthAttachment
Whether the render pass has a depth attachment.
Definition: WebGPUGraphicsPipeline.hpp:27
uint32_t attachmentlessMsaa
MSAA sample count when doing attachmentless rendering.
Definition: WebGPUGraphicsPipeline.hpp:33
WGPUTextureFormat depthAttachmentFormat
The format of the render pass' depth attachment (if there is one).
Definition: WebGPUGraphicsPipeline.hpp:30
WGPUTextureFormat colorAttachmentFormat
The format of the render pass' color attachment (if there is one).
Definition: WebGPUGraphicsPipeline.hpp:24