Foundation
Loading...
Searching...
No Matches
PipelineState.hpp
Go to the documentation of this file.
1#pragma once
2#include "Common.hpp"
3#include "Shader.hpp"
4#include "Descriptor.hpp"
5namespace Foundation::RHI {
6 class RHIDevice;
8 {
9 protected:
11 public:
17 RHIPipelineStateCache(RHIDevice const& device, PipelineStateCacheDesc const& desc) : mDevice(device), mDesc(desc) {}
18
19 [[nodiscard]] virtual size_t GetCachedData(void* dstBuffer = nullptr) const = 0;
20 virtual void DebugSetObjectName(const char* name) = 0;
21 };
22 class RHIPipelineState : public RHIObject {
23 protected:
25 public:
28 RHIDevicePipelineType type{ RHIDevicePipelineType::Graphics };
29 // [Graphics] Vertex Input
30 struct VertexInput {
31 struct Binding {
32 uint32_t stride; // In bytes
33 bool perInstance{ false }; // If true, this binding is per-instance data
34 };
38 // [Graphics] Input Assembly
45 // [Graphics] Viewport
46 struct Viewport {
47 float x = 0, y = 0, width, height;
48 float minDepth = 0.0, maxDepth = 1.0;
50 // [Graphics] Scissor
51 struct Scissor {
52 int32_t x = 0, y = 0, width, height;
54 // [Graphics] Rasterizer
73 // [Graphics] MSAA
78 // [Graphics] Depth Stencil
95 struct Attachment {
96 struct Blending {
97 bool enabled{ false };
115 const static Blending GetNoBlending() { return {}; }
116 const static Blending GetAlphaBlending() {
117 return {
118 .enabled = true,
119 .srcColorBlendFactor = SrcAlpha,
120 .dstColorBlendFactor = OneMinusSrcAlpha,
121 .srcAlphaBlendFactor = One,
122 .dstAlphaBlendFactor = OneMinusSrcAlpha,
123 .colorBlendOp = Add,
124 .alphaBlendOp = Add
125 };
126 }
128 {
129 return {
130 .enabled = true,
131 .srcColorBlendFactor = SrcAlpha,
132 .dstColorBlendFactor = One,
133 .srcAlphaBlendFactor = One,
134 .dstAlphaBlendFactor = One,
135 .colorBlendOp = Add,
136 .alphaBlendOp = Add
137 };
138 }
143 };
144 // [Graphics] Attachments/Alpha Blending
146 // Stages
147 struct ShaderStage {
148 struct StageDesc {
149 // Stage this shader participates in
150 // You can only specify one stage per shader module.
152 const char* entryPoint;
153 // Only one specialization info per stage for simplicity
157 };
159 // Descriptors
161 // Push Constants
164 size_t offset;
165 size_t size;
166 };
168 };
170
171 RHIPipelineState(RHIDevice const& device, PipelineStateDesc const& desc) : mDevice(device), mDesc(desc) {}
172
173 virtual void DebugSetObjectName(const char* name) = 0;
174 };
175
176}
Definition Device.hpp:188
Base class for all RHI objects.
Definition Details.hpp:16
Definition PipelineState.hpp:8
const PipelineStateCacheDesc mDesc
Definition PipelineState.hpp:16
virtual void DebugSetObjectName(const char *name)=0
virtual size_t GetCachedData(void *dstBuffer=nullptr) const =0
RHIPipelineStateCache(RHIDevice const &device, PipelineStateCacheDesc const &desc)
Definition PipelineState.hpp:17
const RHIDevice & mDevice
Definition PipelineState.hpp:10
Definition PipelineState.hpp:22
const RHIDevice & mDevice
Definition PipelineState.hpp:24
RHIPipelineState(RHIDevice const &device, PipelineStateDesc const &desc)
Definition PipelineState.hpp:171
const PipelineStateDesc mDesc
Definition PipelineState.hpp:169
virtual void DebugSetObjectName(const char *name)=0
Definition Shader.hpp:5
T * Construct(Allocator *resource, Args &&...args)
Convenience placement new with object of type T using a Foundation::Core::Allocator.
Definition Allocator.hpp:149
std::span< T > Span
Alias for std::span
Definition Container.hpp:60
Low-level Rendering Hardware Interface (RHI) abstractions.
Definition Application.hpp:4
RHIResourceFormat
Definition Common.hpp:20
RHIMultisampleCount
Definition Common.hpp:189
Span< const char > initialData
Definition PipelineState.hpp:14
static const Blending GetAdditiveBlending()
Definition PipelineState.hpp:127
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Attachment::Blending::BlendFactor dstAlphaBlendFactor
static const Blending GetAlphaBlending()
Definition PipelineState.hpp:116
static const Blending GetNoBlending()
Definition PipelineState.hpp:115
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Attachment::Blending::BlendFactor dstColorBlendFactor
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Attachment::Blending::BlendFactor srcAlphaBlendFactor
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Attachment::Blending::BlendOp colorBlendOp
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Attachment::Blending::BlendFactor srcColorBlendFactor
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Attachment::Blending::BlendOp alphaBlendOp
struct Foundation::RHI::RHIPipelineState::PipelineStateDesc::Attachment::RenderTarget renderTarget
struct Foundation::RHI::RHIPipelineState::PipelineStateDesc::Attachment::Blending blending
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::DepthStencil::CompareOp Greater
RHIResourceFormat stencilFormat
Definition PipelineState.hpp:81
RHIResourceFormat depthFormat
Definition PipelineState.hpp:80
RHIMultisampleCount sampleCount
Definition PipelineState.hpp:76
RHIShaderStage stage
Definition PipelineState.hpp:163
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Rasterizer::FrontFace FFCounterClockwise
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Rasterizer::FillMode FillSolid
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Rasterizer::CullMode CullBack
Span< const char > specializationData
Definition PipelineState.hpp:154
struct Foundation::RHI::RHIPipelineState::PipelineStateDesc::ShaderStage::StageDesc desc
RHIShaderModule * shaderModule
Definition PipelineState.hpp:156
Span< const Binding > bindings
Definition PipelineState.hpp:35
Span< const RHIVertexAttribute > attributes
Definition PipelineState.hpp:36
struct Foundation::RHI::RHIPipelineState::PipelineStateDesc::Viewport viewport
struct Foundation::RHI::RHIPipelineState::PipelineStateDesc::DepthStencil depthStencil
Span< RHIDeviceDescriptorSetLayout *const > descriptorSetLayouts
Definition PipelineState.hpp:160
Span< const Attachment > attachments
Definition PipelineState.hpp:145
Span< const ShaderStage > shaderStages
Definition PipelineState.hpp:158
struct Foundation::RHI::RHIPipelineState::PipelineStateDesc::VertexInput vertexInput
Span< const PushConstant > pushConstants
Definition PipelineState.hpp:167
struct Foundation::RHI::RHIPipelineState::PipelineStateDesc::Rasterizer rasterizer
struct Foundation::RHI::RHIPipelineState::PipelineStateDesc::Scissor scissor
struct Foundation::RHI::RHIPipelineState::PipelineStateDesc::Multisample multisample
RHIPipelineStateCache * psoCache
Definition PipelineState.hpp:27
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Topology TriangleList
@ TriangleStrip
Definition PipelineState.hpp:43
@ PointList
Definition PipelineState.hpp:41
@ TriangleList
Definition PipelineState.hpp:42
RHIDevicePipelineType type
Definition PipelineState.hpp:28