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