1 /*
2 * Copyright (C) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifndef CORE_GL_UTIL_H
17 #define CORE_GL_UTIL_H
18
19 #include <base/util/formats.h>
20 #include <core/namespace.h>
21
22 CORE_BEGIN_NAMESPACE()
23
24 // Define Some GL enums so that this can be used even without gl headers.
25 constexpr unsigned int GL_NONE = 0x0;
26 constexpr unsigned int GL_INVALID_VALUE = 0x0501;
27
28 //
29 // 8 bits per component formats.
30 //
31 constexpr unsigned int GL_R8 = 0x8229;
32 constexpr unsigned int GL_RG8 = 0x822B;
33 constexpr unsigned int GL_RGB8 = 0x8051;
34 constexpr unsigned int GL_RGBA8 = 0x8058;
35 constexpr unsigned int GL_R8_SNORM = 0x8F94;
36 constexpr unsigned int GL_RG8_SNORM = 0x8F95;
37 constexpr unsigned int GL_RGB8_SNORM = 0x8F96;
38 constexpr unsigned int GL_RGBA8_SNORM = 0x8F97;
39 constexpr unsigned int GL_R8UI = 0x8232;
40 constexpr unsigned int GL_RG8UI = 0x8238;
41 constexpr unsigned int GL_RGB8UI = 0x8D7D;
42 constexpr unsigned int GL_RGBA8UI = 0x8D7C;
43 constexpr unsigned int GL_R8I = 0x8231;
44 constexpr unsigned int GL_RG8I = 0x8237;
45 constexpr unsigned int GL_RGB8I = 0x8D8F;
46 constexpr unsigned int GL_RGBA8I = 0x8D8E;
47 constexpr unsigned int GL_SR8 = 0x8FBD;
48 constexpr unsigned int GL_SRG8 = 0x8FBE;
49 constexpr unsigned int GL_SRGB8 = 0x8C41;
50 constexpr unsigned int GL_SRGB8_ALPHA8 = 0x8C43;
51
52 //
53 // 16 bits per component formats.
54 //
55 constexpr unsigned int GL_R16 = 0x822A;
56 constexpr unsigned int GL_RG16 = 0x822C;
57 constexpr unsigned int GL_RGB16 = 0x8054;
58 constexpr unsigned int GL_RGBA16 = 0x805B;
59 constexpr unsigned int GL_R16_SNORM = 0x8F98;
60 constexpr unsigned int GL_RG16_SNORM = 0x8F99;
61 constexpr unsigned int GL_RGB16_SNORM = 0x8F9A;
62 constexpr unsigned int GL_RGBA16_SNORM = 0x8F9B;
63
64 constexpr unsigned int GL_R16UI = 0x8234;
65 constexpr unsigned int GL_RG16UI = 0x823A;
66 constexpr unsigned int GL_RGB16UI = 0x8D77;
67 constexpr unsigned int GL_RGBA16UI = 0x8D76;
68
69 constexpr unsigned int GL_R16I = 0x8233;
70 constexpr unsigned int GL_RG16I = 0x8239;
71 constexpr unsigned int GL_RGB16I = 0x8D89;
72 constexpr unsigned int GL_RGBA16I = 0x8D88;
73
74 constexpr unsigned int GL_R16F = 0x822D;
75 constexpr unsigned int GL_RG16F = 0x822F;
76 constexpr unsigned int GL_RGB16F = 0x881B;
77 constexpr unsigned int GL_RGBA16F = 0x881A;
78
79 //
80 // 32 bits per component formats.
81 //
82 constexpr unsigned int GL_R32UI = 0x8236;
83 constexpr unsigned int GL_RG32UI = 0x823C;
84 constexpr unsigned int GL_RGB32UI = 0x8D71;
85 constexpr unsigned int GL_RGBA32UI = 0x8D70;
86
87 constexpr unsigned int GL_R32I = 0x8235;
88 constexpr unsigned int GL_RG32I = 0x823B;
89 constexpr unsigned int GL_RGB32I = 0x8D83;
90 constexpr unsigned int GL_RGBA32I = 0x8D82;
91
92 constexpr unsigned int GL_R32F = 0x822E;
93 constexpr unsigned int GL_RG32F = 0x8230;
94 constexpr unsigned int GL_RGB32F = 0x8815;
95 constexpr unsigned int GL_RGBA32F = 0x8814;
96
97 //
98 // Packed formats.
99 //
100 constexpr unsigned int GL_R3_G3_B2 = 0x2A10;
101 constexpr unsigned int GL_RGB4 = 0x804F;
102 constexpr unsigned int GL_RGB5 = 0x8050;
103 constexpr unsigned int GL_RGB565 = 0x8D62;
104 constexpr unsigned int GL_RGB10 = 0x8052;
105 constexpr unsigned int GL_RGB12 = 0x8053;
106 constexpr unsigned int GL_RGBA2 = 0x8055;
107 constexpr unsigned int GL_RGBA4 = 0x8056;
108 constexpr unsigned int GL_RGBA12 = 0x805A;
109 constexpr unsigned int GL_RGB5_A1 = 0x8057;
110 constexpr unsigned int GL_RGB10_A2 = 0x8059;
111 constexpr unsigned int GL_RGB10_A2UI = 0x906F;
112 constexpr unsigned int GL_R11F_G11F_B10F = 0x8C3A;
113 constexpr unsigned int GL_RGB9_E5 = 0x8C3D;
114
115 //
116 // Luminance formats.
117 //
118 constexpr unsigned int GL_LUMINANCE4 = 0x803F;
119 constexpr unsigned int GL_LUMINANCE8 = 0x8040;
120 constexpr unsigned int GL_LUMINANCE8_SNORM = 0x9015;
121 constexpr unsigned int GL_SLUMINANCE8 = 0x8C47;
122 constexpr unsigned int GL_LUMINANCE8UI_EXT = 0x8D80;
123 constexpr unsigned int GL_LUMINANCE8I_EXT = 0x8D92;
124 constexpr unsigned int GL_LUMINANCE12 = 0x8041;
125 constexpr unsigned int GL_LUMINANCE16 = 0x8042;
126 constexpr unsigned int GL_LUMINANCE16_SNORM = 0x9019;
127 constexpr unsigned int GL_LUMINANCE16UI_EXT = 0x8D7A;
128 constexpr unsigned int GL_LUMINANCE16I_EXT = 0x8D8C;
129 constexpr unsigned int GL_LUMINANCE16F_ARB = 0x881E;
130 constexpr unsigned int GL_LUMINANCE32UI_EXT = 0x8D74;
131 constexpr unsigned int GL_LUMINANCE32I_EXT = 0x8D86;
132 constexpr unsigned int GL_LUMINANCE32F_ARB = 0x8818;
133
134 //
135 // Luminance/Alpha
136 //
137 constexpr unsigned int GL_LUMINANCE4_ALPHA4 = 0x8043;
138 constexpr unsigned int GL_LUMINANCE6_ALPHA2 = 0x8044;
139 constexpr unsigned int GL_LUMINANCE8_ALPHA8 = 0x8045;
140 constexpr unsigned int GL_LUMINANCE8_ALPHA8_SNORM = 0x9016;
141 constexpr unsigned int GL_SLUMINANCE8_ALPHA8 = 0x8C45;
142 constexpr unsigned int GL_LUMINANCE_ALPHA8UI_EXT = 0x8D81;
143 constexpr unsigned int GL_LUMINANCE_ALPHA8I_EXT = 0x8D93;
144 constexpr unsigned int GL_LUMINANCE12_ALPHA4 = 0x8046;
145 constexpr unsigned int GL_LUMINANCE12_ALPHA12 = 0x8047;
146 constexpr unsigned int GL_LUMINANCE16_ALPHA16 = 0x8048;
147 constexpr unsigned int GL_LUMINANCE16_ALPHA16_SNORM = 0x901A;
148 constexpr unsigned int GL_LUMINANCE_ALPHA16UI_EXT = 0x8D7B;
149 constexpr unsigned int GL_LUMINANCE_ALPHA16I_EXT = 0x8D8D;
150 constexpr unsigned int GL_LUMINANCE_ALPHA16F_ARB = 0x881F;
151 constexpr unsigned int GL_LUMINANCE_ALPHA32UI_EXT = 0x8D75;
152 constexpr unsigned int GL_LUMINANCE_ALPHA32I_EXT = 0x8D87;
153 constexpr unsigned int GL_LUMINANCE_ALPHA32F_ARB = 0x8819;
154
155 //
156 // Intensity
157 //
158 constexpr unsigned int GL_INTENSITY4 = 0x804A;
159 constexpr unsigned int GL_INTENSITY8 = 0x804B;
160 constexpr unsigned int GL_INTENSITY8_SNORM = 0x9017;
161 constexpr unsigned int GL_INTENSITY8UI_EXT = 0x8D7F;
162 constexpr unsigned int GL_INTENSITY8I_EXT = 0x8D91;
163 constexpr unsigned int GL_INTENSITY12 = 0x804C;
164 constexpr unsigned int GL_INTENSITY16 = 0x804D;
165 constexpr unsigned int GL_INTENSITY16_SNORM = 0x901B;
166 constexpr unsigned int GL_INTENSITY16UI_EXT = 0x8D79;
167 constexpr unsigned int GL_INTENSITY16I_EXT = 0x8D8B;
168 constexpr unsigned int GL_INTENSITY16F_ARB = 0x881D;
169 constexpr unsigned int GL_INTENSITY32UI_EXT = 0x8D73;
170 constexpr unsigned int GL_INTENSITY32I_EXT = 0x8D85;
171 constexpr unsigned int GL_INTENSITY32F_ARB = 0x8817;
172
173 //
174 // Generic compressed.
175 //
176 constexpr unsigned int GL_COMPRESSED_RED = 0x8225;
177 constexpr unsigned int GL_COMPRESSED_ALPHA = 0x84E9;
178 constexpr unsigned int GL_COMPRESSED_LUMINANCE = 0x84EA;
179 constexpr unsigned int GL_COMPRESSED_SLUMINANCE = 0x8C4A;
180 constexpr unsigned int GL_COMPRESSED_LUMINANCE_ALPHA = 0x84EB;
181 constexpr unsigned int GL_COMPRESSED_SLUMINANCE_ALPHA = 0x8C4B;
182 constexpr unsigned int GL_COMPRESSED_INTENSITY = 0x84EC;
183 constexpr unsigned int GL_COMPRESSED_RG = 0x8226;
184 constexpr unsigned int GL_COMPRESSED_RGB = 0x84ED;
185 constexpr unsigned int GL_COMPRESSED_RGBA = 0x84EE;
186 constexpr unsigned int GL_COMPRESSED_SRGB = 0x8C48;
187 constexpr unsigned int GL_COMPRESSED_SRGB_ALPHA = 0x8C49;
188
189 //
190 // S3TC/DXT/BC compressed.
191 //
192 constexpr unsigned int GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
193 constexpr unsigned int GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
194 constexpr unsigned int GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
195 constexpr unsigned int GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
196
197 constexpr unsigned int GL_COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8C4C;
198 constexpr unsigned int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8C4D;
199 constexpr unsigned int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E;
200 constexpr unsigned int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F;
201
202 constexpr unsigned int GL_COMPRESSED_LUMINANCE_LATC1_EXT = 0x8C70;
203 constexpr unsigned int GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT = 0x8C72;
204 constexpr unsigned int GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT = 0x8C71;
205 constexpr unsigned int GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT = 0x8C73;
206
207 constexpr unsigned int GL_COMPRESSED_RED_RGTC1 = 0x8DBB;
208 constexpr unsigned int GL_COMPRESSED_RG_RGTC2 = 0x8DBD;
209 constexpr unsigned int GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC;
210 constexpr unsigned int GL_COMPRESSED_SIGNED_RG_RGTC2 = 0x8DBE;
211
212 constexpr unsigned int GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 0x8E8E;
213 constexpr unsigned int GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F;
214 constexpr unsigned int GL_COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C;
215 constexpr unsigned int GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM = 0x8E8D;
216
217 //
218 // ETC compressed.
219 //
220 constexpr unsigned int GL_ETC1_RGB8_OES = 0x8D64;
221
222 constexpr unsigned int GL_COMPRESSED_RGB8_ETC2 = 0x9274;
223 constexpr unsigned int GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276;
224 constexpr unsigned int GL_COMPRESSED_RGBA8_ETC2_EAC = 0x9278;
225
226 constexpr unsigned int GL_COMPRESSED_SRGB8_ETC2 = 0x9275;
227 constexpr unsigned int GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277;
228 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279;
229
230 constexpr unsigned int GL_COMPRESSED_R11_EAC = 0x9270;
231 constexpr unsigned int GL_COMPRESSED_RG11_EAC = 0x9272;
232 constexpr unsigned int GL_COMPRESSED_SIGNED_R11_EAC = 0x9271;
233 constexpr unsigned int GL_COMPRESSED_SIGNED_RG11_EAC = 0x9273;
234
235 //
236 // ASTC compressed.
237 //
238 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0;
239 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1;
240 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2;
241 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3;
242 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4;
243 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5;
244 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6;
245 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7;
246 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8;
247 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9;
248 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA;
249 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB;
250 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC;
251 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD;
252
253 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0;
254 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1;
255 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2;
256 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3;
257 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4;
258 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5;
259 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6;
260 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7;
261 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8;
262 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9;
263 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA;
264 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB;
265 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC;
266 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD;
267
268 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_3x3x3_OES = 0x93C0;
269 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_4x3x3_OES = 0x93C1;
270 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_4x4x3_OES = 0x93C2;
271 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_4x4x4_OES = 0x93C3;
272 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_5x4x4_OES = 0x93C4;
273 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_5x5x4_OES = 0x93C5;
274 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_5x5x5_OES = 0x93C6;
275 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_6x5x5_OES = 0x93C7;
276 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_6x6x5_OES = 0x93C8;
277 constexpr unsigned int GL_COMPRESSED_RGBA_ASTC_6x6x6_OES = 0x93C9;
278
279 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES = 0x93E0;
280 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES = 0x93E1;
281 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES = 0x93E2;
282 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES = 0x93E3;
283 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES = 0x93E4;
284 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES = 0x93E5;
285 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES = 0x93E6;
286 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES = 0x93E7;
287 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES = 0x93E8;
288 constexpr unsigned int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES = 0x93E9;
289
290 struct GlImageFormatInfo {
291 BASE_NS::Format coreFormat;
292 BASE_NS::Format coreFormatForceSrgb;
293 BASE_NS::Format coreFormatForceLinear;
294
295 unsigned int glFormat;
296
297 bool compressed;
298 uint8_t blockWidth;
299 uint8_t blockHeight;
300 uint8_t blockDepth;
301 uint32_t bitsPerBlock;
302 };
303
304 // NOTE: Only a subset of formats are supported. E.g. 3D formats are not listed.
305 static constexpr GlImageFormatInfo GL_IMAGE_FORMATS[] = {
306 // 8 bits per component.
307 { BASE_NS::Format::BASE_FORMAT_R8_UNORM, BASE_NS::Format::BASE_FORMAT_R8_SRGB,
308 BASE_NS::Format::BASE_FORMAT_R8_UNORM, GL_R8, false, 1, 1, 1, 8 },
309 { BASE_NS::Format::BASE_FORMAT_R8G8_UNORM, BASE_NS::Format::BASE_FORMAT_R8G8_SRGB,
310 BASE_NS::Format::BASE_FORMAT_R8G8_UNORM, GL_RG8, false, 1, 1, 1, 16 },
311 { BASE_NS::Format::BASE_FORMAT_R8G8B8_UNORM, BASE_NS::Format::BASE_FORMAT_R8G8B8_SRGB,
312 BASE_NS::Format::BASE_FORMAT_R8G8B8_UNORM, GL_RGB8, false, 1, 1, 1, 24 },
313 { BASE_NS::Format::BASE_FORMAT_R8G8B8A8_UNORM, BASE_NS::Format::BASE_FORMAT_R8G8B8A8_SRGB,
314 BASE_NS::Format::BASE_FORMAT_R8G8B8A8_UNORM, GL_RGBA8, false, 1, 1, 1, 32 },
315
316 { BASE_NS::Format::BASE_FORMAT_R8_UINT, BASE_NS::Format::BASE_FORMAT_R8_SRGB, BASE_NS::Format::BASE_FORMAT_R8_UINT,
317 GL_R8UI, false, 1, 1, 1, 8 },
318 { BASE_NS::Format::BASE_FORMAT_R8G8_UINT, BASE_NS::Format::BASE_FORMAT_R8G8_SRGB,
319 BASE_NS::Format::BASE_FORMAT_R8G8_UINT, GL_RG8UI, false, 1, 1, 1, 16 },
320 { BASE_NS::Format::BASE_FORMAT_R8G8B8_UINT, BASE_NS::Format::BASE_FORMAT_R8G8B8_SRGB,
321 BASE_NS::Format::BASE_FORMAT_R8G8B8_UINT, GL_RGB8UI, false, 1, 1, 1, 24 },
322 { BASE_NS::Format::BASE_FORMAT_R8G8B8A8_UINT, BASE_NS::Format::BASE_FORMAT_R8G8B8A8_SRGB,
323 BASE_NS::Format::BASE_FORMAT_R8G8B8A8_UINT, GL_RGBA8UI, false, 1, 1, 1, 32 },
324
325 { BASE_NS::Format::BASE_FORMAT_R8_SINT, BASE_NS::Format::BASE_FORMAT_R8_SRGB, BASE_NS::Format::BASE_FORMAT_R8_SINT,
326 GL_R8I, false, 1, 1, 1, 8 },
327 { BASE_NS::Format::BASE_FORMAT_R8G8_SINT, BASE_NS::Format::BASE_FORMAT_R8G8_SRGB,
328 BASE_NS::Format::BASE_FORMAT_R8G8_SINT, GL_RG8I, false, 1, 1, 1, 16 },
329 { BASE_NS::Format::BASE_FORMAT_R8G8B8_SINT, BASE_NS::Format::BASE_FORMAT_R8G8B8_SRGB,
330 BASE_NS::Format::BASE_FORMAT_R8G8B8_SINT, GL_RGB8I, false, 1, 1, 1, 24 },
331 { BASE_NS::Format::BASE_FORMAT_R8G8B8A8_SINT, BASE_NS::Format::BASE_FORMAT_R8G8B8A8_SRGB,
332 BASE_NS::Format::BASE_FORMAT_R8G8B8A8_SINT, GL_RGBA8I, false, 1, 1, 1, 32 },
333
334 { BASE_NS::Format::BASE_FORMAT_R8_SRGB, BASE_NS::Format::BASE_FORMAT_R8_SRGB, BASE_NS::Format::BASE_FORMAT_R8_UNORM,
335 GL_SR8, false, 1, 1, 1, 8 },
336 { BASE_NS::Format::BASE_FORMAT_R8G8_SRGB, BASE_NS::Format::BASE_FORMAT_R8G8_SRGB,
337 BASE_NS::Format::BASE_FORMAT_R8G8_UNORM, GL_SRG8, false, 1, 1, 1, 16 },
338 { BASE_NS::Format::BASE_FORMAT_R8G8B8_SRGB, BASE_NS::Format::BASE_FORMAT_R8G8B8_SRGB,
339 BASE_NS::Format::BASE_FORMAT_R8G8B8_UNORM, GL_SRGB8, false, 1, 1, 1, 24 },
340 { BASE_NS::Format::BASE_FORMAT_R8G8B8A8_SRGB, BASE_NS::Format::BASE_FORMAT_R8G8B8A8_SRGB,
341 BASE_NS::Format::BASE_FORMAT_R8G8B8A8_UNORM, GL_SRGB8_ALPHA8, false, 1, 1, 1, 32 },
342
343 // 16 bits per component.
344 { BASE_NS::Format::BASE_FORMAT_R16_UNORM, BASE_NS::Format::BASE_FORMAT_R16_UNORM,
345 BASE_NS::Format::BASE_FORMAT_R16_UNORM, GL_R16, false, 1, 1, 1, 16 },
346 { BASE_NS::Format::BASE_FORMAT_R16G16_UNORM, BASE_NS::Format::BASE_FORMAT_R16G16_UNORM,
347 BASE_NS::Format::BASE_FORMAT_R16G16_UNORM, GL_RG16, false, 1, 1, 1, 32 },
348 { BASE_NS::Format::BASE_FORMAT_R16G16B16_UNORM, BASE_NS::Format::BASE_FORMAT_R16G16B16_UNORM,
349 BASE_NS::Format::BASE_FORMAT_R16G16B16_UNORM, GL_RGB16, false, 1, 1, 1, 48 },
350 { BASE_NS::Format::BASE_FORMAT_R16G16B16A16_UNORM, BASE_NS::Format::BASE_FORMAT_R16G16B16A16_UNORM,
351 BASE_NS::Format::BASE_FORMAT_R16G16B16A16_UNORM, GL_RGBA16, false, 1, 1, 1, 64 },
352
353 { BASE_NS::Format::BASE_FORMAT_R16_SFLOAT, BASE_NS::Format::BASE_FORMAT_R16_UNORM,
354 BASE_NS::Format::BASE_FORMAT_R16_UNORM, GL_R16F, false, 1, 1, 1, 16 },
355 { BASE_NS::Format::BASE_FORMAT_R16G16_SFLOAT, BASE_NS::Format::BASE_FORMAT_R16G16_SFLOAT,
356 BASE_NS::Format::BASE_FORMAT_R16G16_SFLOAT, GL_RG16F, false, 1, 1, 1, 32 },
357 { BASE_NS::Format::BASE_FORMAT_R16G16B16_SFLOAT, BASE_NS::Format::BASE_FORMAT_R16G16B16_SFLOAT,
358 BASE_NS::Format::BASE_FORMAT_R16G16B16_SFLOAT, GL_RGB16F, false, 1, 1, 1, 48 },
359 { BASE_NS::Format::BASE_FORMAT_R16G16B16A16_SFLOAT, BASE_NS::Format::BASE_FORMAT_R16G16B16A16_SFLOAT,
360 BASE_NS::Format::BASE_FORMAT_R16G16B16A16_SFLOAT, GL_RGBA16F, false, 1, 1, 1, 64 },
361
362 // 32 bits per component.
363 { BASE_NS::Format::BASE_FORMAT_R32_SFLOAT, BASE_NS::Format::BASE_FORMAT_R32_SFLOAT,
364 BASE_NS::Format::BASE_FORMAT_R32_SFLOAT, GL_R32F, false, 1, 1, 1, 32 },
365 { BASE_NS::Format::BASE_FORMAT_R32G32_SFLOAT, BASE_NS::Format::BASE_FORMAT_R32G32_SFLOAT,
366 BASE_NS::Format::BASE_FORMAT_R32G32_SFLOAT, GL_RG32F, false, 1, 1, 1, 64 },
367 { BASE_NS::Format::BASE_FORMAT_R32G32B32_SFLOAT, BASE_NS::Format::BASE_FORMAT_R32G32B32_SFLOAT,
368 BASE_NS::Format::BASE_FORMAT_R32G32B32_SFLOAT, GL_RGB32F, false, 1, 1, 1, 96 },
369 { BASE_NS::Format::BASE_FORMAT_R32G32B32A32_SFLOAT, BASE_NS::Format::BASE_FORMAT_R32G32B32A32_SFLOAT,
370 BASE_NS::Format::BASE_FORMAT_R32G32B32A32_SFLOAT, GL_RGBA32F, false, 1, 1, 1, 128 },
371
372 // Packed formats.
373 { BASE_NS::Format::BASE_FORMAT_B10G11R11_UFLOAT_PACK32, BASE_NS::Format::BASE_FORMAT_B10G11R11_UFLOAT_PACK32,
374 BASE_NS::Format::BASE_FORMAT_B10G11R11_UFLOAT_PACK32, GL_R11F_G11F_B10F, false, 1, 1, 1, 32 },
375
376 // Compressed formats.
377 { BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
378 BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, GL_ETC1_RGB8_OES, true, 4, 4, 1,
379 64 }, // ETC1 is compatible with ETC2
380
381 { BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
382 BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, GL_COMPRESSED_RGB8_ETC2, true, 4, 4, 1, 64 },
383 { BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
384 BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, true, 4, 4,
385 1, 64 },
386 { BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
387 BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, GL_COMPRESSED_RGBA8_ETC2_EAC, true, 4, 4, 1, 128 },
388
389 { BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
390 BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ETC2, true, 4, 4, 1, 64 },
391 { BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
392 BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, true, 4,
393 4, 1, 64 },
394 { BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
395 BASE_NS::Format::BASE_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, true, 4, 4, 1,
396 128 },
397
398 { BASE_NS::Format::BASE_FORMAT_EAC_R11_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_EAC_R11_UNORM_BLOCK,
399 BASE_NS::Format::BASE_FORMAT_EAC_R11_UNORM_BLOCK, GL_COMPRESSED_R11_EAC, true, 4, 4, 1, 64 },
400 { BASE_NS::Format::BASE_FORMAT_EAC_R11G11_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_EAC_R11G11_UNORM_BLOCK,
401 BASE_NS::Format::BASE_FORMAT_EAC_R11G11_UNORM_BLOCK, GL_COMPRESSED_RG11_EAC, true, 4, 4, 1, 128 },
402
403 { BASE_NS::Format::BASE_FORMAT_EAC_R11_SNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_EAC_R11_SNORM_BLOCK,
404 BASE_NS::Format::BASE_FORMAT_EAC_R11_SNORM_BLOCK, GL_COMPRESSED_SIGNED_R11_EAC, true, 4, 4, 1, 64 },
405 { BASE_NS::Format::BASE_FORMAT_EAC_R11G11_SNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_EAC_R11G11_SNORM_BLOCK,
406 BASE_NS::Format::BASE_FORMAT_EAC_R11G11_SNORM_BLOCK, GL_COMPRESSED_SIGNED_RG11_EAC, true, 4, 4, 1, 128 },
407
408 // ASTC formats.
409 { BASE_NS::Format::BASE_FORMAT_ASTC_4x4_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_4x4_SRGB_BLOCK,
410 BASE_NS::Format::BASE_FORMAT_ASTC_4x4_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, true, 4, 4, 1, 128 },
411 { BASE_NS::Format::BASE_FORMAT_ASTC_5x4_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_5x4_SRGB_BLOCK,
412 BASE_NS::Format::BASE_FORMAT_ASTC_5x4_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_5x4_KHR, true, 5, 4, 1, 128 },
413 { BASE_NS::Format::BASE_FORMAT_ASTC_5x5_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_5x5_SRGB_BLOCK,
414 BASE_NS::Format::BASE_FORMAT_ASTC_5x5_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_5x5_KHR, true, 5, 5, 1, 128 },
415 { BASE_NS::Format::BASE_FORMAT_ASTC_6x5_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_6x5_SRGB_BLOCK,
416 BASE_NS::Format::BASE_FORMAT_ASTC_6x5_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_6x5_KHR, true, 6, 5, 1, 128 },
417 { BASE_NS::Format::BASE_FORMAT_ASTC_6x6_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_6x6_SRGB_BLOCK,
418 BASE_NS::Format::BASE_FORMAT_ASTC_6x6_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_6x6_KHR, true, 6, 6, 1, 128 },
419 { BASE_NS::Format::BASE_FORMAT_ASTC_8x5_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_8x5_SRGB_BLOCK,
420 BASE_NS::Format::BASE_FORMAT_ASTC_8x5_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, true, 8, 5, 1, 128 },
421 { BASE_NS::Format::BASE_FORMAT_ASTC_8x6_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_8x6_SRGB_BLOCK,
422 BASE_NS::Format::BASE_FORMAT_ASTC_8x6_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, true, 8, 6, 1, 128 },
423 { BASE_NS::Format::BASE_FORMAT_ASTC_8x8_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_8x8_SRGB_BLOCK,
424 BASE_NS::Format::BASE_FORMAT_ASTC_8x8_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_8x8_KHR, true, 8, 8, 1, 128 },
425 { BASE_NS::Format::BASE_FORMAT_ASTC_10x5_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_10x5_SRGB_BLOCK,
426 BASE_NS::Format::BASE_FORMAT_ASTC_10x5_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_10x5_KHR, true, 10, 5, 1, 128 },
427 { BASE_NS::Format::BASE_FORMAT_ASTC_10x6_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_10x6_SRGB_BLOCK,
428 BASE_NS::Format::BASE_FORMAT_ASTC_10x6_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_10x6_KHR, true, 10, 6, 1, 128 },
429 { BASE_NS::Format::BASE_FORMAT_ASTC_10x8_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_10x8_SRGB_BLOCK,
430 BASE_NS::Format::BASE_FORMAT_ASTC_10x8_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_10x8_KHR, true, 10, 8, 1, 128 },
431 { BASE_NS::Format::BASE_FORMAT_ASTC_10x10_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_10x10_SRGB_BLOCK,
432 BASE_NS::Format::BASE_FORMAT_ASTC_10x10_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_10x10_KHR, true, 10, 10, 1, 128 },
433 { BASE_NS::Format::BASE_FORMAT_ASTC_12x10_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_12x10_SRGB_BLOCK,
434 BASE_NS::Format::BASE_FORMAT_ASTC_12x10_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_12x10_KHR, true, 12, 10, 1, 128 },
435 { BASE_NS::Format::BASE_FORMAT_ASTC_12x12_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_12x12_SRGB_BLOCK,
436 BASE_NS::Format::BASE_FORMAT_ASTC_12x12_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_12x12_KHR, true, 12, 12, 1, 128 },
437
438 { BASE_NS::Format::BASE_FORMAT_ASTC_4x4_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_4x4_SRGB_BLOCK,
439 BASE_NS::Format::BASE_FORMAT_ASTC_4x4_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, true, 4, 4, 1,
440 128 },
441 { BASE_NS::Format::BASE_FORMAT_ASTC_5x4_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_5x4_SRGB_BLOCK,
442 BASE_NS::Format::BASE_FORMAT_ASTC_5x4_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, true, 5, 4, 1,
443 128 },
444 { BASE_NS::Format::BASE_FORMAT_ASTC_5x5_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_5x5_SRGB_BLOCK,
445 BASE_NS::Format::BASE_FORMAT_ASTC_5x5_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, true, 5, 5, 1,
446 128 },
447 { BASE_NS::Format::BASE_FORMAT_ASTC_6x5_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_6x5_SRGB_BLOCK,
448 BASE_NS::Format::BASE_FORMAT_ASTC_6x5_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, true, 6, 5, 1,
449 128 },
450 { BASE_NS::Format::BASE_FORMAT_ASTC_6x6_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_6x6_SRGB_BLOCK,
451 BASE_NS::Format::BASE_FORMAT_ASTC_6x6_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, true, 6, 6, 1,
452 128 },
453 { BASE_NS::Format::BASE_FORMAT_ASTC_8x5_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_8x5_SRGB_BLOCK,
454 BASE_NS::Format::BASE_FORMAT_ASTC_8x5_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, true, 8, 5, 1,
455 128 },
456 { BASE_NS::Format::BASE_FORMAT_ASTC_8x6_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_8x6_SRGB_BLOCK,
457 BASE_NS::Format::BASE_FORMAT_ASTC_8x6_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, true, 8, 6, 1,
458 128 },
459 { BASE_NS::Format::BASE_FORMAT_ASTC_8x8_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_8x8_SRGB_BLOCK,
460 BASE_NS::Format::BASE_FORMAT_ASTC_8x8_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, true, 8, 8, 1,
461 128 },
462 { BASE_NS::Format::BASE_FORMAT_ASTC_10x5_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_10x5_SRGB_BLOCK,
463 BASE_NS::Format::BASE_FORMAT_ASTC_10x5_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, true, 10, 5, 1,
464 128 },
465 { BASE_NS::Format::BASE_FORMAT_ASTC_10x6_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_10x6_SRGB_BLOCK,
466 BASE_NS::Format::BASE_FORMAT_ASTC_10x6_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, true, 10, 6, 1,
467 128 },
468 { BASE_NS::Format::BASE_FORMAT_ASTC_10x8_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_10x8_SRGB_BLOCK,
469 BASE_NS::Format::BASE_FORMAT_ASTC_10x8_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, true, 10, 8, 1,
470 128 },
471 { BASE_NS::Format::BASE_FORMAT_ASTC_10x10_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_10x10_SRGB_BLOCK,
472 BASE_NS::Format::BASE_FORMAT_ASTC_10x10_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, true, 10, 10, 1,
473 128 },
474 { BASE_NS::Format::BASE_FORMAT_ASTC_12x10_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_12x10_SRGB_BLOCK,
475 BASE_NS::Format::BASE_FORMAT_ASTC_12x10_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, true, 12, 10, 1,
476 128 },
477 { BASE_NS::Format::BASE_FORMAT_ASTC_12x12_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_ASTC_12x12_SRGB_BLOCK,
478 BASE_NS::Format::BASE_FORMAT_ASTC_12x12_UNORM_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, true, 12, 12, 1,
479 128 },
480
481 // S3TC/DXT/BC formats.
482 { BASE_NS::Format::BASE_FORMAT_BC1_RGB_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_BC1_RGB_SRGB_BLOCK,
483 BASE_NS::Format::BASE_FORMAT_BC1_RGB_UNORM_BLOCK, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, true, 4, 4, 1, 64 },
484 { BASE_NS::Format::BASE_FORMAT_BC1_RGBA_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_BC1_RGBA_SRGB_BLOCK,
485 BASE_NS::Format::BASE_FORMAT_BC1_RGBA_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, true, 4, 4, 1, 64 },
486 { BASE_NS::Format::BASE_FORMAT_BC2_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_BC2_SRGB_BLOCK,
487 BASE_NS::Format::BASE_FORMAT_BC2_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, true, 4, 4, 1, 128 },
488 { BASE_NS::Format::BASE_FORMAT_BC3_UNORM_BLOCK, BASE_NS::Format::BASE_FORMAT_BC3_SRGB_BLOCK,
489 BASE_NS::Format::BASE_FORMAT_BC3_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, true, 4, 4, 1, 128 },
490
491 { BASE_NS::Format::BASE_FORMAT_BC1_RGB_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_BC1_RGB_SRGB_BLOCK,
492 BASE_NS::Format::BASE_FORMAT_BC1_RGB_UNORM_BLOCK, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, true, 4, 4, 1, 64 },
493 { BASE_NS::Format::BASE_FORMAT_BC1_RGBA_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_BC1_RGBA_SRGB_BLOCK,
494 BASE_NS::Format::BASE_FORMAT_BC1_RGBA_UNORM_BLOCK, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, true, 4, 4, 1, 64 },
495 { BASE_NS::Format::BASE_FORMAT_BC2_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_BC2_SRGB_BLOCK,
496 BASE_NS::Format::BASE_FORMAT_BC2_UNORM_BLOCK, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, true, 4, 4, 1, 128 },
497 { BASE_NS::Format::BASE_FORMAT_BC3_SRGB_BLOCK, BASE_NS::Format::BASE_FORMAT_BC3_SRGB_BLOCK,
498 BASE_NS::Format::BASE_FORMAT_BC3_UNORM_BLOCK, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, true, 4, 4, 1, 128 },
499
500 // Terminator
501 { BASE_NS::Format::BASE_FORMAT_UNDEFINED, BASE_NS::Format::BASE_FORMAT_UNDEFINED,
502 BASE_NS::Format::BASE_FORMAT_UNDEFINED, GL_NONE, false, 0, 0, 0, 0 },
503 };
504
GetFormatInfo(const uint32_t glFormat)505 GlImageFormatInfo GetFormatInfo(const uint32_t glFormat)
506 {
507 int i = 0;
508 for (;; i++) {
509 if ((GL_IMAGE_FORMATS[i].coreFormat == BASE_NS::Format::BASE_FORMAT_UNDEFINED) ||
510 (glFormat == GL_IMAGE_FORMATS[i].glFormat)) {
511 break;
512 }
513 }
514 return GL_IMAGE_FORMATS[i];
515 }
516 CORE_END_NAMESPACE()
517
518 #endif // CORE_GL_UTIL_H
519