UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PixelFormat.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4#pragma once
5
6#include "CoreTypes.h"
8
9#if defined(PF_MAX)
10#undef PF_MAX
11#endif
12
14
16{
20 PF_G8 =3, // G8 means Gray/Grey , not Green , typically actually uses a red format with replication of R to RGB
21 PF_G16 =4, // G16 means Gray/Grey like G8
26 PF_FloatRGB =9, // FloatRGB == PF_FloatR11G11B10 , NOT 16F usually, but varies
27 PF_FloatRGBA =10, // RGBA16F
37 PF_D24 =20,
40 PF_BC5 =23,
42 PF_A1 =25,
44 PF_A8 =27,
55 PF_A8R8G8B8 =38, // Only used for legacy loading; do NOT use!
56 PF_BC4 =39,
57 PF_R8G8 =40,
58 PF_ATC_RGB =41, // Unsupported Format
59 PF_ATC_RGBA_E =42, // Unsupported Format
60 PF_ATC_RGBA_I =43, // Unsupported Format
61 PF_X24_G8 =44, // Used for creating SRVs to alias a DepthStencil buffer to read Stencil. Don't use for creating textures.
62 PF_ETC1 =45, // Unsupported Format
67 PF_ASTC_4x4 =50, // 8.00 bpp
68 PF_ASTC_6x6 =51, // 3.56 bpp
69 PF_ASTC_8x8 =52, // 2.00 bpp
70 PF_ASTC_10x10 =53, // 1.28 bpp
71 PF_ASTC_12x12 =54, // 0.89 bpp
73 PF_BC7 =56,
75 PF_L8 =58,
82 PF_PLATFORM_HDR_1 =65, // Reserved.
83 PF_PLATFORM_HDR_2 =66, // Reserved.
88 PF_R8 =71,
104 PF_ASTC_4x4_NORM_RG =87, // RG format stored in LA endpoints for better precision (requires RHI support for texture swizzle)
112};
113#define FOREACH_ENUM_EPIXELFORMAT(op) \
114 op(PF_Unknown) \
115 op(PF_A32B32G32R32F) \
116 op(PF_B8G8R8A8) \
117 op(PF_G8) \
118 op(PF_G16) \
119 op(PF_DXT1) \
120 op(PF_DXT3) \
121 op(PF_DXT5) \
122 op(PF_UYVY) \
123 op(PF_FloatRGB) \
124 op(PF_FloatRGBA) \
125 op(PF_DepthStencil) \
126 op(PF_ShadowDepth) \
127 op(PF_R32_FLOAT) \
128 op(PF_G16R16) \
129 op(PF_G16R16F) \
130 op(PF_G16R16F_FILTER) \
131 op(PF_G32R32F) \
132 op(PF_A2B10G10R10) \
133 op(PF_A16B16G16R16) \
134 op(PF_D24) \
135 op(PF_R16F) \
136 op(PF_R16F_FILTER) \
137 op(PF_BC5) \
138 op(PF_V8U8) \
139 op(PF_A1) \
140 op(PF_FloatR11G11B10) \
141 op(PF_A8) \
142 op(PF_R32_UINT) \
143 op(PF_R32_SINT) \
144 op(PF_PVRTC2) \
145 op(PF_PVRTC4) \
146 op(PF_R16_UINT) \
147 op(PF_R16_SINT) \
148 op(PF_R16G16B16A16_UINT) \
149 op(PF_R16G16B16A16_SINT) \
150 op(PF_R5G6B5_UNORM) \
151 op(PF_R8G8B8A8) \
152 op(PF_A8R8G8B8) \
153 op(PF_BC4) \
154 op(PF_R8G8) \
155 op(PF_ATC_RGB) \
156 op(PF_ATC_RGBA_E) \
157 op(PF_ATC_RGBA_I) \
158 op(PF_X24_G8) \
159 op(PF_ETC1) \
160 op(PF_ETC2_RGB) \
161 op(PF_ETC2_RGBA) \
162 op(PF_R32G32B32A32_UINT) \
163 op(PF_R16G16_UINT) \
164 op(PF_ASTC_4x4) \
165 op(PF_ASTC_6x6) \
166 op(PF_ASTC_8x8) \
167 op(PF_ASTC_10x10) \
168 op(PF_ASTC_12x12) \
169 op(PF_BC6H) \
170 op(PF_BC7) \
171 op(PF_R8_UINT) \
172 op(PF_L8) \
173 op(PF_XGXR8) \
174 op(PF_R8G8B8A8_UINT) \
175 op(PF_R8G8B8A8_SNORM) \
176 op(PF_R16G16B16A16_UNORM) \
177 op(PF_R16G16B16A16_SNORM) \
178 op(PF_PLATFORM_HDR_0) \
179 op(PF_PLATFORM_HDR_1) \
180 op(PF_PLATFORM_HDR_2) \
181 op(PF_NV12) \
182 op(PF_R32G32_UINT) \
183 op(PF_ETC2_R11_EAC) \
184 op(PF_ETC2_RG11_EAC) \
185 op(PF_R8) \
186 op(PF_B5G5R5A1_UNORM) \
187 op(PF_ASTC_4x4_HDR) \
188 op(PF_ASTC_6x6_HDR) \
189 op(PF_ASTC_8x8_HDR) \
190 op(PF_ASTC_10x10_HDR) \
191 op(PF_ASTC_12x12_HDR) \
192 op(PF_G16R16_SNORM) \
193 op(PF_R8G8_UINT) \
194 op(PF_R32G32B32_UINT) \
195 op(PF_R32G32B32_SINT) \
196 op(PF_R32G32B32F) \
197 op(PF_R8_SINT) \
198 op(PF_R64_UINT) \
199 op(PF_R9G9B9EXP5) \
200 op(PF_P010) \
201 op(PF_ASTC_4x4_NORM_RG) \
202 op(PF_ASTC_6x6_NORM_RG) \
203 op(PF_ASTC_8x8_NORM_RG) \
204 op(PF_ASTC_10x10_NORM_RG) \
205 op(PF_ASTC_12x12_NORM_RG) \
206 op(PF_R8G8B8)\
207 op(PF_R16G16_SINT)
208
209// Defines which channel is valid for each pixel format
211{
212 R = 1 << 0,
213 G = 1 << 1,
214 B = 1 << 2,
215 A = 1 << 3,
216 RG = R | G,
217 RGB = R | G | B,
218 RGBA = R | G | B | A,
219
220 None = 0,
221};
223
225{
226 None = 0,
227 Texture1D = 1ull << 1,
228 Texture2D = 1ull << 2,
229 Texture3D = 1ull << 3,
230 TextureCube = 1ull << 4,
231 RenderTarget = 1ull << 5,
232 DepthStencil = 1ull << 6,
233 TextureMipmaps = 1ull << 7,
234 TextureLoad = 1ull << 8,
235 TextureSample = 1ull << 9,
236 TextureGather = 1ull << 10,
237 TextureAtomics = 1ull << 11,
238 TextureBlendable = 1ull << 12,
239 TextureStore = 1ull << 13,
240
241 Buffer = 1ull << 14,
242 VertexBuffer = 1ull << 15,
243 IndexBuffer = 1ull << 16,
244 BufferLoad = 1ull << 17,
245 BufferStore = 1ull << 18,
246 BufferAtomics = 1ull << 19,
247
248 UAV = 1ull << 20,
249 TypedUAVLoad = 1ull << 21,
250 TypedUAVStore = 1ull << 22,
251
252 TextureFilterable = 1ull << 23,
253 LossyCompressible = 1ull << 24,
254
256
260
262};
264
265// EPixelFormat is currently used interchangably with uint8, and most call sites taking a uint8
266// should be updated to take an EPixelFormat instead, but in the interim this allows fixing
267// type conversion warnings
268#define UE_PIXELFORMAT_TO_UINT8(argument) static_cast<uint8>(argument)
269
271{
273 switch (PixelFormat)
274 {
275 case PF_ETC2_RGB:
276 case PF_ETC2_RGBA:
277 case PF_ETC2_R11_EAC:
278 case PF_ETC2_RG11_EAC:
279 return true;
280 }
282 return false;
283}
284
286{
288 switch (PixelFormat)
289 {
290 case PF_ASTC_4x4:
291 case PF_ASTC_6x6:
292 case PF_ASTC_8x8:
293 case PF_ASTC_10x10:
294 case PF_ASTC_12x12:
295 case PF_ASTC_4x4_HDR:
296 case PF_ASTC_6x6_HDR:
297 case PF_ASTC_8x8_HDR:
305 return true;
306 default:
307 return false;
308 }
310}
311
313{
315 switch (Format)
316 {
317 case PF_DXT1:
318 case PF_DXT3:
319 case PF_DXT5:
320 case PF_BC4:
321 case PF_BC5:
322 case PF_BC6H:
323 case PF_BC7:
324 return true;
325 }
327 return false;
328}
329
334
335// unclear what IsHDR is supposed to mean
336// see also IsFloatFormat
337inline bool IsHDR(EPixelFormat PixelFormat)
338{
339 return PixelFormat == PF_FloatRGBA || PixelFormat == PF_BC6H || PixelFormat == PF_R16F || PixelFormat == PF_R32_FLOAT || PixelFormat == PF_A32B32G32R32F
340 || PixelFormat == PF_ASTC_4x4_HDR || PixelFormat == PF_ASTC_6x6_HDR || PixelFormat == PF_ASTC_8x8_HDR || PixelFormat == PF_ASTC_10x10_HDR || PixelFormat == PF_ASTC_12x12_HDR;
341}
342
343inline bool IsInteger(EPixelFormat PixelFormat)
344{
346 switch (PixelFormat)
347 {
348 case PF_R32_UINT:
349 case PF_R32_SINT:
350 case PF_R16_UINT:
351 case PF_R16_SINT:
355 case PF_R16G16_UINT:
356 case PF_R8_UINT:
357 case PF_R8G8B8A8_UINT:
358 case PF_R32G32_UINT:
359 case PF_R8G8_UINT:
362 case PF_R8_SINT:
363 case PF_R64_UINT:
364 case PF_R16G16_SINT:
365 return true;
366 }
368 return false;
369}
370
371// IsFloatFormat does not include all floating point formats; see also IsHDR
373{
375 switch (Format)
376 {
377 case PF_A32B32G32R32F:
378 case PF_FloatRGB:
379 case PF_FloatRGBA:
380 case PF_R32_FLOAT:
381 case PF_G16R16F:
383 case PF_G32R32F:
384 case PF_R16F:
385 case PF_R16F_FILTER:
387 return true;
388 }
390 return false;
391}
392
394{
396 switch (Format)
397 {
398 case PF_D24:
399 case PF_DepthStencil:
400 case PF_X24_G8:
401 case PF_ShadowDepth:
402 case PF_R32_FLOAT:
403 return true;
404 }
406 return false;
407}
408
410{
412 switch (Format)
413 {
414 case PF_DepthStencil:
415 case PF_X24_G8:
416 return true;
417 }
419 return false;
420}
421
423{
425 switch (PixelFormat)
426 {
427 case PF_DXT1:
428 case PF_DXT3:
429 case PF_DXT5:
430 case PF_BC4:
431 case PF_BC5:
432 case PF_BC6H:
433 case PF_BC7:
434 return true;
435 default:
436 return false;
437 }
439}
440
442{
443 // BCN DXTC formats require 4x4 alignment, but ASTC/ETC do not
444 return IsDXTCBlockCompressedTextureFormat(PixelFormat);
445}
446
453{
457 const TCHAR* InName,
463 bool InSupported);
464
465 const TCHAR* Name;
472
475
478
481
482 // If false, 32 bit float is assumed (initialized by RHI module - invalid otherwise)
484
496
502};
503
504
517
518
519extern CORE_API FPixelFormatInfo GPixelFormats[PF_MAX]; // Maps members of EPixelFormat to a FPixelFormatInfo describing the format.
520
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
constexpr bool EnumHasAllFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:28
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
#define PRAGMA_DISABLE_SWITCH_UNHANDLED_ENUM_CASE_WARNINGS
Definition MSVCPlatformCompilerPreSetup.h:105
#define PRAGMA_RESTORE_SWITCH_UNHANDLED_ENUM_CASE_WARNINGS
Definition MSVCPlatformCompilerPreSetup.h:111
FPixelFormatInfo GPixelFormats[PF_MAX]
Definition PixelFormat.cpp:31
EPixelFormatCapabilities
Definition PixelFormat.h:225
bool IsASTCBlockCompressedTextureFormat(EPixelFormat PixelFormat)
Definition PixelFormat.h:285
CORE_API EPixelFormat GetPixelFormatFromString(const TCHAR *InPixelFormatStr)
Definition PixelFormat.cpp:261
bool IsBlockCompressedFormat(EPixelFormat Format)
Definition PixelFormat.h:312
bool IsDepthOrStencilFormat(EPixelFormat Format)
Definition PixelFormat.h:393
bool IsFloatFormat(EPixelFormat Format)
Definition PixelFormat.h:372
bool IsDXTCBlockCompressedTextureFormat(EPixelFormat PixelFormat)
Definition PixelFormat.h:422
CORE_API FPixelFormatInfo GPixelFormats[PF_MAX]
Definition PixelFormat.cpp:31
bool IsInteger(EPixelFormat PixelFormat)
Definition PixelFormat.h:343
bool IsETCBlockCompressedPixelFormat(EPixelFormat PixelFormat)
Definition PixelFormat.h:270
bool IsHDR(EPixelFormat PixelFormat)
Definition PixelFormat.h:337
CORE_API const TCHAR * GetPixelFormatString(EPixelFormat InPixelFormat)
Definition PixelFormat.cpp:251
bool IsStencilFormat(EPixelFormat Format)
Definition PixelFormat.h:409
UE_FORCEINLINE_HINT bool RequiresBlock4Alignment(EPixelFormat PixelFormat)
Definition PixelFormat.h:441
UE_FORCEINLINE_HINT bool IsAnyBlockCompressedPixelFormat(EPixelFormat PixelFormat)
Definition PixelFormat.h:330
EPixelFormat
Definition PixelFormat.h:16
@ PF_R8G8B8A8_UINT
Definition PixelFormat.h:77
@ PF_FloatRGBA
Definition PixelFormat.h:27
@ PF_R32G32_UINT
Definition PixelFormat.h:85
@ PF_R32G32B32_SINT
Definition PixelFormat.h:98
@ PF_G32R32F
Definition PixelFormat.h:34
@ PF_Unknown
Definition PixelFormat.h:17
@ PF_R16G16_SINT
Definition PixelFormat.h:109
@ PF_FloatR11G11B10
Definition PixelFormat.h:43
@ PF_R16F
Definition PixelFormat.h:38
@ PF_ATC_RGBA_I
Definition PixelFormat.h:60
@ PF_R8G8
Definition PixelFormat.h:57
@ PF_PLATFORM_HDR_2
Definition PixelFormat.h:83
@ PF_ASTC_12x12
Definition PixelFormat.h:71
@ PF_DepthStencil
Definition PixelFormat.h:28
@ PF_FloatRGB
Definition PixelFormat.h:26
@ PF_G16R16F
Definition PixelFormat.h:32
@ PF_B5G5R5A1_UNORM
Definition PixelFormat.h:89
@ PF_ASTC_6x6
Definition PixelFormat.h:68
@ PF_R16_SINT
Definition PixelFormat.h:50
@ PF_BC5
Definition PixelFormat.h:40
@ PF_R5G6B5_UNORM
Definition PixelFormat.h:53
@ PF_G16
Definition PixelFormat.h:21
@ PF_NV12
Definition PixelFormat.h:84
@ PF_MAX
Definition PixelFormat.h:111
@ PF_R32_FLOAT
Definition PixelFormat.h:30
@ PF_UYVY
Definition PixelFormat.h:25
@ PF_P010
Definition PixelFormat.h:103
@ PF_ASTC_8x8_HDR
Definition PixelFormat.h:92
@ PF_R16G16B16A16_SINT
Definition PixelFormat.h:52
@ PF_BC7
Definition PixelFormat.h:73
@ PF_PVRTC2
Definition PixelFormat.h:47
@ PF_ASTC_6x6_NORM_RG
Definition PixelFormat.h:105
@ PF_ETC2_RGBA
Definition PixelFormat.h:64
@ PF_ASTC_12x12_HDR
Definition PixelFormat.h:94
@ PF_ETC2_RG11_EAC
Definition PixelFormat.h:87
@ PF_DXT3
Definition PixelFormat.h:23
@ PF_R8G8B8
Definition PixelFormat.h:110
@ PF_ASTC_12x12_NORM_RG
Definition PixelFormat.h:108
@ PF_ATC_RGB
Definition PixelFormat.h:58
@ PF_ATC_RGBA_E
Definition PixelFormat.h:59
@ PF_V8U8
Definition PixelFormat.h:41
@ PF_ASTC_4x4_NORM_RG
Definition PixelFormat.h:104
@ PF_R8G8B8A8_SNORM
Definition PixelFormat.h:78
@ PF_R16G16B16A16_SNORM
Definition PixelFormat.h:80
@ PF_ETC2_R11_EAC
Definition PixelFormat.h:86
@ PF_A2B10G10R10
Definition PixelFormat.h:35
@ PF_DXT1
Definition PixelFormat.h:22
@ PF_PLATFORM_HDR_1
Definition PixelFormat.h:82
@ PF_R8_UINT
Definition PixelFormat.h:74
@ PF_G16R16_SNORM
Definition PixelFormat.h:95
@ PF_R64_UINT
Definition PixelFormat.h:101
@ PF_R16G16B16A16_UNORM
Definition PixelFormat.h:79
@ PF_R32G32B32_UINT
Definition PixelFormat.h:97
@ PF_R16G16_UINT
Definition PixelFormat.h:66
@ PF_R32_SINT
Definition PixelFormat.h:46
@ PF_R32_UINT
Definition PixelFormat.h:45
@ PF_R32G32B32A32_UINT
Definition PixelFormat.h:65
@ PF_ASTC_8x8
Definition PixelFormat.h:69
@ PF_L8
Definition PixelFormat.h:75
@ PF_ASTC_10x10_HDR
Definition PixelFormat.h:93
@ PF_G8
Definition PixelFormat.h:20
@ PF_BC4
Definition PixelFormat.h:56
@ PF_A8
Definition PixelFormat.h:44
@ PF_ASTC_10x10
Definition PixelFormat.h:70
@ PF_ASTC_4x4
Definition PixelFormat.h:67
@ PF_A32B32G32R32F
Definition PixelFormat.h:18
@ PF_R16F_FILTER
Definition PixelFormat.h:39
@ PF_D24
Definition PixelFormat.h:37
@ PF_ASTC_6x6_HDR
Definition PixelFormat.h:91
@ PF_R16G16B16A16_UINT
Definition PixelFormat.h:51
@ PF_ASTC_8x8_NORM_RG
Definition PixelFormat.h:106
@ PF_G16R16F_FILTER
Definition PixelFormat.h:33
@ PF_DXT5
Definition PixelFormat.h:24
@ PF_A16B16G16R16
Definition PixelFormat.h:36
@ PF_R8
Definition PixelFormat.h:88
@ PF_ASTC_4x4_HDR
Definition PixelFormat.h:90
@ PF_ShadowDepth
Definition PixelFormat.h:29
@ PF_R16_UINT
Definition PixelFormat.h:49
@ PF_B8G8R8A8
Definition PixelFormat.h:19
@ PF_ETC1
Definition PixelFormat.h:62
@ PF_R8G8B8A8
Definition PixelFormat.h:54
@ PF_X24_G8
Definition PixelFormat.h:61
@ PF_R32G32B32F
Definition PixelFormat.h:99
@ PF_XGXR8
Definition PixelFormat.h:76
@ PF_R8G8_UINT
Definition PixelFormat.h:96
@ PF_A1
Definition PixelFormat.h:42
@ PF_BC6H
Definition PixelFormat.h:72
@ PF_R8_SINT
Definition PixelFormat.h:100
@ PF_ETC2_RGB
Definition PixelFormat.h:63
@ PF_R9G9B9EXP5
Definition PixelFormat.h:102
@ PF_PVRTC4
Definition PixelFormat.h:48
@ PF_A8R8G8B8
Definition PixelFormat.h:55
@ PF_PLATFORM_HDR_0
Definition PixelFormat.h:81
@ PF_G16R16
Definition PixelFormat.h:31
@ PF_ASTC_10x10_NORM_RG
Definition PixelFormat.h:107
EPixelFormatChannelFlags
Definition PixelFormat.h:211
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition PixelFormat.h:522
bool HasCapabilities(EPixelFormat InFormat, EPixelFormatCapabilities InCapabilities)
Definition PixelFormat.h:523
Definition PixelFormat.h:453
FPixelFormatInfo()=delete
EPixelFormat UnrealFormat
Definition PixelFormat.h:466
EPixelFormatCapabilities Capabilities
Definition PixelFormat.h:474
CORE_API uint64 Get2DTextureSizeInBytes(uint32 InTextureWidth, uint32 InTextureHeight, uint32 InMipCount) const
Definition PixelFormat.cpp:227
CORE_API uint64 Get3DTextureSizeInBytes(uint32 InTextureWidth, uint32 InTextureHeight, uint32 InTextureDepth, uint32 InMipCount) const
Definition PixelFormat.cpp:170
int32 BlockSizeX
Definition PixelFormat.h:467
CORE_API uint64 Get2DImageSizeInBytes(uint32 InWidth, uint32 InHeight) const
Definition PixelFormat.cpp:213
int32 NumComponents
Definition PixelFormat.h:471
CORE_API uint64 Get2DTextureMipSizeInBytes(uint32 InTextureWidth, uint32 InTextureHeight, uint32 InMipIndex) const
Definition PixelFormat.cpp:220
uint8 Supported
Definition PixelFormat.h:480
CORE_API uint64 GetBlockCountForHeight(uint32 InHeight) const
Definition PixelFormat.cpp:200
const TCHAR * Name
Definition PixelFormat.h:465
int32 BlockBytes
Definition PixelFormat.h:470
uint32 PlatformFormat
Definition PixelFormat.h:477
int32 BlockSizeZ
Definition PixelFormat.h:469
int32 BlockSizeY
Definition PixelFormat.h:468
CORE_API uint64 Get3DTextureMipSizeInBytes(uint32 InTextureWidth, uint32 InTextureHeight, uint32 InTextureDepth, uint32 InMipIndex) const
Definition PixelFormat.cpp:162
CORE_API uint64 GetBlockCountForWidth(uint32 InWidth) const
Definition PixelFormat.cpp:186
CORE_API uint64 Get3DImageSizeInBytes(uint32 InWidth, uint32 InHeight, uint32 InDepth) const
Definition PixelFormat.cpp:153
uint8 bIs24BitUnormDepthStencil
Definition PixelFormat.h:483