Plasma Engine  2.0
Loading...
Searching...
No Matches
ResourceFormats.h
1
2#pragma once
3
4#include <RendererFoundation/RendererFoundationDLL.h>
5
6struct PL_RENDERERFOUNDATION_DLL plGALResourceFormat
7{
8 using StorageType = plUInt8;
9
10 enum Enum : plUInt8
11 {
12 Invalid = 0,
13
14 RGBAFloat,
15 XYZWFloat = RGBAFloat,
16 RGBAUInt,
17 RGBAInt,
18
19 RGBFloat,
20 XYZFloat = RGBFloat,
21 UVWFloat = RGBFloat,
22 RGBUInt,
23 RGBInt,
24
25 B5G6R5UNormalized,
26 BGRAUByteNormalized,
27 BGRAUByteNormalizedsRGB,
28
29 RGBAHalf,
30 XYZWHalf = RGBAHalf,
31 RGBAUShort,
32 RGBAUShortNormalized,
33 RGBAShort,
34 RGBAShortNormalized,
35
36 RGFloat,
37 XYFloat = RGFloat,
38 UVFloat = RGFloat,
39 RGUInt,
40 RGInt,
41
42 RGB10A2UInt,
43 RGB10A2UIntNormalized,
44 RG11B10Float,
45
46 RGBAUByteNormalized,
47 RGBAUByteNormalizedsRGB,
48 RGBAUByte,
49 RGBAByteNormalized,
50 RGBAByte,
51
52 RGHalf,
53 XYHalf = RGHalf,
54 UVHalf = RGHalf,
55 RGUShort,
56 RGUShortNormalized,
57 RGShort,
58 RGShortNormalized,
59 RGUByte,
60 RGUByteNormalized,
61 RGByte,
62 RGByteNormalized,
63
64 DFloat,
65
66 RFloat,
67 RUInt,
68 RInt,
69 RHalf,
70 RUShort,
71 RUShortNormalized,
72 RShort,
73 RShortNormalized,
74 RUByte,
75 RUByteNormalized,
76 RByte,
77 RByteNormalized,
78
79 AUByteNormalized,
80
81 D16,
82 D24S8,
83
84 BC1,
85 BC1sRGB,
86 BC2,
87 BC2sRGB,
88 BC3,
89 BC3sRGB,
90 BC4UNormalized,
91 BC4Normalized,
92 BC5UNormalized,
93 BC5Normalized,
94 BC6UFloat,
95 BC6Float,
96 BC7UNormalized,
97 BC7UNormalizedsRGB,
98
99 ENUM_COUNT,
100
101 Default = RGBAUByteNormalizedsRGB
102 };
103
104
105 // General format Meta-Informations:
106
108 static plUInt32 GetBitsPerElement(plGALResourceFormat::Enum format);
109
111 static plUInt8 GetChannelCount(plGALResourceFormat::Enum format);
112
114 // Would be very useful for some GL stuff and Testing.
115
117 static bool IsDepthFormat(plGALResourceFormat::Enum format);
118 static bool IsStencilFormat(plGALResourceFormat::Enum format);
119
120 static bool IsSrgb(plGALResourceFormat::Enum format);
121
123 static bool IsIntegerFormat(plGALResourceFormat::Enum format);
124
126 static bool IsSignedFormat(plGALResourceFormat::Enum format);
127
128private:
129 static const plUInt8 s_BitsPerElement[plGALResourceFormat::ENUM_COUNT];
130
131 static const plUInt8 s_ChannelCount[plGALResourceFormat::ENUM_COUNT];
132};
133
134template <typename NativeFormatType, NativeFormatType InvalidFormat>
136{
137public:
138 inline plGALFormatLookupEntry();
139
140 inline plGALFormatLookupEntry(NativeFormatType storage);
141
142 inline plGALFormatLookupEntry<NativeFormatType, InvalidFormat>& RT(NativeFormatType renderTargetType);
143
144 inline plGALFormatLookupEntry<NativeFormatType, InvalidFormat>& D(NativeFormatType depthOnlyType);
145
146 inline plGALFormatLookupEntry<NativeFormatType, InvalidFormat>& S(NativeFormatType stencilOnlyType);
147
148 inline plGALFormatLookupEntry<NativeFormatType, InvalidFormat>& DS(NativeFormatType depthStencilType);
149
150 inline plGALFormatLookupEntry<NativeFormatType, InvalidFormat>& VA(NativeFormatType vertexAttributeType);
151
152 inline plGALFormatLookupEntry<NativeFormatType, InvalidFormat>& RV(NativeFormatType resourceViewType);
153
154 NativeFormatType m_eStorage;
155 NativeFormatType m_eRenderTarget;
156 NativeFormatType m_eDepthOnlyType;
157 NativeFormatType m_eStencilOnlyType;
158 NativeFormatType m_eDepthStencilType;
159 NativeFormatType m_eVertexAttributeType;
160 NativeFormatType m_eResourceViewType;
161};
162
163// Reusable table class to store lookup information (from plGALResourceFormat to the various formats for texture/buffer storage, views)
164template <typename FormatClass>
166{
167public:
169
170 PL_ALWAYS_INLINE const FormatClass& GetFormatInfo(plGALResourceFormat::Enum format) const;
171
172 PL_ALWAYS_INLINE void SetFormatInfo(plGALResourceFormat::Enum format, const FormatClass& newFormatInfo);
173
174private:
175 FormatClass m_Formats[plGALResourceFormat::ENUM_COUNT];
176};
177
178#include <RendererFoundation/Resources/Implementation/ResourceFormats_inl.h>
Definition ResourceFormats.h:136
Definition ResourceFormats.h:166
Definition ResourceFormats.h:7