Plasma Engine  2.0
Loading...
Searching...
No Matches
ShaderByteCode.h
1
2#pragma once
3
4#include <Foundation/Containers/DynamicArray.h>
5#include <Foundation/Types/RefCounted.h>
6#include <RendererFoundation/Descriptors/Enumerations.h>
7#include <RendererFoundation/RendererFoundationDLL.h>
8
11struct PL_RENDERERFOUNDATION_DLL plShaderConstant
12{
13 PL_DECLARE_MEM_RELOCATABLE_TYPE();
14
15 struct Type
16 {
17 using StorageType = plUInt8;
18
19 enum Enum
20 {
21 Default,
22 Float1,
23 Float2,
24 Float3,
25 Float4,
26 Int1,
27 Int2,
28 Int3,
29 Int4,
30 UInt1,
31 UInt2,
32 UInt3,
33 UInt4,
34 Mat3x3,
35 Mat4x4,
36 Transform,
37 Bool,
38 Struct,
39 ENUM_COUNT
40 };
41 };
42
43 static plUInt32 s_TypeSize[Type::ENUM_COUNT];
44
45 void CopyDataFormVariant(plUInt8* pDest, plVariant* pValue) const;
46
47 plHashedString m_sName;
48 plEnum<Type> m_Type;
49 plUInt8 m_uiArrayElements = 0;
50 plUInt16 m_uiOffset = 0;
51};
52
55class PL_RENDERERFOUNDATION_DLL plShaderConstantBufferLayout : public plRefCounted
56{
57public:
58 plUInt32 m_uiTotalSize = 0;
60};
61
65struct PL_RENDERERFOUNDATION_DLL plShaderVertexInputAttribute
66{
67 PL_DECLARE_MEM_RELOCATABLE_TYPE();
68
69 plEnum<plGALVertexAttributeSemantic> m_eSemantic = plGALVertexAttributeSemantic::Position;
70 plEnum<plGALResourceFormat> m_eFormat = plGALResourceFormat::XYZFloat;
71 plUInt8 m_uiLocation = 0; // The bind slot of a vertex input
72};
73
76struct PL_RENDERERFOUNDATION_DLL plShaderResourceBinding
77{
78 PL_DECLARE_MEM_RELOCATABLE_TYPE();
79 plEnum<plGALShaderResourceType> m_ResourceType; //< The type of shader resource. Note, not all are supported by PL right now.
80 plEnum<plGALShaderTextureType> m_TextureType; //< Only valid if m_ResourceType is Texture, TextureRW or TextureAndSampler.
81 plBitflags<plGALShaderStageFlags> m_Stages; //< The shader stages under which this resource is bound.
82 plInt16 m_iSet = -1; //< The set to which this resource belongs. Aka. Vulkan descriptor set.
83 plInt16 m_iSlot = -1; //< The slot under which the resource needs to be bound in the set.
84 plUInt32 m_uiArraySize = 1; //< Number of array elements. Only 1 is currently supported. 0 if bindless.
85 plHashedString m_sName; //< Name under which a resource must be bound to fulfill this resource binding.
86 plScopedRefPointer<plShaderConstantBufferLayout> m_pLayout; //< Only valid if plGALShaderResourceType is ConstantBuffer or PushConstants. #TODO_SHADER We could also support this for StructuredBuffer / StructuredBufferRW, but currently there is no use case for that.
87
88 static plResult CreateMergedShaderResourceBinding(const plArrayPtr<plArrayPtr<const plShaderResourceBinding>>& resourcesPerStage, plDynamicArray<plShaderResourceBinding>& out_bindings, bool bAllowMultipleBindingPerName);
89};
90
95class PL_RENDERERFOUNDATION_DLL plGALShaderByteCode : public plRefCounted
96{
97public:
100
101 inline const void* GetByteCode() const;
102 inline plUInt32 GetSize() const;
103 inline bool IsValid() const;
104
105public:
106 // Filled out by Shader Compiler platform implementation
107 plDynamicArray<plUInt8> m_ByteCode;
108 plHybridArray<plShaderResourceBinding, 8> m_ShaderResourceBindings;
110 // Only set in the hull shader.
111 plUInt8 m_uiTessellationPatchControlPoints = 0;
112
113 // Filled out by compiler base library
114 plEnum<plGALShaderStage> m_Stage = plGALShaderStage::ENUM_COUNT;
115 bool m_bWasCompiledWithDebug = false;
116};
117
118#include <RendererFoundation/Shader/Implementation/ShaderByteCode_inl.h>
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition DynamicArray.h:81
This class wraps shader byte code storage. Since byte code can have different requirements for alignm...
Definition ShaderByteCode.h:96
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Base class for reference counted objects.
Definition RefCounted.h:52
Stores a pointer to a reference counted object and automatically increases / decreases the reference ...
Definition RefCounted.h:65
Reflection data of a shader constant buffer.
Definition ShaderByteCode.h:56
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
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
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Definition ShaderByteCode.h:16
The reflection data of a constant in a shader constant buffer.
Definition ShaderByteCode.h:12
Shader reflection of a single shader resource (texture, constant buffer, etc.).
Definition ShaderByteCode.h:77
Shader reflection of the vertex shader input. This is needed to figure out how to map a plGALVertexDe...
Definition ShaderByteCode.h:66