Cogs.Core
DataFormat.h
1#pragma once
2
3#include "Flags.h"
4
5namespace Cogs
6{
7 class StringView;
8
9 enum struct FormatFlags : uint32_t
10 {
11 None = 0,
12 Alpha = 1 << 0,
13 VertexFormat = 1 << 1,
14 Depth = 1 << 2,
15 Typeless = 1 << 3,
16 Integer = 1 << 4,
17 Unsigned = 1 << 5
18 };
19 COGS_RENDERING_ENABLE_ENUM_FLAGS(FormatFlags);
20
21 enum class Format : uint16_t
22 {
23 Unknown = 0,
24
25 // Unsigned normalized byte formats
26
27 R8_UNORM,
28 R8G8_UNORM,
29 R8G8B8_UNORM,
30 R8G8B8A8_UNORM,
31
32 // Unsigned 16 bit normalized integer formats
33
34 R16_UNORM,
35 R16G16_UNORM,
36 R16G16B16_UNORM,
37 R16G16B16A16_UNORM,
38
39 // Signed normalized byte formats
40
41 R8_SNORM,
42 R8G8_SNORM,
43 R8G8B8_SNORM,
44 R8G8B8A8_SNORM,
45
46 // Signed 16 bit normalized integer formats
47
48 R16_SNORM,
49 R16G16_SNORM,
50 R16G16B16_SNORM,
51 R16G16B16A16_SNORM,
52
53 // Unsigned byte formats
54
55 R8_UINT,
56 R8G8_UINT,
57 R8G8B8_UINT,
58 R8G8B8A8_UINT,
59
60 // Unsigned 16 bit integer formats
61
62 R16_UINT,
63 R16G16_UINT,
64 R16G16B16_UINT,
65 R16G16B16A16_UINT,
66
67 // Unsigned 32 bit integer formats
68
69 R32_UINT,
70 R32G32_UINT,
71 R32G32B32_UINT,
72 R32G32B32A32_UINT,
73
74 // Signed byte formats
75
76 R8_SINT,
77 R8G8_SINT,
78 R8G8B8_SINT,
79 R8G8B8A8_SINT,
80
81 // Signed 16 bit integer formats
82
83 R16_SINT,
84 R16G16_SINT,
85 R16G16B16_SINT,
86 R16G16B16A16_SINT,
87
88 // Signed 32 bit integer formats
89
90 R32_SINT,
91 R32G32_SINT,
92 R32G32B32_SINT,
93 R32G32B32A32_SINT,
94
95 // 16 bit floating point formats
96
97 R16_FLOAT,
98 R16G16_FLOAT,
99 R16G16B16_FLOAT,
100 R16G16B16A16_FLOAT,
101
102 // 32 bit floating point formats
103
104 R32_FLOAT,
105 R32G32_FLOAT,
106 R32G32B32_FLOAT,
107 R32G32B32A32_FLOAT,
108
109 // Depth buffer formats
110
111 D16_UNORM,
112 D24_UNORM,
113 D24S8_UNORM,
114 D32_FLOAT,
115 R32_TYPELESS,
116 R16_TYPELESS,
117
118 // 8 bit typeless formats
119
120 R8T,
121 R8G8T,
122 R8G8B8T,
123 R8G8B8A8T,
124
125 // Reverse component order formats.
126
127 B8G8R8,
128 B8G8R8A8,
129
130 // Alpha formats
131
132 A8_UNORM,
133
134 // Compressed formats
135
136 BC1_TYPELESS,
137 BC1_UNORM,
138 BC1_UNORM_SRGB,
139 BC2_TYPELESS,
140 BC2_UNORM,
141 BC2_UNORM_SRGB,
142 BC3_TYPELESS,
143 BC3_UNORM,
144 BC3_UNORM_SRGB,
145 BC4_TYPELESS,
146 BC4_UNORM,
147 BC4_SNORM,
148 BC5_TYPELESS,
149 BC5_UNORM,
150 BC5_SNORM,
151
152 // BC7
153
154 BC6H_SIGNED_FLOAT_RGB,
155 BC6H_UNSIGNED_FLOAT_RGB,
156 BC7_UNORM_RGBA,
157 BC7_UNORM_SRGBA,
158
159 // PRTVC_V1
160 PVRTC1_2BPP_UNORM_RGB,
161 PVRTC1_4BPP_UNORM_RGB,
162 PVRTC1_2BPP_UNORM_RGBA,
163 PVRTC1_4BPP_UNORM_RGBA,
164
165 // ETC
166 EAC_BLOCK8_UNSIGNED_FLOAT_R,
167 EAC_BLOCK8_SIGNED_FLOAT_R,
168 EAC_BLOCK16_UNSIGNED_FLOAT_RG,
169 EAC_BLOCK16_SIGNED_FLOAT_RG,
170
171 ETC2_BLOCK8_UNORM_RGB,
172 ETC2_BLOCK8_UNORM_SRGB,
173 ETC2_BLOCK16_UNORM_RGBA,
174 ETC2_BLOCK16_UNORM_SRGBA,
175
176 // ASTC
177 ASTC_4x4_UNORM_RGBA,
178 ASTC_5x4_UNORM_RGBA,
179 ASTC_5x5_UNORM_RGBA,
180 ASTC_6x5_UNORM_RGBA,
181 ASTC_6x6_UNORM_RGBA,
182 ASTC_8x5_UNORM_RGBA,
183 ASTC_8x6_UNORM_RGBA,
184 ASTC_8x8_UNORM_RGBA,
185 ASTC_10x5_UNORM_RGBA,
186 ASTC_10x6_UNORM_RGBA,
187 ASTC_10x8_UNORM_RGBA,
188 ASTC_10x10_UNORM_RGBA,
189 ASTC_12x10_UNORM_RGBA,
190 ASTC_12x12_UNORM_RGBA,
191 // ASTC SRGBA
192 ASTC_4x4_UNORM_SRGBA,
193 ASTC_5x4_UNORM_SRGBA,
194 ASTC_5x5_UNORM_SRGBA,
195 ASTC_6x5_UNORM_SRGBA,
196 ASTC_6x6_UNORM_SRGBA,
197 ASTC_8x5_UNORM_SRGBA,
198 ASTC_8x6_UNORM_SRGBA,
199 ASTC_8x8_UNORM_SRGBA,
200 ASTC_10x5_UNORM_SRGBA,
201 ASTC_10x6_UNORM_SRGBA,
202 ASTC_10x8_UNORM_SRGBA,
203 ASTC_10x10_UNORM_SRGBA,
204 ASTC_12x10_UNORM_SRGBA,
205 ASTC_12x12_UNORM_SRGBA,
206
207 // SRGB formats
208
209 R8G8B8_UNORM_SRGB,
210 R8G8B8A8_UNORM_SRGB,
211
212 // Packed formats
213
214 R10G10B10A2_TYPELESS,
215 R10G10B10A2_UNORM,
216 R10G10B10A2_UINT,
217 R11G11B10_FLOAT,
218 R5G6B5_UNORM,
219 R5G5B5A1_UNORM,
220 R4G4B4A4_UNORM,
221 R9G9B9E5_FLOAT,
222
223 // Matrix format for instancing
224
225 MAT4X4_FLOAT,
226
227 // Utility
228
229 Format_Size,
230 TextureFormat_Size = Format_Size,
231
232 // Format aliases
233
234 X16_FLOAT = R16_FLOAT,
235 X16Y16_FLOAT = R16G16_FLOAT,
236 X16Y16Z16_FLOAT = R16G16B16_FLOAT,
237 X16Y16Z16W16_FLOAT = R16G16B16A16_FLOAT,
238
239 X32_FLOAT = R32_FLOAT,
240 X32Y32_FLOAT = R32G32_FLOAT,
241 X32Y32Z32_FLOAT = R32G32B32_FLOAT,
242 X32Y32Z32W32_FLOAT = R32G32B32A32_FLOAT,
243 };
244
245 using DataFormat = Format;
246 using TextureFormat = Format;
247
249 {
250 uint32_t width = 0;
251 uint32_t height = 0;
252 uint32_t depth = 0;
253 };
254
256 {
257 uint8_t blockSize = 0;
259 uint16_t elements = 0;
260 const char * name = nullptr;
261 const char * vName = nullptr;
262 FormatFlags flags = FormatFlags::None;
263 };
264
265 COGSRENDERING_DLL_API const FormatInfo * getFormatInfo(Format format);
266
267 COGSRENDERING_DLL_API DataFormat parseDataFormat(const StringView& format);
268
269}
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
@ Depth
Render world-space distance from eye, scaled by 1/100 (so a value of 1 equals a distance of 100 units...
@ Alpha
Fetch elevation from alpha channel of elevation texture.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
@ None
Default flags.
uint16_t elements
Number of channels in a data item.
Definition: DataFormat.h:259
uint8_t blockSize
Bytesize of one block of data.
Definition: DataFormat.h:257
TextureExtent blockExtent
Number of data items in a block.
Definition: DataFormat.h:258
const char * vName
Name as a vertex format (using XYZW as channels).
Definition: DataFormat.h:261
const char * name
Name as a color format (using RGBA as channels).
Definition: DataFormat.h:260
FormatFlags flags
See FormatFlags.
Definition: DataFormat.h:262