Plasma Engine  2.0
Loading...
Searching...
No Matches
Descriptors.h
1
2#pragma once
3
4#include <Foundation/Algorithm/HashableStruct.h>
5#include <Foundation/Containers/HybridArray.h>
6#include <Foundation/Containers/StaticArray.h>
7#include <Foundation/Math/Color.h>
8#include <Foundation/Types/SharedPtr.h>
9#include <RendererFoundation/Descriptors/Enumerations.h>
10#include <RendererFoundation/RendererFoundationDLL.h>
11#include <RendererFoundation/Resources/ResourceFormats.h>
12#include <RendererFoundation/Shader/ShaderByteCode.h>
13#include <Texture/Image/ImageEnums.h>
14
15class plWindowBase;
16
17
18
19struct plGALWindowSwapChainCreationDescription : public plHashableStruct<plGALWindowSwapChainCreationDescription>
20{
21 plWindowBase* m_pWindow = nullptr;
22
23 // Describes the format that should be used for the backbuffer.
24 // Note however, that different platforms may enforce restrictions on this.
25 plGALMSAASampleCount::Enum m_SampleCount = plGALMSAASampleCount::None;
26 plGALResourceFormat::Enum m_BackBufferFormat = plGALResourceFormat::RGBAUByteNormalizedsRGB;
27 plEnum<plGALPresentMode> m_InitialPresentMode = plGALPresentMode::VSync;
28
29 bool m_bDoubleBuffered = true;
30 bool m_bAllowScreenshots = false;
31};
32
33struct plGALSwapChainCreationDescription : public plHashableStruct<plGALSwapChainCreationDescription>
34{
35 const plRTTI* m_pSwapChainType = nullptr;
36};
37
39{
40 bool m_bDebugDevice = false;
41};
42
43struct plGALShaderCreationDescription : public plHashableStruct<plGALShaderCreationDescription>
44{
47
48 bool HasByteCodeForStage(plGALShaderStage::Enum stage) const;
49
50 plSharedPtr<plGALShaderByteCode> m_ByteCodes[plGALShaderStage::ENUM_COUNT];
51};
52
53struct plGALRenderTargetBlendDescription : public plHashableStruct<plGALRenderTargetBlendDescription>
54{
55 plEnum<plGALBlend> m_SourceBlend = plGALBlend::One;
56 plEnum<plGALBlend> m_DestBlend = plGALBlend::One;
57 plEnum<plGALBlendOp> m_BlendOp = plGALBlendOp::Add;
58
59 plEnum<plGALBlend> m_SourceBlendAlpha = plGALBlend::One;
60 plEnum<plGALBlend> m_DestBlendAlpha = plGALBlend::One;
61 plEnum<plGALBlendOp> m_BlendOpAlpha = plGALBlendOp::Add;
62
63 plUInt8 m_uiWriteMask = 0xFF;
65 bool m_bBlendingEnabled = false;
67};
68
69struct plGALBlendStateCreationDescription : public plHashableStruct<plGALBlendStateCreationDescription>
70{
71 plGALRenderTargetBlendDescription m_RenderTargetBlendDescriptions[PL_GAL_MAX_RENDERTARGET_COUNT];
72
73 bool m_bAlphaToCoverage = false;
74 bool m_bIndependentBlend = false;
76};
77
78struct plGALStencilOpDescription : public plHashableStruct<plGALStencilOpDescription>
79{
80 plEnum<plGALStencilOp> m_FailOp = plGALStencilOp::Keep;
81 plEnum<plGALStencilOp> m_DepthFailOp = plGALStencilOp::Keep;
82 plEnum<plGALStencilOp> m_PassOp = plGALStencilOp::Keep;
83
84 plEnum<plGALCompareFunc> m_StencilFunc = plGALCompareFunc::Always;
85};
86
87struct plGALDepthStencilStateCreationDescription : public plHashableStruct<plGALDepthStencilStateCreationDescription>
88{
89 plGALStencilOpDescription m_FrontFaceStencilOp;
90 plGALStencilOpDescription m_BackFaceStencilOp;
91
92 plEnum<plGALCompareFunc> m_DepthTestFunc = plGALCompareFunc::Less;
93
96 bool m_bDepthTest = true;
97 bool m_bDepthWrite = true;
98 bool m_bStencilTest = false;
99 plUInt8 m_uiStencilReadMask = 0xFF;
100 plUInt8 m_uiStencilWriteMask = 0xFF;
101};
102
104struct plGALRasterizerStateCreationDescription : public plHashableStruct<plGALRasterizerStateCreationDescription>
105{
107 plInt32 m_iDepthBias = 0;
108 float m_fDepthBiasClamp = 0.0f;
110 bool m_bWireFrame = false;
113 bool m_bScissorTest = false;
115};
116
117struct plGALSamplerStateCreationDescription : public plHashableStruct<plGALSamplerStateCreationDescription>
118{
122
126
127 plEnum<plGALCompareFunc> m_SampleCompareFunc;
128
129 plColor m_BorderColor = plColor::Black;
130
131 float m_fMipLodBias = 0.0f;
132 float m_fMinMip = -1.0f;
133 float m_fMaxMip = 42000.0f;
134
135 plUInt32 m_uiMaxAnisotropy = 4;
136};
137
138struct PL_RENDERERFOUNDATION_DLL plGALVertexAttribute
139{
140 plGALVertexAttribute() = default;
141
142 plGALVertexAttribute(plGALVertexAttributeSemantic::Enum semantic, plGALResourceFormat::Enum format, plUInt16 uiOffset, plUInt8 uiVertexBufferSlot,
143 bool bInstanceData);
144
145 plGALVertexAttributeSemantic::Enum m_eSemantic = plGALVertexAttributeSemantic::Position;
146 plGALResourceFormat::Enum m_eFormat = plGALResourceFormat::XYZFloat;
147 plUInt16 m_uiOffset = 0;
148 plUInt8 m_uiVertexBufferSlot = 0;
149 bool m_bInstanceData = false;
150};
151
152struct PL_RENDERERFOUNDATION_DLL plGALVertexDeclarationCreationDescription : public plHashableStruct<plGALVertexDeclarationCreationDescription>
153{
154 plGALShaderHandle m_hShader;
156};
157
158// Need to add: immutable (GPU only), default(GPU only, but allows CopyToTempStorage updates), transient (allows plGALUpdateMode::Discard), staging: read(back), staging: write (constantly mapped), unified memory (mobile, onboard GPU, allows all ops)
159// Or use VmaMemoryUsage + read write flags?
161{
162 PL_ALWAYS_INLINE bool IsImmutable() const { return m_bImmutable; }
163
164 bool m_bReadBack = false;
165 bool m_bImmutable = true;
166};
167
168struct plGALBufferCreationDescription : public plHashableStruct<plGALBufferCreationDescription>
169{
170 plUInt32 m_uiTotalSize = 0;
171 plUInt32 m_uiStructSize = 0; // Struct or texel size
173 plGALResourceAccess m_ResourceAccess;
174};
175
176struct plGALTextureCreationDescription : public plHashableStruct<plGALTextureCreationDescription>
177{
178 void SetAsRenderTarget(plUInt32 uiWidth, plUInt32 uiHeight, plGALResourceFormat::Enum format, plGALMSAASampleCount::Enum sampleCount = plGALMSAASampleCount::None);
179
180 plUInt32 m_uiWidth = 0;
181 plUInt32 m_uiHeight = 0;
182 plUInt32 m_uiDepth = 1;
183 plUInt32 m_uiMipLevelCount = 1;
184 plUInt32 m_uiArraySize = 1;
185
186 plEnum<plGALResourceFormat> m_Format = plGALResourceFormat::Invalid;
187 plEnum<plGALMSAASampleCount> m_SampleCount = plGALMSAASampleCount::None;
188 plEnum<plGALTextureType> m_Type = plGALTextureType::Texture2D;
189
190 bool m_bAllowShaderResourceView = true;
191 bool m_bAllowUAV = false;
192 bool m_bCreateRenderTarget = false;
193 bool m_bAllowDynamicMipGeneration = false;
194
195 plGALResourceAccess m_ResourceAccess;
196
197 void* m_pExisitingNativeObject = nullptr;
198};
199
200struct plGALTextureResourceViewCreationDescription : public plHashableStruct<plGALTextureResourceViewCreationDescription>
201{
202 plGALTextureHandle m_hTexture;
203 plEnum<plGALResourceFormat> m_OverrideViewFormat = plGALResourceFormat::Invalid;
204 plUInt32 m_uiMostDetailedMipLevel = 0;
205 plUInt32 m_uiMipLevelsToUse = 0xFFFFFFFFu;
206 plUInt32 m_uiFirstArraySlice = 0; // For cubemap array: index of first 2d slice to start with
207 plUInt32 m_uiArraySize = 1; // For cubemap array: number of cubemaps
208};
209
210struct plGALBufferResourceViewCreationDescription : public plHashableStruct<plGALBufferResourceViewCreationDescription>
211{
212 plGALBufferHandle m_hBuffer;
213 plEnum<plGALResourceFormat> m_OverrideViewFormat = plGALResourceFormat::Invalid;
214 plUInt32 m_uiFirstElement = 0;
215 plUInt32 m_uiNumElements = 0;
216 bool m_bRawView = false;
217};
218
219struct plGALRenderTargetViewCreationDescription : public plHashableStruct<plGALRenderTargetViewCreationDescription>
220{
221 plGALTextureHandle m_hTexture;
222
223 plEnum<plGALResourceFormat> m_OverrideViewFormat = plGALResourceFormat::Invalid;
224
225 plUInt32 m_uiMipLevel = 0;
226
227 plUInt32 m_uiFirstSlice = 0;
228 plUInt32 m_uiSliceCount = 1;
229
230 bool m_bReadOnly = false;
231};
232
233struct plGALTextureUnorderedAccessViewCreationDescription : public plHashableStruct<plGALTextureUnorderedAccessViewCreationDescription>
234{
235 plGALTextureHandle m_hTexture;
236 plUInt32 m_uiFirstArraySlice = 0;
237 plUInt32 m_uiArraySize = 1;
238 plUInt16 m_uiMipLevelToUse = 0;
239 plEnum<plGALResourceFormat> m_OverrideViewFormat = plGALResourceFormat::Invalid;
240};
241
242struct plGALBufferUnorderedAccessViewCreationDescription : public plHashableStruct<plGALBufferUnorderedAccessViewCreationDescription>
243{
244 plGALBufferHandle m_hBuffer;
245 plUInt32 m_uiFirstElement = 0;
246 plUInt32 m_uiNumElements = 0;
247 plEnum<plGALResourceFormat> m_OverrideViewFormat = plGALResourceFormat::Invalid;
248 bool m_bRawView = false;
249};
250
253{
254 enum Type
255 {
256 AfterInit,
257 BeforeShutdown,
258 BeforeBeginFrame,
259 AfterBeginFrame,
260 BeforeEndFrame,
261 AfterEndFrame,
262 BeforeBeginCommands,
263 AfterBeginCommands,
264 BeforeEndCommands,
265 AfterEndCommands,
266 // could add resource creation/destruction events, if this would be useful
267 };
268
269 Type m_Type;
270 class plGALDevice* m_pDevice = nullptr;
271 plGALCommandEncoder* m_pCommandEncoder = nullptr;
272};
273
274// Opaque platform specific handle
275// Typically holds a platform specific handle for the texture and it's synchronization primitive
276struct plGALPlatformSharedHandle : public plHashableStruct<plGALPlatformSharedHandle>
277{
278 plUInt64 m_hSharedTexture = 0;
279 plUInt64 m_hSemaphore = 0;
280 plUInt32 m_uiProcessId = 0;
281 plUInt32 m_uiMemoryTypeIndex = 0;
282 plUInt64 m_uiSize = 0;
283};
284
285#include <RendererFoundation/Descriptors/Implementation/Descriptors_inl.h>
plColor represents an RGBA color in linear color space. Values are stored as float,...
Definition Color.h:44
static const plColor Black
#000000
Definition Color.h:57
Definition RendererFoundationDLL.h:418
Definition CommandEncoder.h:11
The plRenderDevice class is the primary interface for interactions with rendering APIs It contains a ...
Definition Device.h:19
Definition RendererFoundationDLL.h:404
Definition RendererFoundationDLL.h:411
This class provides a base class for hashable structs (e.g. descriptor objects).
Definition HashableStruct.h:17
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
A Shared ptr manages a shared object and destroys that object when no one references it anymore....
Definition SharedPtr.h:10
Wraps a C-style array, which has a fixed size at compile-time, with a more convenient interface.
Definition StaticArray.h:13
Base class of all window classes that have a client area and a native window handle.
Definition Window.h:134
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Definition Descriptors.h:70
bool m_bIndependentBlend
Definition Descriptors.h:74
bool m_bAlphaToCoverage
Alpha-to-coverage can only be used with MSAA render targets. Default is false.
Definition Descriptors.h:73
Definition Descriptors.h:169
Definition Descriptors.h:211
@ Back
Definition RendererFoundationDLL.h:310
bool m_bSeparateFrontAndBack
Definition Descriptors.h:94
Definition Descriptors.h:39
Type for important GAL events.
Definition Descriptors.h:253
Definition Descriptors.h:277
Describes the settings for a new rasterizer state. See plGALDevice::CreateRasterizerState.
Definition Descriptors.h:105
bool m_bWireFrame
Whether triangles are rendered filled or as wireframe. Default is false.
Definition Descriptors.h:110
bool m_bFrontCounterClockwise
Definition Descriptors.h:111
float m_fDepthBiasClamp
The pixel depth bias clamp. Default is 0.
Definition Descriptors.h:108
bool m_bConservativeRasterization
Whether conservative rasterization is enabled.
Definition Descriptors.h:114
float m_fSlopeScaledDepthBias
The pixel slope scaled depth bias clamp. Default is 0.
Definition Descriptors.h:109
plInt32 m_iDepthBias
The pixel depth bias. Default is 0.
Definition Descriptors.h:107
plEnum< plGALCullMode > m_CullMode
Which sides of a triangle to cull. Default is plGALCullMode::Back.
Definition Descriptors.h:106
Definition Descriptors.h:54
bool m_bBlendingEnabled
Definition Descriptors.h:65
plUInt8 m_uiWriteMask
Definition Descriptors.h:63
Definition Descriptors.h:220
bool m_bReadOnly
Can be used for depth stencil views to create read only views (e.g. for soft particles using the nati...
Definition Descriptors.h:230
Definition Descriptors.h:161
Definition Descriptors.h:118
Definition Descriptors.h:44
Definition Descriptors.h:79
Definition Descriptors.h:34
Definition Descriptors.h:177
void * m_pExisitingNativeObject
Can be used to encapsulate existing native textures in objects usable by the GAL.
Definition Descriptors.h:197
plUInt16 m_uiMipLevelToUse
Which MipLevel is accessed with this UAV.
Definition Descriptors.h:238
plUInt32 m_uiArraySize
Number of depth slices for 3D textures.
Definition Descriptors.h:237
plUInt32 m_uiFirstArraySlice
First depth slice for 3D Textures.
Definition Descriptors.h:236
Definition Descriptors.h:139
Definition Descriptors.h:153
Definition Descriptors.h:20