CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/GPU/DataFormat.h
Views: 1401
1
#pragma once
2
3
#include <cstdint>
4
#include <cstdlib>
5
6
namespace Draw {
7
8
enum class DataFormat : uint8_t {
9
UNDEFINED,
10
11
R8_UNORM,
12
R8G8_UNORM,
13
R8G8B8_UNORM,
14
15
R8G8B8A8_UNORM,
16
R8G8B8A8_UNORM_SRGB,
17
B8G8R8A8_UNORM, // D3D style
18
B8G8R8A8_UNORM_SRGB, // D3D style
19
20
R8G8B8A8_SNORM,
21
R8G8B8A8_UINT,
22
R8G8B8A8_SINT,
23
24
R4G4_UNORM_PACK8,
25
A4R4G4B4_UNORM_PACK16, // A4 in the UPPER bit
26
B4G4R4A4_UNORM_PACK16,
27
R4G4B4A4_UNORM_PACK16,
28
R5G6B5_UNORM_PACK16,
29
B5G6R5_UNORM_PACK16,
30
R5G5B5A1_UNORM_PACK16, // A1 in the LOWER bit
31
B5G5R5A1_UNORM_PACK16, // A1 in the LOWER bit
32
A1R5G5B5_UNORM_PACK16, // A1 in the UPPER bit.
33
A1B5G5R5_UNORM_PACK16, // A1 in the UPPER bit. OpenGL-only.
34
35
R16_UNORM,
36
37
R16_FLOAT,
38
R16G16_FLOAT,
39
R16G16B16A16_FLOAT,
40
41
R32_FLOAT,
42
R32G32_FLOAT,
43
R32G32B32_FLOAT,
44
R32G32B32A32_FLOAT,
45
46
// Block compression formats.
47
// These are modern names for DXT and friends, now patent free.
48
// https://msdn.microsoft.com/en-us/library/bb694531.aspx
49
BC1_RGBA_UNORM_BLOCK, // 64 bits per 4x4 block. Used by Basis, along with ETC2_R8G8B8_UNORM_BLOCK.
50
BC2_UNORM_BLOCK, // 4-bit straight alpha + DXT1 color. 128 bits per block. Usually not worth using
51
BC3_UNORM_BLOCK, // 3-bit alpha with 2 ref values (+ magic) + DXT1 color. 128 bits per block.
52
BC4_UNORM_BLOCK, // 1-channel, same storage as BC3 alpha. 64 bits per block.
53
BC5_UNORM_BLOCK, // 2-channel RG, each has same storage as BC3 alpha. 128 bits per block.
54
BC7_UNORM_BLOCK, // Highly advanced RGBA, very expensive to compress, very good quality. 128 bits per block.
55
56
// Ericsson texture compression.
57
ETC2_R8G8B8_UNORM_BLOCK, // Color-only, 64 bits per 4x4 block.
58
ETC2_R8G8B8A1_UNORM_BLOCK, // Color + alpha, 128 bits per 4x4 block.
59
ETC2_R8G8B8A8_UNORM_BLOCK, // Color + alpha, 128 bits per 4x4 block.
60
61
// This is the one ASTC format used by UASTC / basis Universal.
62
ASTC_4x4_UNORM_BLOCK,
63
64
S8,
65
D16,
66
D16_S8,
67
D24_S8,
68
D32F,
69
D32F_S8,
70
};
71
72
size_t DataFormatSizeInBytes(DataFormat fmt);
73
bool DataFormatIsDepthStencil(DataFormat fmt);
74
inline bool DataFormatIsColor(DataFormat fmt) {
75
return !DataFormatIsDepthStencil(fmt);
76
}
77
bool DataFormatIsBlockCompressed(DataFormat fmt, int *blockSize);
78
79
// Limited format support for now.
80
const char *DataFormatToString(DataFormat fmt);
81
82
void ConvertFromRGBA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);
83
void ConvertFromBGRA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);
84
void ConvertToD32F(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);
85
void ConvertToD16(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);
86
87
} // namespace
88
89