blob: fac0f473989139f6dd8df861bae85785e584f7f4 [file] [log] [blame]
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001//
Geoff Langcec35902014-04-16 10:52:36 -04002// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// formatutils.cpp: Queries for GL image formats.
8
Jamie Madill6a6b09c2017-01-12 21:52:29 +00009#include "libANGLE/formatutils.h"
Yuly Novikovd73f8522017-01-13 17:48:57 -050010
11#include "common/mathutil.h"
Geoff Lang2b5420c2014-11-19 14:20:15 -050012#include "libANGLE/Context.h"
13#include "libANGLE/Framebuffer.h"
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000014
Jamie Madille2e406c2016-06-02 13:04:10 -040015using namespace angle;
16
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000017namespace gl
18{
19
Frank Henigman95fb2a12018-05-27 20:17:05 -040020// ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the
21// implementation can decide the true, sized, internal format. The ES2FormatMap determines the
22// internal format for all valid format and type combinations.
Jamie Madilled4d3422016-10-03 15:45:35 -040023GLenum GetSizedFormatInternal(GLenum format, GLenum type);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000024
Jamie Madilled4d3422016-10-03 15:45:35 -040025namespace
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000026{
Geoff Langca271392017-04-05 12:30:00 -040027using InternalFormatInfoMap =
28 std::unordered_map<GLenum, std::unordered_map<GLenum, InternalFormat>>;
Jamie Madilla3944d42016-07-22 22:13:26 -040029
Jamie Madillca2ff382018-07-11 09:01:17 -040030bool CheckedMathResult(const CheckedNumeric<GLuint> &value, GLuint *resultOut)
31{
32 if (!value.IsValid())
33 {
34 return false;
35 }
36 else
37 {
38 *resultOut = value.ValueOrDie();
39 return true;
40 }
41}
Markus Tavenrath0d665132018-11-18 15:47:02 +010042
Markus Tavenrath0d665132018-11-18 15:47:02 +010043constexpr uint32_t PackTypeInfo(GLuint bytes, bool specialized)
44{
45 // static_assert within constexpr requires c++17
46 // static_assert(isPow2(bytes));
Jamie Madill3f0c4a52019-01-10 10:20:35 -050047 return bytes | (rx::Log2(bytes) << 8) | (specialized << 16);
Markus Tavenrath0d665132018-11-18 15:47:02 +010048}
49
Jamie Madilla3944d42016-07-22 22:13:26 -040050} // anonymous namespace
51
Markus Tavenrath0d665132018-11-18 15:47:02 +010052FormatType::FormatType() : format(GL_NONE), type(GL_NONE) {}
Jamie Madilla3944d42016-07-22 22:13:26 -040053
Markus Tavenrath0d665132018-11-18 15:47:02 +010054FormatType::FormatType(GLenum format_, GLenum type_) : format(format_), type(type_) {}
Jamie Madilla3944d42016-07-22 22:13:26 -040055
56bool FormatType::operator<(const FormatType &other) const
57{
58 if (format != other.format)
59 return format < other.format;
60 return type < other.type;
61}
62
Frank Henigman95fb2a12018-05-27 20:17:05 -040063bool operator<(const Type &a, const Type &b)
Geoff Lang5d601382014-07-22 15:14:06 -040064{
65 return memcmp(&a, &b, sizeof(Type)) < 0;
66}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000067
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000068// Information about internal formats
Geoff Langeb66a6e2016-10-31 13:06:12 -040069static bool AlwaysSupported(const Version &, const Extensions &)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000070{
Geoff Lang493daf52014-07-03 13:38:44 -040071 return true;
72}
73
Geoff Langeb66a6e2016-10-31 13:06:12 -040074static bool NeverSupported(const Version &, const Extensions &)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000075{
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000076 return false;
77}
78
Geoff Langeb66a6e2016-10-31 13:06:12 -040079template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion>
80static bool RequireES(const Version &clientVersion, const Extensions &)
Geoff Lange4a492b2014-06-19 14:14:41 -040081{
Geoff Langeb66a6e2016-10-31 13:06:12 -040082 return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion);
Geoff Lange4a492b2014-06-19 14:14:41 -040083}
84
Geoff Langcec35902014-04-16 10:52:36 -040085// Pointer to a boolean memeber of the Extensions struct
86typedef bool(Extensions::*ExtensionBool);
87
88// Check support for a single extension
89template <ExtensionBool bool1>
Geoff Langeb66a6e2016-10-31 13:06:12 -040090static bool RequireExt(const Version &, const Extensions &extensions)
Geoff Langcec35902014-04-16 10:52:36 -040091{
Geoff Lange4a492b2014-06-19 14:14:41 -040092 return extensions.*bool1;
93}
94
95// Check for a minimum client version or a single extension
Geoff Langeb66a6e2016-10-31 13:06:12 -040096template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion, ExtensionBool bool1>
97static bool RequireESOrExt(const Version &clientVersion, const Extensions &extensions)
Geoff Lange4a492b2014-06-19 14:14:41 -040098{
Geoff Langeb66a6e2016-10-31 13:06:12 -040099 return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
100 extensions.*bool1;
Geoff Lange4a492b2014-06-19 14:14:41 -0400101}
102
103// Check for a minimum client version or two extensions
Geoff Langeb66a6e2016-10-31 13:06:12 -0400104template <GLuint minCoreGLMajorVersion,
105 GLuint minCoreGLMinorVersion,
106 ExtensionBool bool1,
107 ExtensionBool bool2>
108static bool RequireESOrExtAndExt(const Version &clientVersion, const Extensions &extensions)
Geoff Lange4a492b2014-06-19 14:14:41 -0400109{
Geoff Langeb66a6e2016-10-31 13:06:12 -0400110 return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
111 (extensions.*bool1 && extensions.*bool2);
Geoff Langabce7622014-09-19 16:13:00 -0400112}
113
114// Check for a minimum client version or at least one of two extensions
Geoff Langeb66a6e2016-10-31 13:06:12 -0400115template <GLuint minCoreGLMajorVersion,
116 GLuint minCoreGLMinorVersion,
117 ExtensionBool bool1,
118 ExtensionBool bool2>
119static bool RequireESOrExtOrExt(const Version &clientVersion, const Extensions &extensions)
Geoff Langabce7622014-09-19 16:13:00 -0400120{
Geoff Langeb66a6e2016-10-31 13:06:12 -0400121 return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
122 extensions.*bool1 || extensions.*bool2;
Geoff Langcec35902014-04-16 10:52:36 -0400123}
124
125// Check support for two extensions
126template <ExtensionBool bool1, ExtensionBool bool2>
Geoff Langeb66a6e2016-10-31 13:06:12 -0400127static bool RequireExtAndExt(const Version &, const Extensions &extensions)
Geoff Langcec35902014-04-16 10:52:36 -0400128{
Geoff Langabce7622014-09-19 16:13:00 -0400129 return extensions.*bool1 && extensions.*bool2;
Geoff Langcec35902014-04-16 10:52:36 -0400130}
131
Geoff Lang60ad73d2015-10-23 10:08:44 -0400132// Check support for either of two extensions
133template <ExtensionBool bool1, ExtensionBool bool2>
Geoff Langeb66a6e2016-10-31 13:06:12 -0400134static bool RequireExtOrExt(const Version &, const Extensions &extensions)
Geoff Lang60ad73d2015-10-23 10:08:44 -0400135{
136 return extensions.*bool1 || extensions.*bool2;
137}
138
Yuly Novikovd0828192018-06-15 15:51:07 -0400139// R8, RG8
140static bool SizedRGSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500141{
Yuly Novikovd0828192018-06-15 15:51:07 -0400142 return clientVersion >= Version(3, 0) || (extensions.textureStorage && extensions.textureRG);
Jamie Madillcd089732015-12-17 09:53:09 -0500143}
144
Yuly Novikovd0828192018-06-15 15:51:07 -0400145// R16F, RG16F with HALF_FLOAT_OES type
146static bool SizedHalfFloatOESRGSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500147{
Yuly Novikovd0828192018-06-15 15:51:07 -0400148 return extensions.textureStorage && extensions.textureHalfFloat && extensions.textureRG;
Jamie Madillcd089732015-12-17 09:53:09 -0500149}
150
Yuly Novikovd0828192018-06-15 15:51:07 -0400151static bool SizedHalfFloatOESRGTextureAttachmentSupport(const Version &clientVersion,
152 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400153{
Yuly Novikovd0828192018-06-15 15:51:07 -0400154 return SizedHalfFloatOESRGSupport(clientVersion, extensions) && extensions.colorBufferHalfFloat;
Geoff Lang677bb6f2017-04-05 12:40:40 -0400155}
156
Yuly Novikovd0828192018-06-15 15:51:07 -0400157// R16F, RG16F with either HALF_FLOAT_OES or HALF_FLOAT types
158static bool SizedHalfFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500159{
Yuly Novikovd0828192018-06-15 15:51:07 -0400160 // HALF_FLOAT
161 if (clientVersion >= Version(3, 0))
162 {
163 return true;
164 }
165 // HALF_FLOAT_OES
166 else
167 {
168 return SizedHalfFloatOESRGSupport(clientVersion, extensions);
169 }
Jamie Madillcd089732015-12-17 09:53:09 -0500170}
171
Yuly Novikovd0828192018-06-15 15:51:07 -0400172static bool SizedHalfFloatRGTextureAttachmentSupport(const Version &clientVersion,
173 const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500174{
Yuly Novikovd0828192018-06-15 15:51:07 -0400175 // HALF_FLOAT
176 if (clientVersion >= Version(3, 0))
177 {
178 return extensions.colorBufferFloat;
179 }
180 // HALF_FLOAT_OES
181 else
182 {
183 return SizedHalfFloatOESRGTextureAttachmentSupport(clientVersion, extensions);
184 }
Geoff Lang677bb6f2017-04-05 12:40:40 -0400185}
186
Yuly Novikovd0828192018-06-15 15:51:07 -0400187static bool SizedHalfFloatRGRenderbufferSupport(const Version &clientVersion,
188 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400189{
Yuly Novikovd0828192018-06-15 15:51:07 -0400190 return (clientVersion >= Version(3, 0) ||
191 (extensions.textureHalfFloat && extensions.textureRG)) &&
192 (extensions.colorBufferFloat || extensions.colorBufferHalfFloat);
Geoff Lang677bb6f2017-04-05 12:40:40 -0400193}
194
Yuly Novikovd0828192018-06-15 15:51:07 -0400195// RGB16F, RGBA16F with HALF_FLOAT_OES type
196static bool SizedHalfFloatOESSupport(const Version &clientVersion, const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400197{
Yuly Novikovd0828192018-06-15 15:51:07 -0400198 return extensions.textureStorage && extensions.textureHalfFloat;
199}
200
201static bool SizedHalfFloatOESTextureAttachmentSupport(const Version &clientVersion,
202 const Extensions &extensions)
203{
204 return SizedHalfFloatOESSupport(clientVersion, extensions) && extensions.colorBufferHalfFloat;
205}
206
207// RGB16F, RGBA16F with either HALF_FLOAT_OES or HALF_FLOAT types
208static bool SizedHalfFloatSupport(const Version &clientVersion, const Extensions &extensions)
209{
210 // HALF_FLOAT
211 if (clientVersion >= Version(3, 0))
212 {
213 return true;
214 }
215 // HALF_FLOAT_OES
216 else
217 {
218 return SizedHalfFloatOESSupport(clientVersion, extensions);
219 }
220}
221
222static bool SizedHalfFloatFilterSupport(const Version &clientVersion, const Extensions &extensions)
223{
224 // HALF_FLOAT
225 if (clientVersion >= Version(3, 0))
226 {
227 return true;
228 }
229 // HALF_FLOAT_OES
230 else
231 {
232 return extensions.textureHalfFloatLinear;
233 }
234}
235
236static bool SizedHalfFloatRGBTextureAttachmentSupport(const Version &clientVersion,
237 const Extensions &extensions)
238{
239 // HALF_FLOAT
240 if (clientVersion >= Version(3, 0))
241 {
242 // It is unclear how EXT_color_buffer_half_float applies to ES3.0 and above, however,
243 // dEQP GLES3 es3fFboColorbufferTests.cpp verifies that texture attachment of GL_RGB16F
244 // is possible, so assume that all GLES implementations support it.
245 return extensions.colorBufferHalfFloat;
246 }
247 // HALF_FLOAT_OES
248 else
249 {
250 return SizedHalfFloatOESTextureAttachmentSupport(clientVersion, extensions);
251 }
252}
253
254static bool SizedHalfFloatRGBRenderbufferSupport(const Version &clientVersion,
255 const Extensions &extensions)
256{
257 return (clientVersion >= Version(3, 0) || extensions.textureHalfFloat) &&
Geoff Lang677bb6f2017-04-05 12:40:40 -0400258 extensions.colorBufferHalfFloat;
259}
260
Yuly Novikovd0828192018-06-15 15:51:07 -0400261static bool SizedHalfFloatRGBATextureAttachmentSupport(const Version &clientVersion,
262 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400263{
Yuly Novikovd0828192018-06-15 15:51:07 -0400264 // HALF_FLOAT
265 if (clientVersion >= Version(3, 0))
266 {
267 return extensions.colorBufferFloat;
268 }
269 // HALF_FLOAT_OES
270 else
271 {
272 return SizedHalfFloatOESTextureAttachmentSupport(clientVersion, extensions);
273 }
Geoff Lang677bb6f2017-04-05 12:40:40 -0400274}
275
Yuly Novikovd0828192018-06-15 15:51:07 -0400276static bool SizedHalfFloatRGBARenderbufferSupport(const Version &clientVersion,
277 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400278{
Yuly Novikovd0828192018-06-15 15:51:07 -0400279 return (clientVersion >= Version(3, 0) || extensions.textureHalfFloat) &&
280 (extensions.colorBufferFloat || extensions.colorBufferHalfFloat);
Jamie Madillcd089732015-12-17 09:53:09 -0500281}
282
Yuly Novikovd0828192018-06-15 15:51:07 -0400283// R32F, RG32F
284static bool SizedFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500285{
Yuly Novikovd0828192018-06-15 15:51:07 -0400286 return clientVersion >= Version(3, 0) ||
287 (extensions.textureStorage && extensions.textureFloat && extensions.textureRG);
Jamie Madillcd089732015-12-17 09:53:09 -0500288}
289
Geoff Lang677bb6f2017-04-05 12:40:40 -0400290// RGB32F
Yuly Novikovd0828192018-06-15 15:51:07 -0400291static bool SizedFloatRGBSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500292{
Yuly Novikovd0828192018-06-15 15:51:07 -0400293 return clientVersion >= Version(3, 0) ||
294 (extensions.textureStorage && extensions.textureFloat) || extensions.colorBufferFloatRGB;
Geoff Lang677bb6f2017-04-05 12:40:40 -0400295}
296
297// RGBA32F
Yuly Novikovd0828192018-06-15 15:51:07 -0400298static bool SizedFloatRGBASupport(const Version &clientVersion, const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400299{
Yuly Novikovd0828192018-06-15 15:51:07 -0400300 return clientVersion >= Version(3, 0) ||
301 (extensions.textureStorage && extensions.textureFloat) ||
302 extensions.colorBufferFloatRGBA;
Geoff Lang677bb6f2017-04-05 12:40:40 -0400303}
304
Jeff Gilbert6446c882019-03-28 17:49:38 -0700305static bool SizedFloatRGBARenderableSupport(const Version &clientVersion,
306 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400307{
Jeff Gilbert6446c882019-03-28 17:49:38 -0700308 // This logic is the same for both Renderbuffers and TextureAttachment.
309 return extensions.colorBufferFloatRGBA || // ES2
310 extensions.colorBufferFloat; // ES3
Jamie Madillcd089732015-12-17 09:53:09 -0500311}
312
Geoff Lang5d601382014-07-22 15:14:06 -0400313InternalFormat::InternalFormat()
Jamie Madilla3944d42016-07-22 22:13:26 -0400314 : internalFormat(GL_NONE),
Geoff Langca271392017-04-05 12:30:00 -0400315 sized(false),
316 sizedInternalFormat(GL_NONE),
Jamie Madilla3944d42016-07-22 22:13:26 -0400317 redBits(0),
Geoff Lang5d601382014-07-22 15:14:06 -0400318 greenBits(0),
319 blueBits(0),
320 luminanceBits(0),
321 alphaBits(0),
322 sharedBits(0),
323 depthBits(0),
324 stencilBits(0),
325 pixelBytes(0),
326 componentCount(0),
Corentin Wallezbc99bb62015-05-14 17:42:20 -0400327 compressed(false),
Geoff Lang5d601382014-07-22 15:14:06 -0400328 compressedBlockWidth(0),
329 compressedBlockHeight(0),
330 format(GL_NONE),
331 type(GL_NONE),
332 componentType(GL_NONE),
333 colorEncoding(GL_NONE),
Geoff Lang5d601382014-07-22 15:14:06 -0400334 textureSupport(NeverSupported),
Yuly Novikovf15f8862018-06-04 18:59:41 -0400335 filterSupport(NeverSupported),
336 textureAttachmentSupport(NeverSupported),
337 renderbufferSupport(NeverSupported)
Jamie Madillb980c562018-11-27 11:34:27 -0500338{}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000339
Jamie Madillacf2f3a2017-11-21 19:22:44 -0500340InternalFormat::InternalFormat(const InternalFormat &other) = default;
341
Jamie Madilla3944d42016-07-22 22:13:26 -0400342bool InternalFormat::isLUMA() const
343{
344 return ((redBits + greenBits + blueBits + depthBits + stencilBits) == 0 &&
345 (luminanceBits + alphaBits) > 0);
346}
347
Geoff Langf607c602016-09-21 11:46:48 -0400348GLenum InternalFormat::getReadPixelsFormat() const
349{
350 return format;
351}
352
Geoff Langc71ea662017-09-26 17:06:02 -0400353GLenum InternalFormat::getReadPixelsType(const Version &version) const
Geoff Langf607c602016-09-21 11:46:48 -0400354{
355 switch (type)
356 {
357 case GL_HALF_FLOAT:
Geoff Langc71ea662017-09-26 17:06:02 -0400358 case GL_HALF_FLOAT_OES:
359 if (version < Version(3, 0))
360 {
361 // The internal format may have a type of GL_HALF_FLOAT but when exposing this type
362 // as the IMPLEMENTATION_READ_TYPE, only HALF_FLOAT_OES is allowed by
363 // OES_texture_half_float. HALF_FLOAT becomes core in ES3 and is acceptable to use
364 // as an IMPLEMENTATION_READ_TYPE.
365 return GL_HALF_FLOAT_OES;
366 }
367 else
368 {
369 return GL_HALF_FLOAT;
370 }
Geoff Langf607c602016-09-21 11:46:48 -0400371
372 default:
373 return type;
374 }
375}
376
Olli Etuaho50c562d2017-06-06 14:43:30 +0300377bool InternalFormat::isRequiredRenderbufferFormat(const Version &version) const
378{
379 // GLES 3.0.5 section 4.4.2.2:
380 // "Implementations are required to support the same internal formats for renderbuffers as the
381 // required formats for textures enumerated in section 3.8.3.1, with the exception of the color
382 // formats labelled "texture-only"."
383 if (!sized || compressed)
384 {
385 return false;
386 }
387
388 // Luma formats.
389 if (isLUMA())
390 {
391 return false;
392 }
393
394 // Depth/stencil formats.
395 if (depthBits > 0 || stencilBits > 0)
396 {
397 // GLES 2.0.25 table 4.5.
398 // GLES 3.0.5 section 3.8.3.1.
399 // GLES 3.1 table 8.14.
400
401 // Required formats in all versions.
402 switch (internalFormat)
403 {
404 case GL_DEPTH_COMPONENT16:
405 case GL_STENCIL_INDEX8:
406 // Note that STENCIL_INDEX8 is not mentioned in GLES 3.0.5 section 3.8.3.1, but it
407 // is in section 4.4.2.2.
408 return true;
409 default:
410 break;
411 }
412 if (version.major < 3)
413 {
414 return false;
415 }
416 // Required formats in GLES 3.0 and up.
417 switch (internalFormat)
418 {
419 case GL_DEPTH_COMPONENT32F:
420 case GL_DEPTH_COMPONENT24:
421 case GL_DEPTH32F_STENCIL8:
422 case GL_DEPTH24_STENCIL8:
423 return true;
424 default:
425 return false;
426 }
427 }
428
429 // RGBA formats.
430 // GLES 2.0.25 table 4.5.
431 // GLES 3.0.5 section 3.8.3.1.
432 // GLES 3.1 table 8.13.
433
434 // Required formats in all versions.
435 switch (internalFormat)
436 {
437 case GL_RGBA4:
438 case GL_RGB5_A1:
439 case GL_RGB565:
440 return true;
441 default:
442 break;
443 }
444 if (version.major < 3)
445 {
446 return false;
447 }
448
449 if (format == GL_BGRA_EXT)
450 {
451 return false;
452 }
453
454 switch (componentType)
455 {
456 case GL_SIGNED_NORMALIZED:
457 case GL_FLOAT:
458 return false;
459 case GL_UNSIGNED_INT:
460 case GL_INT:
461 // Integer RGB formats are not required renderbuffer formats.
462 if (alphaBits == 0 && blueBits != 0)
463 {
464 return false;
465 }
466 // All integer R and RG formats are required.
467 // Integer RGBA formats including RGB10_A2_UI are required.
468 return true;
469 case GL_UNSIGNED_NORMALIZED:
470 if (internalFormat == GL_SRGB8)
471 {
472 return false;
473 }
474 return true;
475 default:
476 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -0500477#if !UNREACHABLE_IS_NORETURN
Olli Etuaho50c562d2017-06-06 14:43:30 +0300478 return false;
Nico Weberb5db2b42018-02-12 15:31:56 -0500479#endif
Olli Etuaho50c562d2017-06-06 14:43:30 +0300480 }
481}
482
Markus Tavenrath0d665132018-11-18 15:47:02 +0100483Format::Format(GLenum internalFormat) : Format(GetSizedInternalFormatInfo(internalFormat)) {}
Jamie Madilla3944d42016-07-22 22:13:26 -0400484
Markus Tavenrath0d665132018-11-18 15:47:02 +0100485Format::Format(const InternalFormat &internalFormat) : info(&internalFormat) {}
Jamie Madilla3944d42016-07-22 22:13:26 -0400486
Geoff Langca271392017-04-05 12:30:00 -0400487Format::Format(GLenum internalFormat, GLenum type)
488 : info(&GetInternalFormatInfo(internalFormat, type))
Jamie Madillb980c562018-11-27 11:34:27 -0500489{}
Jamie Madilla3944d42016-07-22 22:13:26 -0400490
491Format::Format(const Format &other) = default;
492Format &Format::operator=(const Format &other) = default;
493
Jamie Madilla3944d42016-07-22 22:13:26 -0400494bool Format::valid() const
495{
Geoff Langca271392017-04-05 12:30:00 -0400496 return info->internalFormat != GL_NONE;
Jamie Madilla3944d42016-07-22 22:13:26 -0400497}
498
499// static
500bool Format::SameSized(const Format &a, const Format &b)
501{
Geoff Langca271392017-04-05 12:30:00 -0400502 return a.info->sizedInternalFormat == b.info->sizedInternalFormat;
Jamie Madilla3944d42016-07-22 22:13:26 -0400503}
504
Kenneth Russell69382852017-07-21 16:38:44 -0400505static GLenum EquivalentBlitInternalFormat(GLenum internalformat)
506{
507 // BlitFramebuffer works if the color channels are identically
508 // sized, even if there is a swizzle (for example, blitting from a
509 // multisampled RGBA8 renderbuffer to a BGRA8 texture). This could
510 // be expanded and/or autogenerated if that is found necessary.
511 if (internalformat == GL_BGRA8_EXT)
512 return GL_RGBA8;
513 return internalformat;
514}
515
516// static
517bool Format::EquivalentForBlit(const Format &a, const Format &b)
518{
519 return (EquivalentBlitInternalFormat(a.info->sizedInternalFormat) ==
520 EquivalentBlitInternalFormat(b.info->sizedInternalFormat));
521}
522
Jamie Madilla3944d42016-07-22 22:13:26 -0400523// static
524Format Format::Invalid()
525{
Geoff Langca271392017-04-05 12:30:00 -0400526 static Format invalid(GL_NONE, GL_NONE);
Jamie Madilla3944d42016-07-22 22:13:26 -0400527 return invalid;
528}
529
Yuly Novikovd73f8522017-01-13 17:48:57 -0500530std::ostream &operator<<(std::ostream &os, const Format &fmt)
531{
532 // TODO(ynovikov): return string representation when available
Geoff Langb0e9ddb2018-05-23 11:30:04 -0400533 return FmtHex(os, fmt.info->sizedInternalFormat);
Yuly Novikovd73f8522017-01-13 17:48:57 -0500534}
535
Jamie Madilla3944d42016-07-22 22:13:26 -0400536bool InternalFormat::operator==(const InternalFormat &other) const
537{
Geoff Langca271392017-04-05 12:30:00 -0400538 // We assume all internal formats are unique if they have the same internal format and type
539 return internalFormat == other.internalFormat && type == other.type;
Jamie Madilla3944d42016-07-22 22:13:26 -0400540}
541
542bool InternalFormat::operator!=(const InternalFormat &other) const
543{
Geoff Langca271392017-04-05 12:30:00 -0400544 return !(*this == other);
Jamie Madilla3944d42016-07-22 22:13:26 -0400545}
546
Geoff Langca271392017-04-05 12:30:00 -0400547void InsertFormatInfo(InternalFormatInfoMap *map, const InternalFormat &formatInfo)
Geoff Lang5d601382014-07-22 15:14:06 -0400548{
Geoff Langca271392017-04-05 12:30:00 -0400549 ASSERT(!formatInfo.sized || (*map).count(formatInfo.internalFormat) == 0);
550 ASSERT((*map)[formatInfo.internalFormat].count(formatInfo.type) == 0);
551 (*map)[formatInfo.internalFormat][formatInfo.type] = formatInfo;
Geoff Lang5d601382014-07-22 15:14:06 -0400552}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000553
Jamie Madilla3944d42016-07-22 22:13:26 -0400554void AddRGBAFormat(InternalFormatInfoMap *map,
555 GLenum internalFormat,
Geoff Langca271392017-04-05 12:30:00 -0400556 bool sized,
Jamie Madilla3944d42016-07-22 22:13:26 -0400557 GLuint red,
558 GLuint green,
559 GLuint blue,
560 GLuint alpha,
561 GLuint shared,
562 GLenum format,
563 GLenum type,
564 GLenum componentType,
565 bool srgb,
566 InternalFormat::SupportCheckFunction textureSupport,
Yuly Novikovf15f8862018-06-04 18:59:41 -0400567 InternalFormat::SupportCheckFunction filterSupport,
568 InternalFormat::SupportCheckFunction textureAttachmentSupport,
569 InternalFormat::SupportCheckFunction renderbufferSupport)
Geoff Lang5d601382014-07-22 15:14:06 -0400570{
571 InternalFormat formatInfo;
Jamie Madilla3944d42016-07-22 22:13:26 -0400572 formatInfo.internalFormat = internalFormat;
Geoff Langca271392017-04-05 12:30:00 -0400573 formatInfo.sized = sized;
574 formatInfo.sizedInternalFormat =
575 sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
Frank Henigman95fb2a12018-05-27 20:17:05 -0400576 formatInfo.redBits = red;
577 formatInfo.greenBits = green;
578 formatInfo.blueBits = blue;
579 formatInfo.alphaBits = alpha;
Geoff Lang5d601382014-07-22 15:14:06 -0400580 formatInfo.sharedBits = shared;
581 formatInfo.pixelBytes = (red + green + blue + alpha + shared) / 8;
Geoff Langca271392017-04-05 12:30:00 -0400582 formatInfo.componentCount =
583 ((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
Geoff Langcb8a9212018-06-28 12:30:36 -0400584 formatInfo.format = format;
585 formatInfo.type = type;
586 formatInfo.componentType = componentType;
587 formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
588 formatInfo.textureSupport = textureSupport;
Yuly Novikovf15f8862018-06-04 18:59:41 -0400589 formatInfo.filterSupport = filterSupport;
590 formatInfo.textureAttachmentSupport = textureAttachmentSupport;
591 formatInfo.renderbufferSupport = renderbufferSupport;
Geoff Langca271392017-04-05 12:30:00 -0400592
593 InsertFormatInfo(map, formatInfo);
Geoff Lang5d601382014-07-22 15:14:06 -0400594}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000595
Geoff Langca271392017-04-05 12:30:00 -0400596static void AddLUMAFormat(InternalFormatInfoMap *map,
597 GLenum internalFormat,
598 bool sized,
599 GLuint luminance,
600 GLuint alpha,
601 GLenum format,
602 GLenum type,
603 GLenum componentType,
604 InternalFormat::SupportCheckFunction textureSupport,
Yuly Novikovf15f8862018-06-04 18:59:41 -0400605 InternalFormat::SupportCheckFunction filterSupport,
606 InternalFormat::SupportCheckFunction textureAttachmentSupport,
607 InternalFormat::SupportCheckFunction renderbufferSupport)
Geoff Lang5d601382014-07-22 15:14:06 -0400608{
609 InternalFormat formatInfo;
Geoff Langca271392017-04-05 12:30:00 -0400610 formatInfo.internalFormat = internalFormat;
611 formatInfo.sized = sized;
612 formatInfo.sizedInternalFormat =
613 sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
Geoff Langcb8a9212018-06-28 12:30:36 -0400614 formatInfo.luminanceBits = luminance;
615 formatInfo.alphaBits = alpha;
616 formatInfo.pixelBytes = (luminance + alpha) / 8;
617 formatInfo.componentCount = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
618 formatInfo.format = format;
619 formatInfo.type = type;
620 formatInfo.componentType = componentType;
621 formatInfo.colorEncoding = GL_LINEAR;
622 formatInfo.textureSupport = textureSupport;
Yuly Novikovf15f8862018-06-04 18:59:41 -0400623 formatInfo.filterSupport = filterSupport;
624 formatInfo.textureAttachmentSupport = textureAttachmentSupport;
625 formatInfo.renderbufferSupport = renderbufferSupport;
Geoff Langca271392017-04-05 12:30:00 -0400626
627 InsertFormatInfo(map, formatInfo);
Geoff Lang5d601382014-07-22 15:14:06 -0400628}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000629
Jamie Madilla3944d42016-07-22 22:13:26 -0400630void AddDepthStencilFormat(InternalFormatInfoMap *map,
631 GLenum internalFormat,
Geoff Langca271392017-04-05 12:30:00 -0400632 bool sized,
Jamie Madilla3944d42016-07-22 22:13:26 -0400633 GLuint depthBits,
634 GLuint stencilBits,
635 GLuint unusedBits,
636 GLenum format,
637 GLenum type,
638 GLenum componentType,
639 InternalFormat::SupportCheckFunction textureSupport,
Yuly Novikovf15f8862018-06-04 18:59:41 -0400640 InternalFormat::SupportCheckFunction filterSupport,
641 InternalFormat::SupportCheckFunction textureAttachmentSupport,
642 InternalFormat::SupportCheckFunction renderbufferSupport)
Geoff Lang5d601382014-07-22 15:14:06 -0400643{
644 InternalFormat formatInfo;
Jamie Madilla3944d42016-07-22 22:13:26 -0400645 formatInfo.internalFormat = internalFormat;
Geoff Langca271392017-04-05 12:30:00 -0400646 formatInfo.sized = sized;
647 formatInfo.sizedInternalFormat =
648 sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
Geoff Langcb8a9212018-06-28 12:30:36 -0400649 formatInfo.depthBits = depthBits;
650 formatInfo.stencilBits = stencilBits;
651 formatInfo.pixelBytes = (depthBits + stencilBits + unusedBits) / 8;
652 formatInfo.componentCount = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0);
653 formatInfo.format = format;
654 formatInfo.type = type;
655 formatInfo.componentType = componentType;
656 formatInfo.colorEncoding = GL_LINEAR;
657 formatInfo.textureSupport = textureSupport;
Yuly Novikovf15f8862018-06-04 18:59:41 -0400658 formatInfo.filterSupport = filterSupport;
659 formatInfo.textureAttachmentSupport = textureAttachmentSupport;
660 formatInfo.renderbufferSupport = renderbufferSupport;
Geoff Langca271392017-04-05 12:30:00 -0400661
662 InsertFormatInfo(map, formatInfo);
Geoff Lang5d601382014-07-22 15:14:06 -0400663}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000664
Geoff Langca271392017-04-05 12:30:00 -0400665void AddCompressedFormat(InternalFormatInfoMap *map,
666 GLenum internalFormat,
667 GLuint compressedBlockWidth,
668 GLuint compressedBlockHeight,
669 GLuint compressedBlockSize,
670 GLuint componentCount,
671 GLenum format,
672 GLenum type,
673 bool srgb,
674 InternalFormat::SupportCheckFunction textureSupport,
Yuly Novikovf15f8862018-06-04 18:59:41 -0400675 InternalFormat::SupportCheckFunction filterSupport,
676 InternalFormat::SupportCheckFunction textureAttachmentSupport,
677 InternalFormat::SupportCheckFunction renderbufferSupport)
Geoff Lang5d601382014-07-22 15:14:06 -0400678{
679 InternalFormat formatInfo;
Geoff Langcb8a9212018-06-28 12:30:36 -0400680 formatInfo.internalFormat = internalFormat;
681 formatInfo.sized = true;
682 formatInfo.sizedInternalFormat = internalFormat;
683 formatInfo.compressedBlockWidth = compressedBlockWidth;
684 formatInfo.compressedBlockHeight = compressedBlockHeight;
685 formatInfo.pixelBytes = compressedBlockSize / 8;
686 formatInfo.componentCount = componentCount;
687 formatInfo.format = format;
688 formatInfo.type = type;
689 formatInfo.componentType = GL_UNSIGNED_NORMALIZED;
690 formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
691 formatInfo.compressed = true;
692 formatInfo.textureSupport = textureSupport;
Yuly Novikovf15f8862018-06-04 18:59:41 -0400693 formatInfo.filterSupport = filterSupport;
694 formatInfo.textureAttachmentSupport = textureAttachmentSupport;
695 formatInfo.renderbufferSupport = renderbufferSupport;
Geoff Langca271392017-04-05 12:30:00 -0400696
697 InsertFormatInfo(map, formatInfo);
Geoff Lang5d601382014-07-22 15:14:06 -0400698}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000699
Yuly Novikovd0828192018-06-15 15:51:07 -0400700// Notes:
701// 1. "Texture supported" includes all the means by which texture can be created, however,
702// GL_EXT_texture_storage in ES2 is a special case, when only glTexStorage* is allowed.
703// The assumption is that ES2 validation will not check textureSupport for sized formats.
704//
705// 2. Sized half float types are a combination of GL_HALF_FLOAT and GL_HALF_FLOAT_OES support,
706// due to a limitation that only one type for sized formats is allowed.
707//
708// TODO(ynovikov): http://anglebug.com/2846 Verify support fields of BGRA, depth, stencil
709// and compressed formats. Perform texturable check as part of filterable and attachment checks.
Geoff Lange4a492b2014-06-19 14:14:41 -0400710static InternalFormatInfoMap BuildInternalFormatInfoMap()
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000711{
712 InternalFormatInfoMap map;
713
714 // From ES 3.0.1 spec, table 3.12
Geoff Langca271392017-04-05 12:30:00 -0400715 map[GL_NONE][GL_NONE] = InternalFormat();
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000716
Jamie Madilla3944d42016-07-22 22:13:26 -0400717 // clang-format off
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000718
Yuly Novikovd0828192018-06-15 15:51:07 -0400719 // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
720 AddRGBAFormat(&map, GL_R8, true, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, SizedRGSupport, AlwaysSupported, SizedRGSupport, RequireESOrExt<3, 0, &Extensions::textureRG> );
721 AddRGBAFormat(&map, GL_R8_SNORM, true, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, AlwaysSupported, NeverSupported, NeverSupported );
722 AddRGBAFormat(&map, GL_RG8, true, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, SizedRGSupport, AlwaysSupported, SizedRGSupport, RequireESOrExt<3, 0, &Extensions::textureRG> );
723 AddRGBAFormat(&map, GL_RG8_SNORM, true, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, AlwaysSupported, NeverSupported, NeverSupported );
724 AddRGBAFormat(&map, GL_RGB8, true, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireESOrExt<3, 0, &Extensions::rgb8rgba8> );
725 AddRGBAFormat(&map, GL_RGB8_SNORM, true, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, AlwaysSupported, NeverSupported, NeverSupported );
726 AddRGBAFormat(&map, GL_RGB565, true, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireES<2, 0> );
727 AddRGBAFormat(&map, GL_RGBA4, true, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireES<2, 0> );
728 AddRGBAFormat(&map, GL_RGB5_A1, true, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireES<2, 0> );
729 AddRGBAFormat(&map, GL_RGBA8, true, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireESOrExt<3, 0, &Extensions::rgb8rgba8> );
730 AddRGBAFormat(&map, GL_RGBA8_SNORM, true, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, AlwaysSupported, NeverSupported, NeverSupported );
731 AddRGBAFormat(&map, GL_RGB10_A2, true, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<3, 0>, AlwaysSupported, RequireES<3, 0>, RequireES<3, 0> );
732 AddRGBAFormat(&map, GL_RGB10_A2UI, true, 10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
733 AddRGBAFormat(&map, GL_SRGB8, true, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireES<3, 0>, AlwaysSupported, NeverSupported, NeverSupported );
734 AddRGBAFormat(&map, GL_SRGB8_ALPHA8, true, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireES<3, 0>, AlwaysSupported, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::sRGB> );
735 AddRGBAFormat(&map, GL_R11F_G11F_B10F, true, 11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireES<3, 0>, AlwaysSupported, RequireExt<&Extensions::colorBufferFloat>, RequireExt<&Extensions::colorBufferFloat> );
736 AddRGBAFormat(&map, GL_RGB9_E5, true, 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireES<3, 0>, AlwaysSupported, NeverSupported, NeverSupported );
737 AddRGBAFormat(&map, GL_R8I, true, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
738 AddRGBAFormat(&map, GL_R8UI, true, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
739 AddRGBAFormat(&map, GL_R16I, true, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
740 AddRGBAFormat(&map, GL_R16UI, true, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
741 AddRGBAFormat(&map, GL_R32I, true, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
742 AddRGBAFormat(&map, GL_R32UI, true, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
743 AddRGBAFormat(&map, GL_RG8I, true, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
744 AddRGBAFormat(&map, GL_RG8UI, true, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
745 AddRGBAFormat(&map, GL_RG16I, true, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
746 AddRGBAFormat(&map, GL_RG16UI, true, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
747 AddRGBAFormat(&map, GL_RG32I, true, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
748 AddRGBAFormat(&map, GL_RG32UI, true, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
749 AddRGBAFormat(&map, GL_RGB8I, true, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported );
750 AddRGBAFormat(&map, GL_RGB8UI, true, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported );
751 AddRGBAFormat(&map, GL_RGB16I, true, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported );
752 AddRGBAFormat(&map, GL_RGB16UI, true, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported );
753 AddRGBAFormat(&map, GL_RGB32I, true, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported );
754 AddRGBAFormat(&map, GL_RGB32UI, true, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported );
755 AddRGBAFormat(&map, GL_RGBA8I, true, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
756 AddRGBAFormat(&map, GL_RGBA8UI, true, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
757 AddRGBAFormat(&map, GL_RGBA16I, true, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
758 AddRGBAFormat(&map, GL_RGBA16UI, true, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
759 AddRGBAFormat(&map, GL_RGBA32I, true, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
760 AddRGBAFormat(&map, GL_RGBA32UI, true, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, RequireES<3, 0>, RequireES<3, 0> );
Jamie Madilla3944d42016-07-22 22:13:26 -0400761
Yuly Novikovd0828192018-06-15 15:51:07 -0400762 AddRGBAFormat(&map, GL_BGRA8_EXT, true, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>);
763 AddRGBAFormat(&map, GL_BGRA4_ANGLEX, true, 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>);
764 AddRGBAFormat(&map, GL_BGR5_A1_ANGLEX, true, 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000765
Olli Etuahoceffd202018-01-08 16:39:45 +0200766 // Special format that is used for D3D textures that are used within ANGLE via the
767 // EGL_ANGLE_d3d_texture_client_buffer extension. We don't allow uploading texture images with
768 // this format, but textures in this format can be created from D3D textures, and filtering them
769 // and rendering to them is allowed.
Yuly Novikovd0828192018-06-15 15:51:07 -0400770 AddRGBAFormat(&map, GL_BGRA8_SRGB_ANGLEX, true, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, NeverSupported, AlwaysSupported, AlwaysSupported, AlwaysSupported );
Olli Etuahoceffd202018-01-08 16:39:45 +0200771
Jamie Madillec0b5802016-07-04 13:11:59 -0400772 // Special format which is not really supported, so always false for all supports.
Yuly Novikovd0828192018-06-15 15:51:07 -0400773 AddRGBAFormat(&map, GL_BGRX8_ANGLEX, true, 8, 8, 8, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported );
774 AddRGBAFormat(&map, GL_BGR565_ANGLEX, true, 5, 6, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported );
Jamie Madillec0b5802016-07-04 13:11:59 -0400775
Yuly Novikovd0828192018-06-15 15:51:07 -0400776 // Floating point formats
777 // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
778 // It's not possible to have two entries per sized format.
779 // E.g. for GL_RG16F, one with GL_HALF_FLOAT type and the other with GL_HALF_FLOAT_OES type.
780 // So, GL_HALF_FLOAT type formats conditions are merged with GL_HALF_FLOAT_OES type conditions.
781 AddRGBAFormat(&map, GL_R16F, true, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, SizedHalfFloatRGSupport, SizedHalfFloatFilterSupport, SizedHalfFloatRGTextureAttachmentSupport, SizedHalfFloatRGRenderbufferSupport );
782 AddRGBAFormat(&map, GL_RG16F, true, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, SizedHalfFloatRGSupport, SizedHalfFloatFilterSupport, SizedHalfFloatRGTextureAttachmentSupport, SizedHalfFloatRGRenderbufferSupport );
783 AddRGBAFormat(&map, GL_RGB16F, true, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, SizedHalfFloatSupport, SizedHalfFloatFilterSupport, SizedHalfFloatRGBTextureAttachmentSupport, SizedHalfFloatRGBRenderbufferSupport );
784 AddRGBAFormat(&map, GL_RGBA16F, true, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, SizedHalfFloatSupport, SizedHalfFloatFilterSupport, SizedHalfFloatRGBATextureAttachmentSupport, SizedHalfFloatRGBARenderbufferSupport );
785 AddRGBAFormat(&map, GL_R32F, true, 32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, SizedFloatRGSupport, RequireExt<&Extensions::textureFloatLinear>, RequireExt<&Extensions::colorBufferFloat>, RequireExt<&Extensions::colorBufferFloat>);
786 AddRGBAFormat(&map, GL_RG32F, true, 32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, SizedFloatRGSupport, RequireExt<&Extensions::textureFloatLinear>, RequireExt<&Extensions::colorBufferFloat>, RequireExt<&Extensions::colorBufferFloat>);
787 AddRGBAFormat(&map, GL_RGB32F, true, 32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, SizedFloatRGBSupport, RequireExt<&Extensions::textureFloatLinear>, RequireExt<&Extensions::colorBufferFloatRGB>, NeverSupported );
Jeff Gilbert6446c882019-03-28 17:49:38 -0700788 AddRGBAFormat(&map, GL_RGBA32F, true, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, SizedFloatRGBASupport, RequireExt<&Extensions::textureFloatLinear>, SizedFloatRGBARenderableSupport, SizedFloatRGBARenderableSupport );
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000789
790 // Depth stencil formats
Yuly Novikovf15f8862018-06-04 18:59:41 -0400791 // | Internal format |sized| D |S | X | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
792 AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT16, true, 16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<1, 0>, RequireESOrExt<3, 0, &Extensions::depthTextures>, RequireES<1, 0>, RequireES<1, 0> );
793 AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT24, true, 24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextures>, RequireES<3, 0>, RequireES<3, 0> );
794 AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32F, true, 32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextures>, RequireES<3, 0>, RequireES<3, 0> );
795 AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32_OES, true, 32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, AlwaysSupported, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32> );
796 AddDepthStencilFormat(&map, GL_DEPTH24_STENCIL8, true, 24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 0, &Extensions::depthTextures>, AlwaysSupported, RequireESOrExtOrExt<3, 0, &Extensions::depthTextures, &Extensions::packedDepthStencil>, RequireESOrExtOrExt<3, 0, &Extensions::depthTextures, &Extensions::packedDepthStencil>);
797 AddDepthStencilFormat(&map, GL_DEPTH32F_STENCIL8, true, 32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireES<3, 0>, AlwaysSupported, RequireES<3, 0>, RequireES<3, 0> );
Corentin Walleze0902642014-11-04 12:32:15 -0800798 // STENCIL_INDEX8 is special-cased, see around the bottom of the list.
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000799
800 // Luminance alpha formats
Yuly Novikovd0828192018-06-15 15:51:07 -0400801 // | Internal format |sized| L | A | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
802 AddLUMAFormat(&map, GL_ALPHA8_EXT, true, 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, AlwaysSupported, NeverSupported, NeverSupported);
803 AddLUMAFormat(&map, GL_LUMINANCE8_EXT, true, 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, AlwaysSupported, NeverSupported, NeverSupported);
804 AddLUMAFormat(&map, GL_LUMINANCE8_ALPHA8_EXT, true, 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, AlwaysSupported, NeverSupported, NeverSupported);
805 AddLUMAFormat(&map, GL_ALPHA16F_EXT, true, 0, 16, GL_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
806 AddLUMAFormat(&map, GL_LUMINANCE16F_EXT, true, 16, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
807 AddLUMAFormat(&map, GL_LUMINANCE_ALPHA16F_EXT, true, 16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
808 AddLUMAFormat(&map, GL_ALPHA32F_EXT, true, 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
809 AddLUMAFormat(&map, GL_LUMINANCE32F_EXT, true, 32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
810 AddLUMAFormat(&map, GL_LUMINANCE_ALPHA32F_EXT, true, 32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000811
812 // Compressed formats, From ES 3.0.1 spec, table 3.16
Geoff Lang836674c2018-11-19 11:45:18 -0500813 // | Internal format |W |H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
814 AddCompressedFormat(&map, GL_COMPRESSED_R11_EAC, 4, 4, 64, 1, GL_RED, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedEACR11UnsignedTexture>, AlwaysSupported, NeverSupported, NeverSupported);
815 AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_R11_EAC, 4, 4, 64, 1, GL_RED, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedEACR11SignedTexture>, AlwaysSupported, NeverSupported, NeverSupported);
816 AddCompressedFormat(&map, GL_COMPRESSED_RG11_EAC, 4, 4, 128, 2, GL_RG, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedEACRG11UnsignedTexture>, AlwaysSupported, NeverSupported, NeverSupported);
817 AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_RG11_EAC, 4, 4, 128, 2, GL_RG, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedEACRG11SignedTexture>, AlwaysSupported, NeverSupported, NeverSupported);
818 AddCompressedFormat(&map, GL_COMPRESSED_RGB8_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2RGB8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
819 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2sRGB8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
820 AddCompressedFormat(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2PunchthroughARGB8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
821 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2PunchthroughAsRGB8AlphaTexture>, AlwaysSupported, NeverSupported, NeverSupported);
822 AddCompressedFormat(&map, GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2RGBA8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
823 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2sRGB8Alpha8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000824
825 // From GL_EXT_texture_compression_dxt1
Yuly Novikovf15f8862018-06-04 18:59:41 -0400826 // | Internal format |W |H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
827 AddCompressedFormat(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, AlwaysSupported, NeverSupported, NeverSupported);
828 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 64, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, AlwaysSupported, NeverSupported, NeverSupported);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000829
830 // From GL_ANGLE_texture_compression_dxt3
Yuly Novikovf15f8862018-06-04 18:59:41 -0400831 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT3>, AlwaysSupported, NeverSupported, NeverSupported);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000832
833 // From GL_ANGLE_texture_compression_dxt5
Yuly Novikovf15f8862018-06-04 18:59:41 -0400834 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT5>, AlwaysSupported, NeverSupported, NeverSupported);
Geoff Lang6ea6f942015-09-11 13:11:22 -0400835
836 // From GL_OES_compressed_ETC1_RGB8_texture
Yuly Novikovf15f8862018-06-04 18:59:41 -0400837 AddCompressedFormat(&map, GL_ETC1_RGB8_OES, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::compressedETC1RGB8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000838
Kai Ninomiya02f075c2016-12-22 14:55:46 -0800839 // From GL_EXT_texture_compression_s3tc_srgb
Yuly Novikovf15f8862018-06-04 18:59:41 -0400840 // | Internal format |W |H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
841 AddCompressedFormat(&map, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, AlwaysSupported, NeverSupported, NeverSupported);
842 AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 4, 4, 64, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, AlwaysSupported, NeverSupported, NeverSupported);
843 AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, AlwaysSupported, NeverSupported, NeverSupported);
844 AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, AlwaysSupported, NeverSupported, NeverSupported);
Kai Ninomiya02f075c2016-12-22 14:55:46 -0800845
Geoff Lang60ad73d2015-10-23 10:08:44 -0400846 // From KHR_texture_compression_astc_hdr
Yuly Novikovf15f8862018-06-04 18:59:41 -0400847 // | Internal format | W | H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
848 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
849 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 5, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
850 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x5_KHR, 5, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
851 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 6, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
852 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x6_KHR, 6, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
853 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 8, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
854 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, 8, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
855 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 8, 8, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
856 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x5_KHR, 10, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
857 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x6_KHR, 10, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
858 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x8_KHR, 10, 8, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
859 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x10_KHR, 10, 10, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
860 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_12x10_KHR, 12, 10, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
861 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_12x12_KHR, 12, 12, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
Geoff Lang60ad73d2015-10-23 10:08:44 -0400862
Yuly Novikovf15f8862018-06-04 18:59:41 -0400863 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
864 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, 5, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
865 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, 5, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
866 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, 6, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
867 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, 6, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
868 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, 8, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
869 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, 8, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
870 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, 8, 8, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
871 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, 10, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
872 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, 10, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
873 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, 10, 8, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
874 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 10, 10, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
875 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 12, 10, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
876 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 12, 12, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
Geoff Lang60ad73d2015-10-23 10:08:44 -0400877
Olli Etuahof2ed2992018-10-04 13:54:42 +0300878 // From EXT_texture_compression_bptc
879 // | Internal format | W | H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
880 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
881 AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
882 AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, 4, 4, 128, 4, GL_RGB, GL_FLOAT, false, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
883 AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, 4, 4, 128, 4, GL_RGB, GL_FLOAT, false, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
884
Corentin Walleze0902642014-11-04 12:32:15 -0800885 // For STENCIL_INDEX8 we chose a normalized component type for the following reasons:
886 // - Multisampled buffer are disallowed for non-normalized integer component types and we want to support it for STENCIL_INDEX8
887 // - All other stencil formats (all depth-stencil) are either float or normalized
888 // - It affects only validation of internalformat in RenderbufferStorageMultisample.
Yuly Novikovf15f8862018-06-04 18:59:41 -0400889 // | Internal format |sized|D |S |X | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
890 AddDepthStencilFormat(&map, GL_STENCIL_INDEX8, true, 0, 8, 0, GL_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<1, 0>, NeverSupported, RequireES<1, 0>, RequireES<1, 0>);
Minmin Gonge3939b92015-12-01 15:36:51 -0800891
892 // From GL_ANGLE_lossy_etc_decode
Yuly Novikovf15f8862018-06-04 18:59:41 -0400893 // | Internal format |W |H |BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
894 AddCompressedFormat(&map, GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, AlwaysSupported, NeverSupported, NeverSupported);
895 AddCompressedFormat(&map, GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, AlwaysSupported, NeverSupported, NeverSupported);
896 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::lossyETCDecode>, AlwaysSupported, NeverSupported, NeverSupported);
897 AddCompressedFormat(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 64, 3, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, AlwaysSupported, NeverSupported, NeverSupported);
898 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 64, 3, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::lossyETCDecode>, AlwaysSupported, NeverSupported, NeverSupported);
Minmin Gonge3939b92015-12-01 15:36:51 -0800899
Vincent Lang25ab4512016-05-13 18:13:59 +0200900 // From GL_EXT_texture_norm16
Yuly Novikovf15f8862018-06-04 18:59:41 -0400901 // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
902 AddRGBAFormat(&map, GL_R16_EXT, true, 16, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>);
903 AddRGBAFormat(&map, GL_R16_SNORM_EXT, true, 16, 0, 0, 0, 0, GL_RED, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, NeverSupported, NeverSupported );
904 AddRGBAFormat(&map, GL_RG16_EXT, true, 16, 16, 0, 0, 0, GL_RG, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>);
905 AddRGBAFormat(&map, GL_RG16_SNORM_EXT, true, 16, 16, 0, 0, 0, GL_RG, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, NeverSupported, NeverSupported );
906 AddRGBAFormat(&map, GL_RGB16_EXT, true, 16, 16, 16, 0, 0, GL_RGB, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, NeverSupported, NeverSupported );
907 AddRGBAFormat(&map, GL_RGB16_SNORM_EXT, true, 16, 16, 16, 0, 0, GL_RGB, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, NeverSupported, NeverSupported );
908 AddRGBAFormat(&map, GL_RGBA16_EXT, true, 16, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>);
909 AddRGBAFormat(&map, GL_RGBA16_SNORM_EXT, true, 16, 16, 16, 16, 0, GL_RGBA, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, NeverSupported, NeverSupported );
Vincent Lang25ab4512016-05-13 18:13:59 +0200910
Geoff Langca271392017-04-05 12:30:00 -0400911 // Unsized formats
Yuly Novikovd0828192018-06-15 15:51:07 -0400912 // | Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
913 AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, RequireExt<&Extensions::textureRG>, NeverSupported);
914 AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
915 AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, RequireExt<&Extensions::textureRG>, NeverSupported);
916 AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
917 AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
918 AddRGBAFormat(&map, GL_RGB, false, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
919 AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
920 AddRGBAFormat(&map, GL_RGBA, false, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
921 AddRGBAFormat(&map, GL_RGBA, false, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
922 AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
923 AddRGBAFormat(&map, GL_RGBA, false, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
924 AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
925 AddRGBAFormat(&map, GL_SRGB, false, 8, 8, 8, 0, 0, GL_SRGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, AlwaysSupported, NeverSupported, NeverSupported);
926 AddRGBAFormat(&map, GL_SRGB_ALPHA_EXT, false, 8, 8, 8, 8, 0, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, AlwaysSupported, RequireExt<&Extensions::sRGB>, NeverSupported);
927 AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888>, NeverSupported);
Geoff Langca271392017-04-05 12:30:00 -0400928
929 // Unsized integer formats
Yuly Novikovf15f8862018-06-04 18:59:41 -0400930 // |Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
931 AddRGBAFormat(&map, GL_RED_INTEGER, false, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
932 AddRGBAFormat(&map, GL_RED_INTEGER, false, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
933 AddRGBAFormat(&map, GL_RED_INTEGER, false, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
934 AddRGBAFormat(&map, GL_RED_INTEGER, false, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
935 AddRGBAFormat(&map, GL_RED_INTEGER, false, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
936 AddRGBAFormat(&map, GL_RED_INTEGER, false, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
937 AddRGBAFormat(&map, GL_RG_INTEGER, false, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
938 AddRGBAFormat(&map, GL_RG_INTEGER, false, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
939 AddRGBAFormat(&map, GL_RG_INTEGER, false, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
940 AddRGBAFormat(&map, GL_RG_INTEGER, false, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
941 AddRGBAFormat(&map, GL_RG_INTEGER, false, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
942 AddRGBAFormat(&map, GL_RG_INTEGER, false, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
943 AddRGBAFormat(&map, GL_RGB_INTEGER, false, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
944 AddRGBAFormat(&map, GL_RGB_INTEGER, false, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
945 AddRGBAFormat(&map, GL_RGB_INTEGER, false, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
946 AddRGBAFormat(&map, GL_RGB_INTEGER, false, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
947 AddRGBAFormat(&map, GL_RGB_INTEGER, false, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
948 AddRGBAFormat(&map, GL_RGB_INTEGER, false, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
949 AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
950 AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
951 AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
952 AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
953 AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
954 AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
955 AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported);
Geoff Langca271392017-04-05 12:30:00 -0400956
957 // Unsized floating point formats
Geoff Lang979f3bb2019-03-14 10:23:29 -0400958 // |Internal format |sized | R | G | B | A |S | Format | Type | Comp | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
959 AddRGBAFormat(&map, GL_RED, false, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
960 AddRGBAFormat(&map, GL_RG, false, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
961 AddRGBAFormat(&map, GL_RGB, false, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
962 AddRGBAFormat(&map, GL_RGBA, false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
963 AddRGBAFormat(&map, GL_RED, false, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
964 AddRGBAFormat(&map, GL_RG, false, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
965 AddRGBAFormat(&map, GL_RGB, false, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, RequireExtAndExt<&Extensions::colorBufferHalfFloat, &Extensions::webglCompatibility>, NeverSupported);
966 AddRGBAFormat(&map, GL_RGBA, false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, RequireExt<&Extensions::colorBufferHalfFloat>, NeverSupported);
967 AddRGBAFormat(&map, GL_RED, false, 32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
968 AddRGBAFormat(&map, GL_RG, false, 32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
969 AddRGBAFormat(&map, GL_RGB, false, 32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
970 AddRGBAFormat(&map, GL_RGB, false, 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
971 AddRGBAFormat(&map, GL_RGB, false, 11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
972 AddRGBAFormat(&map, GL_RGBA, false, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
Geoff Langca271392017-04-05 12:30:00 -0400973
974 // Unsized luminance alpha formats
Yuly Novikovf15f8862018-06-04 18:59:41 -0400975 // | Internal format |sized | L | A | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
Yuly Novikovd0828192018-06-15 15:51:07 -0400976 AddLUMAFormat(&map, GL_ALPHA, false, 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, NeverSupported, NeverSupported);
977 AddLUMAFormat(&map, GL_LUMINANCE, false, 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, NeverSupported, NeverSupported);
978 AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, NeverSupported, NeverSupported);
Yuly Novikovf15f8862018-06-04 18:59:41 -0400979 AddLUMAFormat(&map, GL_ALPHA, false, 0, 16, GL_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
980 AddLUMAFormat(&map, GL_LUMINANCE, false, 16, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
981 AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
982 AddLUMAFormat(&map, GL_ALPHA, false, 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
983 AddLUMAFormat(&map, GL_LUMINANCE, false, 32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
984 AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
Geoff Langca271392017-04-05 12:30:00 -0400985
986 // Unsized depth stencil formats
Yuly Novikovf15f8862018-06-04 18:59:41 -0400987 // | Internal format |sized | D |S | X | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
988 AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<1, 0>, AlwaysSupported, RequireES<1, 0>, RequireES<1, 0> );
989 AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<1, 0>, AlwaysSupported, RequireES<1, 0>, RequireES<1, 0> );
990 AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<1, 0>, AlwaysSupported, RequireES<1, 0>, RequireES<1, 0> );
991 AddDepthStencilFormat(&map, GL_DEPTH_STENCIL, false, 24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>);
992 AddDepthStencilFormat(&map, GL_DEPTH_STENCIL, false, 32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>);
993 AddDepthStencilFormat(&map, GL_STENCIL, false, 0, 8, 0, GL_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<1, 0>, NeverSupported , RequireES<1, 0>, RequireES<1, 0> );
Geoff Lang9bbad182015-09-04 11:07:29 -0400994 // clang-format on
Corentin Walleze0902642014-11-04 12:32:15 -0800995
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000996 return map;
997}
998
Geoff Lange4a492b2014-06-19 14:14:41 -0400999static const InternalFormatInfoMap &GetInternalFormatMap()
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001000{
Geoff Lange4a492b2014-06-19 14:14:41 -04001001 static const InternalFormatInfoMap formatMap = BuildInternalFormatInfoMap();
1002 return formatMap;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001003}
1004
Geoff Lange4a492b2014-06-19 14:14:41 -04001005static FormatSet BuildAllSizedInternalFormatSet()
Geoff Langcec35902014-04-16 10:52:36 -04001006{
1007 FormatSet result;
1008
Geoff Langca271392017-04-05 12:30:00 -04001009 for (const auto &internalFormat : GetInternalFormatMap())
Geoff Langcec35902014-04-16 10:52:36 -04001010 {
Geoff Langca271392017-04-05 12:30:00 -04001011 for (const auto &type : internalFormat.second)
Geoff Langcec35902014-04-16 10:52:36 -04001012 {
Geoff Langca271392017-04-05 12:30:00 -04001013 if (type.second.sized)
1014 {
1015 // TODO(jmadill): Fix this hack.
1016 if (internalFormat.first == GL_BGR565_ANGLEX)
1017 continue;
Jamie Madillec0b5802016-07-04 13:11:59 -04001018
Geoff Langca271392017-04-05 12:30:00 -04001019 result.insert(internalFormat.first);
1020 }
Geoff Langcec35902014-04-16 10:52:36 -04001021 }
1022 }
1023
1024 return result;
1025}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001026
Markus Tavenrath0d665132018-11-18 15:47:02 +01001027uint32_t GetPackedTypeInfo(GLenum type)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001028{
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001029 switch (type)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001030 {
Frank Henigman95fb2a12018-05-27 20:17:05 -04001031 case GL_UNSIGNED_BYTE:
1032 case GL_BYTE:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001033 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001034 static constexpr uint32_t kPacked = PackTypeInfo(1, false);
1035 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001036 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001037 case GL_UNSIGNED_SHORT:
1038 case GL_SHORT:
1039 case GL_HALF_FLOAT:
1040 case GL_HALF_FLOAT_OES:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001041 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001042 static constexpr uint32_t kPacked = PackTypeInfo(2, false);
1043 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001044 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001045 case GL_UNSIGNED_INT:
1046 case GL_INT:
1047 case GL_FLOAT:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001048 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001049 static constexpr uint32_t kPacked = PackTypeInfo(4, false);
1050 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001051 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001052 case GL_UNSIGNED_SHORT_5_6_5:
1053 case GL_UNSIGNED_SHORT_4_4_4_4:
1054 case GL_UNSIGNED_SHORT_5_5_5_1:
1055 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1056 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001057 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001058 static constexpr uint32_t kPacked = PackTypeInfo(2, true);
1059 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001060 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001061 case GL_UNSIGNED_INT_2_10_10_10_REV:
1062 case GL_UNSIGNED_INT_24_8:
1063 case GL_UNSIGNED_INT_10F_11F_11F_REV:
1064 case GL_UNSIGNED_INT_5_9_9_9_REV:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001065 {
1066 ASSERT(GL_UNSIGNED_INT_24_8_OES == GL_UNSIGNED_INT_24_8);
Markus Tavenrath0d665132018-11-18 15:47:02 +01001067 static constexpr uint32_t kPacked = PackTypeInfo(4, true);
1068 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001069 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001070 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001071 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001072 static constexpr uint32_t kPacked = PackTypeInfo(8, true);
1073 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001074 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001075 default:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001076 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001077 return 0;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001078 }
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001079 }
1080}
1081
Geoff Langca271392017-04-05 12:30:00 -04001082const InternalFormat &GetSizedInternalFormatInfo(GLenum internalFormat)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001083{
Geoff Langca271392017-04-05 12:30:00 -04001084 static const InternalFormat defaultInternalFormat;
Geoff Lang5d601382014-07-22 15:14:06 -04001085 const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
Jamie Madillec0b5802016-07-04 13:11:59 -04001086 auto iter = formatMap.find(internalFormat);
Geoff Langca271392017-04-05 12:30:00 -04001087
1088 // Sized internal formats only have one type per entry
1089 if (iter == formatMap.end() || iter->second.size() != 1)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001090 {
Geoff Lang5d601382014-07-22 15:14:06 -04001091 return defaultInternalFormat;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001092 }
Geoff Langca271392017-04-05 12:30:00 -04001093
1094 const InternalFormat &internalFormatInfo = iter->second.begin()->second;
1095 if (!internalFormatInfo.sized)
1096 {
1097 return defaultInternalFormat;
1098 }
1099
1100 return internalFormatInfo;
1101}
1102
1103const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, GLenum type)
1104{
1105 static const InternalFormat defaultInternalFormat;
1106 const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
1107
1108 auto internalFormatIter = formatMap.find(internalFormat);
1109 if (internalFormatIter == formatMap.end())
1110 {
1111 return defaultInternalFormat;
1112 }
1113
1114 // If the internal format is sized, simply return it without the type check.
1115 if (internalFormatIter->second.size() == 1 && internalFormatIter->second.begin()->second.sized)
1116 {
1117 return internalFormatIter->second.begin()->second;
1118 }
1119
1120 auto typeIter = internalFormatIter->second.find(type);
1121 if (typeIter == internalFormatIter->second.end())
1122 {
1123 return defaultInternalFormat;
1124 }
1125
1126 return typeIter->second;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001127}
1128
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001129GLuint InternalFormat::computePixelBytes(GLenum formatType) const
1130{
1131 const auto &typeInfo = GetTypeInfo(formatType);
1132 GLuint components = typeInfo.specialInterpretation ? 1u : componentCount;
1133 return components * typeInfo.bytes;
1134}
1135
Jamie Madillca2ff382018-07-11 09:01:17 -04001136bool InternalFormat::computeRowPitch(GLenum formatType,
1137 GLsizei width,
1138 GLint alignment,
1139 GLint rowLength,
1140 GLuint *resultOut) const
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001141{
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001142 // Compressed images do not use pack/unpack parameters.
1143 if (compressed)
1144 {
1145 ASSERT(rowLength == 0);
Jamie Madillca2ff382018-07-11 09:01:17 -04001146 return computeCompressedImageSize(Extents(width, 1, 1), resultOut);
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001147 }
1148
Geoff Lang3f234062016-07-13 15:35:45 -04001149 CheckedNumeric<GLuint> checkedWidth(rowLength > 0 ? rowLength : width);
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001150 CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * computePixelBytes(formatType);
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001151
1152 ASSERT(alignment > 0 && isPow2(alignment));
1153 CheckedNumeric<GLuint> checkedAlignment(alignment);
1154 auto aligned = rx::roundUp(checkedRowBytes, checkedAlignment);
Jamie Madillca2ff382018-07-11 09:01:17 -04001155 return CheckedMathResult(aligned, resultOut);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001156}
1157
Jamie Madillca2ff382018-07-11 09:01:17 -04001158bool InternalFormat::computeDepthPitch(GLsizei height,
1159 GLint imageHeight,
1160 GLuint rowPitch,
1161 GLuint *resultOut) const
Corentin Wallez0e487192016-10-03 16:30:38 -04001162{
1163 GLuint rows =
1164 (imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height));
1165 CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1166
Jamie Madillca2ff382018-07-11 09:01:17 -04001167 return CheckedMathResult(checkedRowPitch * rows, resultOut);
Corentin Wallez0e487192016-10-03 16:30:38 -04001168}
1169
Jamie Madillca2ff382018-07-11 09:01:17 -04001170bool InternalFormat::computeDepthPitch(GLenum formatType,
1171 GLsizei width,
1172 GLsizei height,
1173 GLint alignment,
1174 GLint rowLength,
1175 GLint imageHeight,
1176 GLuint *resultOut) const
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001177{
Jamie Madille2e406c2016-06-02 13:04:10 -04001178 GLuint rowPitch = 0;
Jamie Madillca2ff382018-07-11 09:01:17 -04001179 if (!computeRowPitch(formatType, width, alignment, rowLength, &rowPitch))
1180 {
1181 return false;
1182 }
1183 return computeDepthPitch(height, imageHeight, rowPitch, resultOut);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001184}
1185
Jamie Madillca2ff382018-07-11 09:01:17 -04001186bool InternalFormat::computeCompressedImageSize(const Extents &size, GLuint *resultOut) const
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001187{
Jamie Madill513558d2016-06-02 13:04:11 -04001188 CheckedNumeric<GLuint> checkedWidth(size.width);
1189 CheckedNumeric<GLuint> checkedHeight(size.height);
1190 CheckedNumeric<GLuint> checkedDepth(size.depth);
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001191 CheckedNumeric<GLuint> checkedBlockWidth(compressedBlockWidth);
1192 CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight);
Jamie Madille2e406c2016-06-02 13:04:10 -04001193
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001194 ASSERT(compressed);
1195 auto numBlocksWide = (checkedWidth + checkedBlockWidth - 1u) / checkedBlockWidth;
1196 auto numBlocksHigh = (checkedHeight + checkedBlockHeight - 1u) / checkedBlockHeight;
1197 auto bytes = numBlocksWide * numBlocksHigh * pixelBytes * checkedDepth;
Jamie Madillca2ff382018-07-11 09:01:17 -04001198 return CheckedMathResult(bytes, resultOut);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001199}
1200
Jamie Madillca2ff382018-07-11 09:01:17 -04001201bool InternalFormat::computeSkipBytes(GLenum formatType,
1202 GLuint rowPitch,
1203 GLuint depthPitch,
1204 const PixelStoreStateBase &state,
1205 bool is3D,
1206 GLuint *resultOut) const
Minmin Gongadff67b2015-10-14 10:34:45 -04001207{
Olli Etuaho989cac32016-06-08 16:18:49 -07001208 CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1209 CheckedNumeric<GLuint> checkedDepthPitch(depthPitch);
Corentin Wallez886de362016-09-27 10:49:35 -04001210 CheckedNumeric<GLuint> checkedSkipImages(static_cast<GLuint>(state.skipImages));
1211 CheckedNumeric<GLuint> checkedSkipRows(static_cast<GLuint>(state.skipRows));
1212 CheckedNumeric<GLuint> checkedSkipPixels(static_cast<GLuint>(state.skipPixels));
Jeff Gilbert31d3deb2018-05-18 18:32:16 -07001213 CheckedNumeric<GLuint> checkedPixelBytes(computePixelBytes(formatType));
Olli Etuaho989cac32016-06-08 16:18:49 -07001214 auto checkedSkipImagesBytes = checkedSkipImages * checkedDepthPitch;
Corentin Wallez886de362016-09-27 10:49:35 -04001215 if (!is3D)
Olli Etuaho989cac32016-06-08 16:18:49 -07001216 {
1217 checkedSkipImagesBytes = 0;
1218 }
1219 auto skipBytes = checkedSkipImagesBytes + checkedSkipRows * checkedRowPitch +
1220 checkedSkipPixels * checkedPixelBytes;
Jamie Madillca2ff382018-07-11 09:01:17 -04001221 return CheckedMathResult(skipBytes, resultOut);
Minmin Gongadff67b2015-10-14 10:34:45 -04001222}
1223
Jamie Madillca2ff382018-07-11 09:01:17 -04001224bool InternalFormat::computePackUnpackEndByte(GLenum formatType,
1225 const Extents &size,
1226 const PixelStoreStateBase &state,
1227 bool is3D,
1228 GLuint *resultOut) const
Corentin Wallezece7c5a2016-09-21 15:28:23 -04001229{
Corentin Wallez886de362016-09-27 10:49:35 -04001230 GLuint rowPitch = 0;
Jamie Madillca2ff382018-07-11 09:01:17 -04001231 if (!computeRowPitch(formatType, size.width, state.alignment, state.rowLength, &rowPitch))
Corentin Wallez0e487192016-10-03 16:30:38 -04001232 {
Jamie Madillca2ff382018-07-11 09:01:17 -04001233 return false;
Corentin Wallez0e487192016-10-03 16:30:38 -04001234 }
1235
Jamie Madillca2ff382018-07-11 09:01:17 -04001236 GLuint depthPitch = 0;
1237 if (is3D && !computeDepthPitch(size.height, state.imageHeight, rowPitch, &depthPitch))
1238 {
1239 return false;
1240 }
1241
1242 CheckedNumeric<GLuint> checkedCopyBytes(0);
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001243 if (compressed)
1244 {
Jamie Madillca2ff382018-07-11 09:01:17 -04001245 GLuint copyBytes = 0;
1246 if (!computeCompressedImageSize(size, &copyBytes))
1247 {
1248 return false;
1249 }
1250 checkedCopyBytes = copyBytes;
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001251 }
Corentin Wallez886de362016-09-27 10:49:35 -04001252 else if (size.height != 0 && (!is3D || size.depth != 0))
Corentin Wallezece7c5a2016-09-21 15:28:23 -04001253 {
Corentin Wallez886de362016-09-27 10:49:35 -04001254 CheckedNumeric<GLuint> bytes = computePixelBytes(formatType);
1255 checkedCopyBytes += size.width * bytes;
1256
1257 CheckedNumeric<GLuint> heightMinusOne = size.height - 1;
1258 checkedCopyBytes += heightMinusOne * rowPitch;
1259
1260 if (is3D)
1261 {
1262 CheckedNumeric<GLuint> depthMinusOne = size.depth - 1;
1263 checkedCopyBytes += depthMinusOne * depthPitch;
1264 }
Corentin Wallezece7c5a2016-09-21 15:28:23 -04001265 }
1266
Jamie Madillca2ff382018-07-11 09:01:17 -04001267 GLuint skipBytes = 0;
1268 if (!computeSkipBytes(formatType, rowPitch, depthPitch, state, is3D, &skipBytes))
1269 {
1270 return false;
1271 }
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001272
Jamie Madillca2ff382018-07-11 09:01:17 -04001273 CheckedNumeric<GLuint> endByte = checkedCopyBytes + CheckedNumeric<GLuint>(skipBytes);
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001274
Jamie Madillca2ff382018-07-11 09:01:17 -04001275 return CheckedMathResult(endByte, resultOut);
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001276}
1277
Geoff Langca271392017-04-05 12:30:00 -04001278GLenum GetUnsizedFormat(GLenum internalFormat)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001279{
Geoff Langca271392017-04-05 12:30:00 -04001280 auto sizedFormatInfo = GetSizedInternalFormatInfo(internalFormat);
1281 if (sizedFormatInfo.internalFormat != GL_NONE)
Geoff Lang051dbc72015-01-05 15:48:58 -05001282 {
Geoff Langca271392017-04-05 12:30:00 -04001283 return sizedFormatInfo.format;
Geoff Lang051dbc72015-01-05 15:48:58 -05001284 }
Geoff Langca271392017-04-05 12:30:00 -04001285
1286 return internalFormat;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001287}
1288
Geoff Lange4a492b2014-06-19 14:14:41 -04001289const FormatSet &GetAllSizedInternalFormats()
Geoff Langcec35902014-04-16 10:52:36 -04001290{
Geoff Lange4a492b2014-06-19 14:14:41 -04001291 static FormatSet formatSet = BuildAllSizedInternalFormatSet();
Geoff Langcec35902014-04-16 10:52:36 -04001292 return formatSet;
1293}
1294
Jamie Madill09e2d932015-07-14 16:40:31 -04001295AttributeType GetAttributeType(GLenum enumValue)
1296{
1297 switch (enumValue)
1298 {
1299 case GL_FLOAT:
1300 return ATTRIBUTE_FLOAT;
1301 case GL_FLOAT_VEC2:
1302 return ATTRIBUTE_VEC2;
1303 case GL_FLOAT_VEC3:
1304 return ATTRIBUTE_VEC3;
1305 case GL_FLOAT_VEC4:
1306 return ATTRIBUTE_VEC4;
1307 case GL_INT:
1308 return ATTRIBUTE_INT;
1309 case GL_INT_VEC2:
1310 return ATTRIBUTE_IVEC2;
1311 case GL_INT_VEC3:
1312 return ATTRIBUTE_IVEC3;
1313 case GL_INT_VEC4:
1314 return ATTRIBUTE_IVEC4;
1315 case GL_UNSIGNED_INT:
1316 return ATTRIBUTE_UINT;
1317 case GL_UNSIGNED_INT_VEC2:
1318 return ATTRIBUTE_UVEC2;
1319 case GL_UNSIGNED_INT_VEC3:
1320 return ATTRIBUTE_UVEC3;
1321 case GL_UNSIGNED_INT_VEC4:
1322 return ATTRIBUTE_UVEC4;
1323 case GL_FLOAT_MAT2:
1324 return ATTRIBUTE_MAT2;
1325 case GL_FLOAT_MAT3:
1326 return ATTRIBUTE_MAT3;
1327 case GL_FLOAT_MAT4:
1328 return ATTRIBUTE_MAT4;
1329 case GL_FLOAT_MAT2x3:
1330 return ATTRIBUTE_MAT2x3;
1331 case GL_FLOAT_MAT2x4:
1332 return ATTRIBUTE_MAT2x4;
1333 case GL_FLOAT_MAT3x2:
1334 return ATTRIBUTE_MAT3x2;
1335 case GL_FLOAT_MAT3x4:
1336 return ATTRIBUTE_MAT3x4;
1337 case GL_FLOAT_MAT4x2:
1338 return ATTRIBUTE_MAT4x2;
1339 case GL_FLOAT_MAT4x3:
1340 return ATTRIBUTE_MAT4x3;
1341 default:
1342 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001343#if !UNREACHABLE_IS_NORETURN
Jamie Madill09e2d932015-07-14 16:40:31 -04001344 return ATTRIBUTE_FLOAT;
Nico Weberb5db2b42018-02-12 15:31:56 -05001345#endif
Jamie Madill09e2d932015-07-14 16:40:31 -04001346 }
1347}
1348
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001349angle::FormatID GetVertexFormatID(VertexAttribType type,
Jamie Madillba365932018-07-18 17:23:46 -04001350 GLboolean normalized,
1351 GLuint components,
1352 bool pureInteger)
Jamie Madilld3dfda22015-07-06 08:28:49 -04001353{
1354 switch (type)
1355 {
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001356 case VertexAttribType::Byte:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001357 switch (components)
1358 {
1359 case 1:
1360 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001361 return angle::FormatID::R8_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001362 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001363 return angle::FormatID::R8_SNORM;
1364 return angle::FormatID::R8_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001365 case 2:
1366 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001367 return angle::FormatID::R8G8_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001368 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001369 return angle::FormatID::R8G8_SNORM;
1370 return angle::FormatID::R8G8_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001371 case 3:
1372 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001373 return angle::FormatID::R8G8B8_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001374 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001375 return angle::FormatID::R8G8B8_SNORM;
1376 return angle::FormatID::R8G8B8_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001377 case 4:
1378 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001379 return angle::FormatID::R8G8B8A8_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001380 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001381 return angle::FormatID::R8G8B8A8_SNORM;
1382 return angle::FormatID::R8G8B8A8_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001383 default:
1384 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001385#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001386 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001387#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001388 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001389 case VertexAttribType::UnsignedByte:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001390 switch (components)
1391 {
1392 case 1:
1393 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001394 return angle::FormatID::R8_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001395 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001396 return angle::FormatID::R8_UNORM;
1397 return angle::FormatID::R8_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001398 case 2:
1399 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001400 return angle::FormatID::R8G8_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001401 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001402 return angle::FormatID::R8G8_UNORM;
1403 return angle::FormatID::R8G8_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001404 case 3:
1405 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001406 return angle::FormatID::R8G8B8_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001407 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001408 return angle::FormatID::R8G8B8_UNORM;
1409 return angle::FormatID::R8G8B8_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001410 case 4:
1411 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001412 return angle::FormatID::R8G8B8A8_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001413 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001414 return angle::FormatID::R8G8B8A8_UNORM;
1415 return angle::FormatID::R8G8B8A8_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001416 default:
1417 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001418#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001419 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001420#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001421 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001422 case VertexAttribType::Short:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001423 switch (components)
1424 {
1425 case 1:
1426 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001427 return angle::FormatID::R16_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001428 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001429 return angle::FormatID::R16_SNORM;
1430 return angle::FormatID::R16_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001431 case 2:
1432 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001433 return angle::FormatID::R16G16_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001434 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001435 return angle::FormatID::R16G16_SNORM;
1436 return angle::FormatID::R16G16_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001437 case 3:
1438 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001439 return angle::FormatID::R16G16B16_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001440 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001441 return angle::FormatID::R16G16B16_SNORM;
1442 return angle::FormatID::R16G16B16_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001443 case 4:
1444 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001445 return angle::FormatID::R16G16B16A16_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001446 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001447 return angle::FormatID::R16G16B16A16_SNORM;
1448 return angle::FormatID::R16G16B16A16_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001449 default:
1450 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001451#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001452 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001453#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001454 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001455 case VertexAttribType::UnsignedShort:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001456 switch (components)
1457 {
1458 case 1:
1459 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001460 return angle::FormatID::R16_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001461 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001462 return angle::FormatID::R16_UNORM;
1463 return angle::FormatID::R16_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001464 case 2:
1465 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001466 return angle::FormatID::R16G16_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001467 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001468 return angle::FormatID::R16G16_UNORM;
1469 return angle::FormatID::R16G16_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001470 case 3:
1471 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001472 return angle::FormatID::R16G16B16_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001473 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001474 return angle::FormatID::R16G16B16_UNORM;
1475 return angle::FormatID::R16G16B16_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001476 case 4:
1477 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001478 return angle::FormatID::R16G16B16A16_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001479 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001480 return angle::FormatID::R16G16B16A16_UNORM;
1481 return angle::FormatID::R16G16B16A16_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001482 default:
1483 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001484#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001485 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001486#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001487 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001488 case VertexAttribType::Int:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001489 switch (components)
1490 {
1491 case 1:
1492 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001493 return angle::FormatID::R32_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001494 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001495 return angle::FormatID::R32_SNORM;
1496 return angle::FormatID::R32_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001497 case 2:
1498 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001499 return angle::FormatID::R32G32_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001500 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001501 return angle::FormatID::R32G32_SNORM;
1502 return angle::FormatID::R32G32_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001503 case 3:
1504 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001505 return angle::FormatID::R32G32B32_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001506 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001507 return angle::FormatID::R32G32B32_SNORM;
1508 return angle::FormatID::R32G32B32_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001509 case 4:
1510 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001511 return angle::FormatID::R32G32B32A32_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001512 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001513 return angle::FormatID::R32G32B32A32_SNORM;
1514 return angle::FormatID::R32G32B32A32_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001515 default:
1516 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001517#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001518 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001519#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001520 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001521 case VertexAttribType::UnsignedInt:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001522 switch (components)
1523 {
1524 case 1:
1525 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001526 return angle::FormatID::R32_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001527 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001528 return angle::FormatID::R32_UNORM;
1529 return angle::FormatID::R32_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001530 case 2:
1531 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001532 return angle::FormatID::R32G32_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001533 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001534 return angle::FormatID::R32G32_UNORM;
1535 return angle::FormatID::R32G32_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001536 case 3:
1537 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001538 return angle::FormatID::R32G32B32_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001539 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001540 return angle::FormatID::R32G32B32_UNORM;
1541 return angle::FormatID::R32G32B32_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001542 case 4:
1543 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001544 return angle::FormatID::R32G32B32A32_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001545 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001546 return angle::FormatID::R32G32B32A32_UNORM;
1547 return angle::FormatID::R32G32B32A32_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001548 default:
1549 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001550#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001551 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001552#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001553 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001554 case VertexAttribType::Float:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001555 switch (components)
1556 {
1557 case 1:
Jamie Madillba365932018-07-18 17:23:46 -04001558 return angle::FormatID::R32_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001559 case 2:
Jamie Madillba365932018-07-18 17:23:46 -04001560 return angle::FormatID::R32G32_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001561 case 3:
Jamie Madillba365932018-07-18 17:23:46 -04001562 return angle::FormatID::R32G32B32_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001563 case 4:
Jamie Madillba365932018-07-18 17:23:46 -04001564 return angle::FormatID::R32G32B32A32_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001565 default:
1566 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001567#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001568 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001569#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001570 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001571 case VertexAttribType::HalfFloat:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001572 switch (components)
1573 {
1574 case 1:
Jamie Madillba365932018-07-18 17:23:46 -04001575 return angle::FormatID::R16_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001576 case 2:
Jamie Madillba365932018-07-18 17:23:46 -04001577 return angle::FormatID::R16G16_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001578 case 3:
Jamie Madillba365932018-07-18 17:23:46 -04001579 return angle::FormatID::R16G16B16_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001580 case 4:
Jamie Madillba365932018-07-18 17:23:46 -04001581 return angle::FormatID::R16G16B16A16_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001582 default:
1583 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001584#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001585 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001586#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001587 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001588 case VertexAttribType::Fixed:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001589 switch (components)
1590 {
1591 case 1:
Jamie Madillba365932018-07-18 17:23:46 -04001592 return angle::FormatID::R32_FIXED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001593 case 2:
Jamie Madillba365932018-07-18 17:23:46 -04001594 return angle::FormatID::R32G32_FIXED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001595 case 3:
Jamie Madillba365932018-07-18 17:23:46 -04001596 return angle::FormatID::R32G32B32_FIXED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001597 case 4:
Jamie Madillba365932018-07-18 17:23:46 -04001598 return angle::FormatID::R32G32B32A32_FIXED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001599 default:
1600 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001601#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001602 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001603#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001604 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001605 case VertexAttribType::Int2101010:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001606 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001607 return angle::FormatID::R10G10B10A2_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001608 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001609 return angle::FormatID::R10G10B10A2_SNORM;
1610 return angle::FormatID::R10G10B10A2_SSCALED;
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001611 case VertexAttribType::UnsignedInt2101010:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001612 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001613 return angle::FormatID::R10G10B10A2_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001614 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001615 return angle::FormatID::R10G10B10A2_UNORM;
1616 return angle::FormatID::R10G10B10A2_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001617 default:
1618 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001619#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001620 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001621#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001622 }
Jamie Madilld3dfda22015-07-06 08:28:49 -04001623}
1624
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001625angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribType currentValueType)
Jamie Madilld3dfda22015-07-06 08:28:49 -04001626{
1627 if (!attrib.enabled)
1628 {
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001629 return GetVertexFormatID(currentValueType, GL_FALSE, 4,
1630 (currentValueType != VertexAttribType::Float));
Jamie Madilld3dfda22015-07-06 08:28:49 -04001631 }
Frank Henigmand633b152018-10-04 23:34:31 -04001632 return GetVertexFormatID(attrib);
Jamie Madilld3dfda22015-07-06 08:28:49 -04001633}
1634
Frank Henigmand633b152018-10-04 23:34:31 -04001635const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID)
Jamie Madilld3dfda22015-07-06 08:28:49 -04001636{
Frank Henigmand633b152018-10-04 23:34:31 -04001637 switch (vertexFormatID)
Jamie Madilld3dfda22015-07-06 08:28:49 -04001638 {
Frank Henigmand633b152018-10-04 23:34:31 -04001639 case angle::FormatID::R8_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001640 {
1641 static const VertexFormat format(GL_BYTE, GL_FALSE, 1, false);
1642 return format;
1643 }
Frank Henigmand633b152018-10-04 23:34:31 -04001644 case angle::FormatID::R8_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001645 {
1646 static const VertexFormat format(GL_BYTE, GL_TRUE, 1, false);
1647 return format;
1648 }
Frank Henigmand633b152018-10-04 23:34:31 -04001649 case angle::FormatID::R8G8_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001650 {
1651 static const VertexFormat format(GL_BYTE, GL_FALSE, 2, false);
1652 return format;
1653 }
Frank Henigmand633b152018-10-04 23:34:31 -04001654 case angle::FormatID::R8G8_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001655 {
1656 static const VertexFormat format(GL_BYTE, GL_TRUE, 2, false);
1657 return format;
1658 }
Frank Henigmand633b152018-10-04 23:34:31 -04001659 case angle::FormatID::R8G8B8_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001660 {
1661 static const VertexFormat format(GL_BYTE, GL_FALSE, 3, false);
1662 return format;
1663 }
Frank Henigmand633b152018-10-04 23:34:31 -04001664 case angle::FormatID::R8G8B8_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001665 {
1666 static const VertexFormat format(GL_BYTE, GL_TRUE, 3, false);
1667 return format;
1668 }
Frank Henigmand633b152018-10-04 23:34:31 -04001669 case angle::FormatID::R8G8B8A8_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001670 {
1671 static const VertexFormat format(GL_BYTE, GL_FALSE, 4, false);
1672 return format;
1673 }
Frank Henigmand633b152018-10-04 23:34:31 -04001674 case angle::FormatID::R8G8B8A8_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001675 {
1676 static const VertexFormat format(GL_BYTE, GL_TRUE, 4, false);
1677 return format;
1678 }
Frank Henigmand633b152018-10-04 23:34:31 -04001679 case angle::FormatID::R8_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001680 {
1681 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, false);
1682 return format;
1683 }
Frank Henigmand633b152018-10-04 23:34:31 -04001684 case angle::FormatID::R8_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001685 {
1686 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 1, false);
1687 return format;
1688 }
Frank Henigmand633b152018-10-04 23:34:31 -04001689 case angle::FormatID::R8G8_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001690 {
1691 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, false);
1692 return format;
1693 }
Frank Henigmand633b152018-10-04 23:34:31 -04001694 case angle::FormatID::R8G8_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001695 {
1696 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 2, false);
1697 return format;
1698 }
Frank Henigmand633b152018-10-04 23:34:31 -04001699 case angle::FormatID::R8G8B8_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001700 {
1701 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, false);
1702 return format;
1703 }
Frank Henigmand633b152018-10-04 23:34:31 -04001704 case angle::FormatID::R8G8B8_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001705 {
1706 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 3, false);
1707 return format;
1708 }
Frank Henigmand633b152018-10-04 23:34:31 -04001709 case angle::FormatID::R8G8B8A8_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001710 {
1711 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, false);
1712 return format;
1713 }
Frank Henigmand633b152018-10-04 23:34:31 -04001714 case angle::FormatID::R8G8B8A8_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001715 {
1716 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 4, false);
1717 return format;
1718 }
Frank Henigmand633b152018-10-04 23:34:31 -04001719 case angle::FormatID::R16_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001720 {
1721 static const VertexFormat format(GL_SHORT, GL_FALSE, 1, false);
1722 return format;
1723 }
Frank Henigmand633b152018-10-04 23:34:31 -04001724 case angle::FormatID::R16_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001725 {
1726 static const VertexFormat format(GL_SHORT, GL_TRUE, 1, false);
1727 return format;
1728 }
Frank Henigmand633b152018-10-04 23:34:31 -04001729 case angle::FormatID::R16G16_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001730 {
1731 static const VertexFormat format(GL_SHORT, GL_FALSE, 2, false);
1732 return format;
1733 }
Frank Henigmand633b152018-10-04 23:34:31 -04001734 case angle::FormatID::R16G16_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001735 {
1736 static const VertexFormat format(GL_SHORT, GL_TRUE, 2, false);
1737 return format;
1738 }
Frank Henigmand633b152018-10-04 23:34:31 -04001739 case angle::FormatID::R16G16B16_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001740 {
1741 static const VertexFormat format(GL_SHORT, GL_FALSE, 3, false);
1742 return format;
1743 }
Frank Henigmand633b152018-10-04 23:34:31 -04001744 case angle::FormatID::R16G16B16_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001745 {
1746 static const VertexFormat format(GL_SHORT, GL_TRUE, 3, false);
1747 return format;
1748 }
Frank Henigmand633b152018-10-04 23:34:31 -04001749 case angle::FormatID::R16G16B16A16_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001750 {
1751 static const VertexFormat format(GL_SHORT, GL_FALSE, 4, false);
1752 return format;
1753 }
Frank Henigmand633b152018-10-04 23:34:31 -04001754 case angle::FormatID::R16G16B16A16_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001755 {
1756 static const VertexFormat format(GL_SHORT, GL_TRUE, 4, false);
1757 return format;
1758 }
Frank Henigmand633b152018-10-04 23:34:31 -04001759 case angle::FormatID::R16_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001760 {
1761 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, false);
1762 return format;
1763 }
Frank Henigmand633b152018-10-04 23:34:31 -04001764 case angle::FormatID::R16_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001765 {
1766 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 1, false);
1767 return format;
1768 }
Frank Henigmand633b152018-10-04 23:34:31 -04001769 case angle::FormatID::R16G16_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001770 {
1771 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, false);
1772 return format;
1773 }
Frank Henigmand633b152018-10-04 23:34:31 -04001774 case angle::FormatID::R16G16_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001775 {
1776 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 2, false);
1777 return format;
1778 }
Frank Henigmand633b152018-10-04 23:34:31 -04001779 case angle::FormatID::R16G16B16_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001780 {
1781 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, false);
1782 return format;
1783 }
Frank Henigmand633b152018-10-04 23:34:31 -04001784 case angle::FormatID::R16G16B16_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001785 {
1786 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 3, false);
1787 return format;
1788 }
Frank Henigmand633b152018-10-04 23:34:31 -04001789 case angle::FormatID::R16G16B16A16_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001790 {
1791 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, false);
1792 return format;
1793 }
Frank Henigmand633b152018-10-04 23:34:31 -04001794 case angle::FormatID::R16G16B16A16_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001795 {
1796 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 4, false);
1797 return format;
1798 }
Frank Henigmand633b152018-10-04 23:34:31 -04001799 case angle::FormatID::R32_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001800 {
1801 static const VertexFormat format(GL_INT, GL_FALSE, 1, false);
1802 return format;
1803 }
Frank Henigmand633b152018-10-04 23:34:31 -04001804 case angle::FormatID::R32_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001805 {
1806 static const VertexFormat format(GL_INT, GL_TRUE, 1, false);
1807 return format;
1808 }
Frank Henigmand633b152018-10-04 23:34:31 -04001809 case angle::FormatID::R32G32_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001810 {
1811 static const VertexFormat format(GL_INT, GL_FALSE, 2, false);
1812 return format;
1813 }
Frank Henigmand633b152018-10-04 23:34:31 -04001814 case angle::FormatID::R32G32_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001815 {
1816 static const VertexFormat format(GL_INT, GL_TRUE, 2, false);
1817 return format;
1818 }
Frank Henigmand633b152018-10-04 23:34:31 -04001819 case angle::FormatID::R32G32B32_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001820 {
1821 static const VertexFormat format(GL_INT, GL_FALSE, 3, false);
1822 return format;
1823 }
Frank Henigmand633b152018-10-04 23:34:31 -04001824 case angle::FormatID::R32G32B32_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001825 {
1826 static const VertexFormat format(GL_INT, GL_TRUE, 3, false);
1827 return format;
1828 }
Frank Henigmand633b152018-10-04 23:34:31 -04001829 case angle::FormatID::R32G32B32A32_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001830 {
1831 static const VertexFormat format(GL_INT, GL_FALSE, 4, false);
1832 return format;
1833 }
Frank Henigmand633b152018-10-04 23:34:31 -04001834 case angle::FormatID::R32G32B32A32_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001835 {
1836 static const VertexFormat format(GL_INT, GL_TRUE, 4, false);
1837 return format;
1838 }
Frank Henigmand633b152018-10-04 23:34:31 -04001839 case angle::FormatID::R32_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001840 {
1841 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, false);
1842 return format;
1843 }
Frank Henigmand633b152018-10-04 23:34:31 -04001844 case angle::FormatID::R32_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001845 {
1846 static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 1, false);
1847 return format;
1848 }
Frank Henigmand633b152018-10-04 23:34:31 -04001849 case angle::FormatID::R32G32_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001850 {
1851 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, false);
1852 return format;
1853 }
Frank Henigmand633b152018-10-04 23:34:31 -04001854 case angle::FormatID::R32G32_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001855 {
1856 static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 2, false);
1857 return format;
1858 }
Frank Henigmand633b152018-10-04 23:34:31 -04001859 case angle::FormatID::R32G32B32_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001860 {
1861 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, false);
1862 return format;
1863 }
Frank Henigmand633b152018-10-04 23:34:31 -04001864 case angle::FormatID::R32G32B32_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001865 {
1866 static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 3, false);
1867 return format;
1868 }
Frank Henigmand633b152018-10-04 23:34:31 -04001869 case angle::FormatID::R32G32B32A32_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001870 {
1871 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, false);
1872 return format;
1873 }
Frank Henigmand633b152018-10-04 23:34:31 -04001874 case angle::FormatID::R32G32B32A32_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001875 {
1876 static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 4, false);
1877 return format;
1878 }
Frank Henigmand633b152018-10-04 23:34:31 -04001879 case angle::FormatID::R8_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001880 {
1881 static const VertexFormat format(GL_BYTE, GL_FALSE, 1, true);
1882 return format;
1883 }
Frank Henigmand633b152018-10-04 23:34:31 -04001884 case angle::FormatID::R8G8_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001885 {
1886 static const VertexFormat format(GL_BYTE, GL_FALSE, 2, true);
1887 return format;
1888 }
Frank Henigmand633b152018-10-04 23:34:31 -04001889 case angle::FormatID::R8G8B8_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001890 {
1891 static const VertexFormat format(GL_BYTE, GL_FALSE, 3, true);
1892 return format;
1893 }
Frank Henigmand633b152018-10-04 23:34:31 -04001894 case angle::FormatID::R8G8B8A8_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001895 {
1896 static const VertexFormat format(GL_BYTE, GL_FALSE, 4, true);
1897 return format;
1898 }
Frank Henigmand633b152018-10-04 23:34:31 -04001899 case angle::FormatID::R8_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001900 {
1901 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, true);
1902 return format;
1903 }
Frank Henigmand633b152018-10-04 23:34:31 -04001904 case angle::FormatID::R8G8_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001905 {
1906 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, true);
1907 return format;
1908 }
Frank Henigmand633b152018-10-04 23:34:31 -04001909 case angle::FormatID::R8G8B8_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001910 {
1911 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, true);
1912 return format;
1913 }
Frank Henigmand633b152018-10-04 23:34:31 -04001914 case angle::FormatID::R8G8B8A8_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001915 {
1916 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, true);
1917 return format;
1918 }
Frank Henigmand633b152018-10-04 23:34:31 -04001919 case angle::FormatID::R16_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001920 {
1921 static const VertexFormat format(GL_SHORT, GL_FALSE, 1, true);
1922 return format;
1923 }
Frank Henigmand633b152018-10-04 23:34:31 -04001924 case angle::FormatID::R16G16_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001925 {
1926 static const VertexFormat format(GL_SHORT, GL_FALSE, 2, true);
1927 return format;
1928 }
Frank Henigmand633b152018-10-04 23:34:31 -04001929 case angle::FormatID::R16G16B16_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001930 {
1931 static const VertexFormat format(GL_SHORT, GL_FALSE, 3, true);
1932 return format;
1933 }
Frank Henigmand633b152018-10-04 23:34:31 -04001934 case angle::FormatID::R16G16B16A16_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001935 {
1936 static const VertexFormat format(GL_SHORT, GL_FALSE, 4, true);
1937 return format;
1938 }
Frank Henigmand633b152018-10-04 23:34:31 -04001939 case angle::FormatID::R16_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001940 {
1941 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, true);
1942 return format;
1943 }
Frank Henigmand633b152018-10-04 23:34:31 -04001944 case angle::FormatID::R16G16_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001945 {
1946 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, true);
1947 return format;
1948 }
Frank Henigmand633b152018-10-04 23:34:31 -04001949 case angle::FormatID::R16G16B16_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001950 {
1951 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, true);
1952 return format;
1953 }
Frank Henigmand633b152018-10-04 23:34:31 -04001954 case angle::FormatID::R16G16B16A16_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001955 {
1956 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, true);
1957 return format;
1958 }
Frank Henigmand633b152018-10-04 23:34:31 -04001959 case angle::FormatID::R32_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001960 {
1961 static const VertexFormat format(GL_INT, GL_FALSE, 1, true);
1962 return format;
1963 }
Frank Henigmand633b152018-10-04 23:34:31 -04001964 case angle::FormatID::R32G32_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001965 {
1966 static const VertexFormat format(GL_INT, GL_FALSE, 2, true);
1967 return format;
1968 }
Frank Henigmand633b152018-10-04 23:34:31 -04001969 case angle::FormatID::R32G32B32_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001970 {
1971 static const VertexFormat format(GL_INT, GL_FALSE, 3, true);
1972 return format;
1973 }
Frank Henigmand633b152018-10-04 23:34:31 -04001974 case angle::FormatID::R32G32B32A32_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001975 {
1976 static const VertexFormat format(GL_INT, GL_FALSE, 4, true);
1977 return format;
1978 }
Frank Henigmand633b152018-10-04 23:34:31 -04001979 case angle::FormatID::R32_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001980 {
1981 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, true);
1982 return format;
1983 }
Frank Henigmand633b152018-10-04 23:34:31 -04001984 case angle::FormatID::R32G32_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001985 {
1986 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, true);
1987 return format;
1988 }
Frank Henigmand633b152018-10-04 23:34:31 -04001989 case angle::FormatID::R32G32B32_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001990 {
1991 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, true);
1992 return format;
1993 }
Frank Henigmand633b152018-10-04 23:34:31 -04001994 case angle::FormatID::R32G32B32A32_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001995 {
1996 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, true);
1997 return format;
1998 }
Frank Henigmand633b152018-10-04 23:34:31 -04001999 case angle::FormatID::R32_FIXED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002000 {
2001 static const VertexFormat format(GL_FIXED, GL_FALSE, 1, false);
2002 return format;
2003 }
Frank Henigmand633b152018-10-04 23:34:31 -04002004 case angle::FormatID::R32G32_FIXED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002005 {
2006 static const VertexFormat format(GL_FIXED, GL_FALSE, 2, false);
2007 return format;
2008 }
Frank Henigmand633b152018-10-04 23:34:31 -04002009 case angle::FormatID::R32G32B32_FIXED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002010 {
2011 static const VertexFormat format(GL_FIXED, GL_FALSE, 3, false);
2012 return format;
2013 }
Frank Henigmand633b152018-10-04 23:34:31 -04002014 case angle::FormatID::R32G32B32A32_FIXED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002015 {
2016 static const VertexFormat format(GL_FIXED, GL_FALSE, 4, false);
2017 return format;
2018 }
Frank Henigmand633b152018-10-04 23:34:31 -04002019 case angle::FormatID::R16_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002020 {
2021 static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 1, false);
2022 return format;
2023 }
Frank Henigmand633b152018-10-04 23:34:31 -04002024 case angle::FormatID::R16G16_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002025 {
2026 static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 2, false);
2027 return format;
2028 }
Frank Henigmand633b152018-10-04 23:34:31 -04002029 case angle::FormatID::R16G16B16_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002030 {
2031 static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 3, false);
2032 return format;
2033 }
Frank Henigmand633b152018-10-04 23:34:31 -04002034 case angle::FormatID::R16G16B16A16_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002035 {
2036 static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 4, false);
2037 return format;
2038 }
Frank Henigmand633b152018-10-04 23:34:31 -04002039 case angle::FormatID::R32_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002040 {
2041 static const VertexFormat format(GL_FLOAT, GL_FALSE, 1, false);
2042 return format;
2043 }
Frank Henigmand633b152018-10-04 23:34:31 -04002044 case angle::FormatID::R32G32_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002045 {
2046 static const VertexFormat format(GL_FLOAT, GL_FALSE, 2, false);
2047 return format;
2048 }
Frank Henigmand633b152018-10-04 23:34:31 -04002049 case angle::FormatID::R32G32B32_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002050 {
2051 static const VertexFormat format(GL_FLOAT, GL_FALSE, 3, false);
2052 return format;
2053 }
Frank Henigmand633b152018-10-04 23:34:31 -04002054 case angle::FormatID::R32G32B32A32_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002055 {
2056 static const VertexFormat format(GL_FLOAT, GL_FALSE, 4, false);
2057 return format;
2058 }
Frank Henigmand633b152018-10-04 23:34:31 -04002059 case angle::FormatID::R10G10B10A2_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002060 {
2061 static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, false);
2062 return format;
2063 }
Frank Henigmand633b152018-10-04 23:34:31 -04002064 case angle::FormatID::R10G10B10A2_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002065 {
2066 static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, false);
2067 return format;
2068 }
Frank Henigmand633b152018-10-04 23:34:31 -04002069 case angle::FormatID::R10G10B10A2_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002070 {
2071 static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_TRUE, 4, false);
2072 return format;
2073 }
Frank Henigmand633b152018-10-04 23:34:31 -04002074 case angle::FormatID::R10G10B10A2_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002075 {
2076 static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 4, false);
2077 return format;
2078 }
Frank Henigmand633b152018-10-04 23:34:31 -04002079 case angle::FormatID::R10G10B10A2_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002080 {
2081 static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, true);
2082 return format;
2083 }
Frank Henigmand633b152018-10-04 23:34:31 -04002084 case angle::FormatID::R10G10B10A2_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002085 {
2086 static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, true);
2087 return format;
2088 }
2089 default:
2090 {
2091 static const VertexFormat format(GL_NONE, GL_FALSE, 0, false);
2092 return format;
2093 }
2094 }
2095}
2096
Frank Henigmand633b152018-10-04 23:34:31 -04002097size_t GetVertexFormatSize(angle::FormatID vertexFormatID)
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002098{
Frank Henigmand633b152018-10-04 23:34:31 -04002099 switch (vertexFormatID)
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002100 {
Frank Henigmand633b152018-10-04 23:34:31 -04002101 case angle::FormatID::R8_SSCALED:
2102 case angle::FormatID::R8_SNORM:
2103 case angle::FormatID::R8_USCALED:
2104 case angle::FormatID::R8_UNORM:
2105 case angle::FormatID::R8_SINT:
2106 case angle::FormatID::R8_UINT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002107 return 1;
2108
Frank Henigmand633b152018-10-04 23:34:31 -04002109 case angle::FormatID::R8G8_SSCALED:
2110 case angle::FormatID::R8G8_SNORM:
2111 case angle::FormatID::R8G8_USCALED:
2112 case angle::FormatID::R8G8_UNORM:
2113 case angle::FormatID::R8G8_SINT:
2114 case angle::FormatID::R8G8_UINT:
2115 case angle::FormatID::R16_SSCALED:
2116 case angle::FormatID::R16_SNORM:
2117 case angle::FormatID::R16_USCALED:
2118 case angle::FormatID::R16_UNORM:
2119 case angle::FormatID::R16_SINT:
2120 case angle::FormatID::R16_UINT:
2121 case angle::FormatID::R16_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002122 return 2;
2123
Frank Henigmand633b152018-10-04 23:34:31 -04002124 case angle::FormatID::R8G8B8_SSCALED:
2125 case angle::FormatID::R8G8B8_SNORM:
2126 case angle::FormatID::R8G8B8_USCALED:
2127 case angle::FormatID::R8G8B8_UNORM:
2128 case angle::FormatID::R8G8B8_SINT:
2129 case angle::FormatID::R8G8B8_UINT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002130 return 3;
2131
Frank Henigmand633b152018-10-04 23:34:31 -04002132 case angle::FormatID::R8G8B8A8_SSCALED:
2133 case angle::FormatID::R8G8B8A8_SNORM:
2134 case angle::FormatID::R8G8B8A8_USCALED:
2135 case angle::FormatID::R8G8B8A8_UNORM:
2136 case angle::FormatID::R8G8B8A8_SINT:
2137 case angle::FormatID::R8G8B8A8_UINT:
2138 case angle::FormatID::R16G16_SSCALED:
2139 case angle::FormatID::R16G16_SNORM:
2140 case angle::FormatID::R16G16_USCALED:
2141 case angle::FormatID::R16G16_UNORM:
2142 case angle::FormatID::R16G16_SINT:
2143 case angle::FormatID::R16G16_UINT:
2144 case angle::FormatID::R32_SSCALED:
2145 case angle::FormatID::R32_SNORM:
2146 case angle::FormatID::R32_USCALED:
2147 case angle::FormatID::R32_UNORM:
2148 case angle::FormatID::R32_SINT:
2149 case angle::FormatID::R32_UINT:
2150 case angle::FormatID::R16G16_FLOAT:
2151 case angle::FormatID::R32_FIXED:
2152 case angle::FormatID::R32_FLOAT:
2153 case angle::FormatID::R10G10B10A2_SSCALED:
2154 case angle::FormatID::R10G10B10A2_USCALED:
2155 case angle::FormatID::R10G10B10A2_SNORM:
2156 case angle::FormatID::R10G10B10A2_UNORM:
2157 case angle::FormatID::R10G10B10A2_SINT:
2158 case angle::FormatID::R10G10B10A2_UINT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002159 return 4;
2160
Frank Henigmand633b152018-10-04 23:34:31 -04002161 case angle::FormatID::R16G16B16_SSCALED:
2162 case angle::FormatID::R16G16B16_SNORM:
2163 case angle::FormatID::R16G16B16_USCALED:
2164 case angle::FormatID::R16G16B16_UNORM:
2165 case angle::FormatID::R16G16B16_SINT:
2166 case angle::FormatID::R16G16B16_UINT:
2167 case angle::FormatID::R16G16B16_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002168 return 6;
2169
Frank Henigmand633b152018-10-04 23:34:31 -04002170 case angle::FormatID::R16G16B16A16_SSCALED:
2171 case angle::FormatID::R16G16B16A16_SNORM:
2172 case angle::FormatID::R16G16B16A16_USCALED:
2173 case angle::FormatID::R16G16B16A16_UNORM:
2174 case angle::FormatID::R16G16B16A16_SINT:
2175 case angle::FormatID::R16G16B16A16_UINT:
2176 case angle::FormatID::R32G32_SSCALED:
2177 case angle::FormatID::R32G32_SNORM:
2178 case angle::FormatID::R32G32_USCALED:
2179 case angle::FormatID::R32G32_UNORM:
2180 case angle::FormatID::R32G32_SINT:
2181 case angle::FormatID::R32G32_UINT:
2182 case angle::FormatID::R16G16B16A16_FLOAT:
2183 case angle::FormatID::R32G32_FIXED:
2184 case angle::FormatID::R32G32_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002185 return 8;
2186
Frank Henigmand633b152018-10-04 23:34:31 -04002187 case angle::FormatID::R32G32B32_SSCALED:
2188 case angle::FormatID::R32G32B32_SNORM:
2189 case angle::FormatID::R32G32B32_USCALED:
2190 case angle::FormatID::R32G32B32_UNORM:
2191 case angle::FormatID::R32G32B32_SINT:
2192 case angle::FormatID::R32G32B32_UINT:
2193 case angle::FormatID::R32G32B32_FIXED:
2194 case angle::FormatID::R32G32B32_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002195 return 12;
2196
Frank Henigmand633b152018-10-04 23:34:31 -04002197 case angle::FormatID::R32G32B32A32_SSCALED:
2198 case angle::FormatID::R32G32B32A32_SNORM:
2199 case angle::FormatID::R32G32B32A32_USCALED:
2200 case angle::FormatID::R32G32B32A32_UNORM:
2201 case angle::FormatID::R32G32B32A32_SINT:
2202 case angle::FormatID::R32G32B32A32_UINT:
2203 case angle::FormatID::R32G32B32A32_FIXED:
2204 case angle::FormatID::R32G32B32A32_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002205 return 16;
2206
Frank Henigmand633b152018-10-04 23:34:31 -04002207 case angle::FormatID::NONE:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002208 default:
2209 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05002210#if !UNREACHABLE_IS_NORETURN
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002211 return 0;
Nico Weberb5db2b42018-02-12 15:31:56 -05002212#endif
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002213 }
2214}
2215
Geoff Lang6d1ccf02017-04-24 14:09:58 -04002216bool ValidES3InternalFormat(GLenum internalFormat)
2217{
2218 const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
2219 return internalFormat != GL_NONE && formatMap.find(internalFormat) != formatMap.end();
2220}
2221
Frank Henigman95fb2a12018-05-27 20:17:05 -04002222VertexFormat::VertexFormat(GLenum typeIn,
2223 GLboolean normalizedIn,
2224 GLuint componentsIn,
2225 bool pureIntegerIn)
2226 : type(typeIn), normalized(normalizedIn), components(componentsIn), pureInteger(pureIntegerIn)
Jamie Madilld3dfda22015-07-06 08:28:49 -04002227{
2228 // float -> !normalized
Frank Henigman95fb2a12018-05-27 20:17:05 -04002229 ASSERT(!(type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_FIXED) ||
2230 normalized == GL_FALSE);
Jamie Madilld3dfda22015-07-06 08:28:49 -04002231}
Markus Tavenrath0d665132018-11-18 15:47:02 +01002232} // namespace gl