Plasma Engine  2.0
Loading...
Searching...
No Matches
ImageFormat.h
1#pragma once
2
3#include <Foundation/Types/Types.h>
4#include <Texture/Image/ImageEnums.h>
5#include <Texture/TextureDLL.h>
6
8struct PL_TEXTURE_DLL plImageFormatType
9{
11 enum Enum
12 {
13 UNKNOWN,
14 LINEAR,
15 BLOCK_COMPRESSED,
16 PLANAR
17 };
18};
19
21struct PL_TEXTURE_DLL plImageFormatDataType
22{
24 enum Enum
25 {
26 FLOAT,
27 UINT,
28 SINT,
29 UNORM,
30 SNORM,
31 DEPTH_STENCIL,
32 GENERIC,
33 NONE
34 };
35};
36
38struct PL_TEXTURE_DLL plImageFormatChannel
39{
41 enum Enum
42 {
43 R = 0,
44 G,
45 B,
46 A,
47 D,
48 S,
49 COUNT
50 };
51};
52
54struct PL_TEXTURE_DLL plImageFormat
55{
67 enum Enum : plUInt16
68 {
69 UNKNOWN,
70
71 // 32b per component, 4 components
72 R32G32B32A32_FLOAT,
73 R32G32B32A32_UINT,
74 R32G32B32A32_SINT,
75
76 // 32b per component, 3 components
77 R32G32B32_FLOAT,
78 R32G32B32_UINT,
79 R32G32B32_SINT,
80
81 // 16b per component, 4 components
82 R16G16B16A16_FLOAT,
83 R16G16B16A16_UNORM,
84 R16G16B16A16_UINT,
85 R16G16B16A16_SNORM,
86 R16G16B16A16_SINT,
87
88 // 16b per component, 3 components
89 R16G16B16_UNORM,
90
91 // 32b per component, 2 components
92 R32G32_FLOAT,
93 R32G32_UINT,
94 R32G32_SINT,
95
96 // Pseudo depth-stencil formats
97 D32_FLOAT_S8X24_UINT,
98
99 // 10b and 11b per component
100 R10G10B10A2_UNORM,
101 R10G10B10A2_UINT,
102 R11G11B10_FLOAT,
103
104 // 8b per component, 4 components
105 R8G8B8A8_UNORM,
106 R8G8B8A8_UNORM_SRGB,
107 R8G8B8A8_UINT,
108 R8G8B8A8_SNORM,
109 R8G8B8A8_SINT,
110
111 B8G8R8A8_UNORM,
112 B8G8R8A8_UNORM_SRGB,
113 B8G8R8X8_UNORM,
114 B8G8R8X8_UNORM_SRGB,
115
116 // 16b per component, 2 components
117 R16G16_FLOAT,
118 R16G16_UNORM,
119 R16G16_UINT,
120 R16G16_SNORM,
121 R16G16_SINT,
122
123 // 32b per component, 1 component
124 D32_FLOAT,
125 R32_FLOAT,
126 R32_UINT,
127 R32_SINT,
128
129 // Mixed 24b/8b formats
130 D24_UNORM_S8_UINT,
131
132 // 8b per component, three components
133 R8G8B8_UNORM,
134 R8G8B8_UNORM_SRGB,
135 B8G8R8_UNORM,
136 B8G8R8_UNORM_SRGB,
137
138 // 8b per component, two components
139 R8G8_UNORM,
140 R8G8_UINT,
141 R8G8_SNORM,
142 R8G8_SINT,
143
144 // 16b per component, one component
145
146 R16_FLOAT,
147 D16_UNORM,
148 R16_UNORM,
149 R16_UINT,
150 R16_SNORM,
151 R16_SINT,
152
153 // 8b per component, one component
154 R8_UNORM,
155 R8_UINT,
156 R8_SNORM,
157 R8_SINT,
158
159 // Block compression formats
160 BC1_UNORM,
161 BC1_UNORM_SRGB,
162 BC2_UNORM,
163 BC2_UNORM_SRGB,
164 BC3_UNORM,
165 BC3_UNORM_SRGB,
166 BC4_UNORM,
167 BC4_SNORM,
168 BC5_UNORM,
169 BC5_SNORM,
170 BC6H_UF16,
171 BC6H_SF16,
172 BC7_UNORM,
173 BC7_UNORM_SRGB,
174
175 // ASTC formats
176 ASTC_4x4_UNORM,
177 ASTC_4x4_UNORM_SRGB,
178 ASTC_5x4_UNORM,
179 ASTC_5x4_UNORM_SRGB,
180 ASTC_5x5_UNORM,
181 ASTC_5x5_UNORM_SRGB,
182 ASTC_6x5_UNORM,
183 ASTC_6x5_UNORM_SRGB,
184 ASTC_6x6_UNORM,
185 ASTC_6x6_UNORM_SRGB,
186 ASTC_8x5_UNORM,
187 ASTC_8x5_UNORM_SRGB,
188 ASTC_8x6_UNORM,
189 ASTC_8x6_UNORM_SRGB,
190 ASTC_10x5_UNORM,
191 ASTC_10x5_UNORM_SRGB,
192 ASTC_10x6_UNORM,
193 ASTC_10x6_UNORM_SRGB,
194 ASTC_8x8_UNORM,
195 ASTC_8x8_UNORM_SRGB,
196 ASTC_10x8_UNORM,
197 ASTC_10x8_UNORM_SRGB,
198 ASTC_10x10_UNORM,
199 ASTC_10x10_UNORM_SRGB,
200 ASTC_12x10_UNORM,
201 ASTC_12x10_UNORM_SRGB,
202 ASTC_12x12_UNORM,
203 ASTC_12x12_UNORM_SRGB,
204
205 // 16bpp formats
206 B4G4R4A4_UNORM,
207 B4G4R4A4_UNORM_SRGB,
208 A4B4G4R4_UNORM,
209 A4B4G4R4_UNORM_SRGB,
210 B5G6R5_UNORM,
211 B5G6R5_UNORM_SRGB,
212 B5G5R5A1_UNORM,
213 B5G5R5A1_UNORM_SRGB,
214 B5G5R5X1_UNORM,
215 B5G5R5X1_UNORM_SRGB,
216 A1B5G5R5_UNORM,
217 A1B5G5R5_UNORM_SRGB,
218 X1B5G5R5_UNORM,
219 X1B5G5R5_UNORM_SRGB,
220
221 // Planar formats
222 NV12,
223
224 NUM_FORMATS,
225
226 Default = UNKNOWN
227 };
228
229 using StorageType = plUInt16;
230
234 static const char* GetName(Enum format);
235
237 static plUInt32 GetPlaneCount(Enum format);
238
241 static plUInt32 GetBitsPerPixel(Enum format, plUInt32 uiPlaneIndex = 0);
242
244 static float GetExactBitsPerPixel(Enum format, plUInt32 uiPlaneIndex = 0);
245
247 static plUInt32 GetBitsPerBlock(Enum format, plUInt32 uiPlaneIndex = 0);
248
250 static plUInt32 GetNumChannels(Enum format);
251
253 static plUInt32 GetChannelMask(Enum format, plImageFormatChannel::Enum c);
254
256 static plUInt32 GetBitsPerChannel(Enum format, plImageFormatChannel::Enum c);
257
259 static plUInt32 GetRedMask(Enum format);
260
262 static plUInt32 GetGreenMask(Enum format);
263
265 static plUInt32 GetBlueMask(Enum format);
266
268 static plUInt32 GetAlphaMask(Enum format);
269
271 static plUInt32 GetBlockWidth(Enum format, plUInt32 uiPlaneIndex = 0);
272
274 static plUInt32 GetBlockHeight(Enum format, plUInt32 uiPlaneIndex = 0);
275
277 static plUInt32 GetBlockDepth(Enum format, plUInt32 uiPlaneIndex = 0);
278
280 static plImageFormatDataType::Enum GetDataType(Enum format);
281
283 static bool IsCompressed(Enum format);
284
286 static bool IsDepth(Enum format);
287
289 static bool IsSrgb(Enum format);
290
292 static bool IsStencil(Enum format);
293
295 static Enum AsSrgb(Enum format);
296
298 static Enum AsLinear(Enum format);
299
301 static plUInt32 GetNumBlocksX(Enum format, plUInt32 uiWidth, plUInt32 uiPlaneIndex = 0);
302
304 static plUInt32 GetNumBlocksY(Enum format, plUInt32 uiHeight, plUInt32 uiPlaneIndex = 0);
305
307 static plUInt32 GetNumBlocksZ(Enum format, plUInt32 uiDepth, plUInt32 uiPlaneIndex = 0);
308
310 static plUInt64 GetRowPitch(Enum format, plUInt32 uiWidth, plUInt32 uiPlaneIndex = 0);
311
313 static plUInt64 GetDepthPitch(Enum format, plUInt32 uiWidth, plUInt32 uiHeight, plUInt32 uiPlaneIndex = 0);
314
316 static plImageFormatType::Enum GetType(Enum format);
317
319 static plImageFormat::Enum FromPixelMask(
320 plUInt32 uiRedMask, plUInt32 uiGreenMask, plUInt32 uiBlueMask, plUInt32 uiAlphaMask, plUInt32 uiBitsPerPixel);
321
323 static plImageFormat::Enum GetPlaneSubFormat(plImageFormat::Enum format, plUInt32 uiPlaneIndex);
324
326 static bool IsCompatible(Enum left, Enum right);
327
329 static bool RequiresFirstLevelBlockAlignment(Enum format);
330};
331
332PL_DEFINE_AS_POD_TYPE(plImageFormat::Enum);
Enum describing the channel of an image format.
Definition ImageFormat.h:39
Enum
Enum describing the channel of an image format.
Definition ImageFormat.h:42
Enum describing the channel type of an image format.
Definition ImageFormat.h:22
Enum
Enum describing the channel type of an image format.
Definition ImageFormat.h:25
Enum describing the encoding format of the pixels of an image.
Definition ImageFormat.h:55
Enum
Enum describing the encoding format of the pixels of an image.
Definition ImageFormat.h:68
Enum describing the type of an image format.
Definition ImageFormat.h:9
Enum
Enum describing the type of an image format.
Definition ImageFormat.h:12