xref: /aosp_15_r20/external/angle/src/libANGLE/formatutils.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2013 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker 
7*8975f5c5SAndroid Build Coastguard Worker // formatutils.cpp: Queries for GL image formats.
8*8975f5c5SAndroid Build Coastguard Worker 
9*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/formatutils.h"
10*8975f5c5SAndroid Build Coastguard Worker 
11*8975f5c5SAndroid Build Coastguard Worker #include "anglebase/no_destructor.h"
12*8975f5c5SAndroid Build Coastguard Worker #include "common/mathutil.h"
13*8975f5c5SAndroid Build Coastguard Worker #include "gpu_info_util/SystemInfo.h"
14*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Context.h"
15*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Framebuffer.h"
16*8975f5c5SAndroid Build Coastguard Worker 
17*8975f5c5SAndroid Build Coastguard Worker using namespace angle;
18*8975f5c5SAndroid Build Coastguard Worker 
19*8975f5c5SAndroid Build Coastguard Worker namespace gl
20*8975f5c5SAndroid Build Coastguard Worker {
21*8975f5c5SAndroid Build Coastguard Worker 
22*8975f5c5SAndroid Build Coastguard Worker // ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the
23*8975f5c5SAndroid Build Coastguard Worker // implementation can decide the true, sized, internal format. The ES2FormatMap determines the
24*8975f5c5SAndroid Build Coastguard Worker // internal format for all valid format and type combinations.
25*8975f5c5SAndroid Build Coastguard Worker GLenum GetSizedFormatInternal(GLenum format, GLenum type);
26*8975f5c5SAndroid Build Coastguard Worker 
27*8975f5c5SAndroid Build Coastguard Worker namespace
28*8975f5c5SAndroid Build Coastguard Worker {
CheckedMathResult(const CheckedNumeric<GLuint> & value,GLuint * resultOut)29*8975f5c5SAndroid Build Coastguard Worker bool CheckedMathResult(const CheckedNumeric<GLuint> &value, GLuint *resultOut)
30*8975f5c5SAndroid Build Coastguard Worker {
31*8975f5c5SAndroid Build Coastguard Worker     if (!value.IsValid())
32*8975f5c5SAndroid Build Coastguard Worker     {
33*8975f5c5SAndroid Build Coastguard Worker         return false;
34*8975f5c5SAndroid Build Coastguard Worker     }
35*8975f5c5SAndroid Build Coastguard Worker     else
36*8975f5c5SAndroid Build Coastguard Worker     {
37*8975f5c5SAndroid Build Coastguard Worker         *resultOut = value.ValueOrDie();
38*8975f5c5SAndroid Build Coastguard Worker         return true;
39*8975f5c5SAndroid Build Coastguard Worker     }
40*8975f5c5SAndroid Build Coastguard Worker }
41*8975f5c5SAndroid Build Coastguard Worker 
PackTypeInfo(GLuint bytes,bool specialized)42*8975f5c5SAndroid Build Coastguard Worker constexpr uint32_t PackTypeInfo(GLuint bytes, bool specialized)
43*8975f5c5SAndroid Build Coastguard Worker {
44*8975f5c5SAndroid Build Coastguard Worker     // static_assert within constexpr requires c++17
45*8975f5c5SAndroid Build Coastguard Worker     // static_assert(isPow2(bytes));
46*8975f5c5SAndroid Build Coastguard Worker     return bytes | (rx::Log2(bytes) << 8) | (specialized << 16);
47*8975f5c5SAndroid Build Coastguard Worker }
48*8975f5c5SAndroid Build Coastguard Worker 
49*8975f5c5SAndroid Build Coastguard Worker }  // anonymous namespace
50*8975f5c5SAndroid Build Coastguard Worker 
FormatType()51*8975f5c5SAndroid Build Coastguard Worker FormatType::FormatType() : format(GL_NONE), type(GL_NONE) {}
52*8975f5c5SAndroid Build Coastguard Worker 
FormatType(GLenum format_,GLenum type_)53*8975f5c5SAndroid Build Coastguard Worker FormatType::FormatType(GLenum format_, GLenum type_) : format(format_), type(type_) {}
54*8975f5c5SAndroid Build Coastguard Worker 
operator <(const FormatType & other) const55*8975f5c5SAndroid Build Coastguard Worker bool FormatType::operator<(const FormatType &other) const
56*8975f5c5SAndroid Build Coastguard Worker {
57*8975f5c5SAndroid Build Coastguard Worker     if (format != other.format)
58*8975f5c5SAndroid Build Coastguard Worker         return format < other.format;
59*8975f5c5SAndroid Build Coastguard Worker     return type < other.type;
60*8975f5c5SAndroid Build Coastguard Worker }
61*8975f5c5SAndroid Build Coastguard Worker 
operator <(const Type & a,const Type & b)62*8975f5c5SAndroid Build Coastguard Worker bool operator<(const Type &a, const Type &b)
63*8975f5c5SAndroid Build Coastguard Worker {
64*8975f5c5SAndroid Build Coastguard Worker     return memcmp(&a, &b, sizeof(Type)) < 0;
65*8975f5c5SAndroid Build Coastguard Worker }
66*8975f5c5SAndroid Build Coastguard Worker 
67*8975f5c5SAndroid Build Coastguard Worker // Information about internal formats
AlwaysSupported(const Version &,const Extensions &)68*8975f5c5SAndroid Build Coastguard Worker static bool AlwaysSupported(const Version &, const Extensions &)
69*8975f5c5SAndroid Build Coastguard Worker {
70*8975f5c5SAndroid Build Coastguard Worker     return true;
71*8975f5c5SAndroid Build Coastguard Worker }
72*8975f5c5SAndroid Build Coastguard Worker 
NeverSupported(const Version &,const Extensions &)73*8975f5c5SAndroid Build Coastguard Worker static bool NeverSupported(const Version &, const Extensions &)
74*8975f5c5SAndroid Build Coastguard Worker {
75*8975f5c5SAndroid Build Coastguard Worker     return false;
76*8975f5c5SAndroid Build Coastguard Worker }
77*8975f5c5SAndroid Build Coastguard Worker 
RequireES1(const Version & clientVersion,const Extensions & extensions)78*8975f5c5SAndroid Build Coastguard Worker static bool RequireES1(const Version &clientVersion, const Extensions &extensions)
79*8975f5c5SAndroid Build Coastguard Worker {
80*8975f5c5SAndroid Build Coastguard Worker     return clientVersion.major == 1;
81*8975f5c5SAndroid Build Coastguard Worker }
82*8975f5c5SAndroid Build Coastguard Worker 
83*8975f5c5SAndroid Build Coastguard Worker template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion>
RequireES(const Version & clientVersion,const Extensions &)84*8975f5c5SAndroid Build Coastguard Worker static bool RequireES(const Version &clientVersion, const Extensions &)
85*8975f5c5SAndroid Build Coastguard Worker {
86*8975f5c5SAndroid Build Coastguard Worker     return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion);
87*8975f5c5SAndroid Build Coastguard Worker }
88*8975f5c5SAndroid Build Coastguard Worker 
89*8975f5c5SAndroid Build Coastguard Worker // Check support for a single extension
90*8975f5c5SAndroid Build Coastguard Worker template <ExtensionBool bool1>
RequireExt(const Version &,const Extensions & extensions)91*8975f5c5SAndroid Build Coastguard Worker static bool RequireExt(const Version &, const Extensions &extensions)
92*8975f5c5SAndroid Build Coastguard Worker {
93*8975f5c5SAndroid Build Coastguard Worker     return extensions.*bool1;
94*8975f5c5SAndroid Build Coastguard Worker }
95*8975f5c5SAndroid Build Coastguard Worker 
96*8975f5c5SAndroid Build Coastguard Worker // Check for a minimum client version or a single extension
97*8975f5c5SAndroid Build Coastguard Worker template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion, ExtensionBool bool1>
RequireESOrExt(const Version & clientVersion,const Extensions & extensions)98*8975f5c5SAndroid Build Coastguard Worker static bool RequireESOrExt(const Version &clientVersion, const Extensions &extensions)
99*8975f5c5SAndroid Build Coastguard Worker {
100*8975f5c5SAndroid Build Coastguard Worker     return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
101*8975f5c5SAndroid Build Coastguard Worker            extensions.*bool1;
102*8975f5c5SAndroid Build Coastguard Worker }
103*8975f5c5SAndroid Build Coastguard Worker 
104*8975f5c5SAndroid Build Coastguard Worker // Check for a minimum client version or two extensions
105*8975f5c5SAndroid Build Coastguard Worker template <GLuint minCoreGLMajorVersion,
106*8975f5c5SAndroid Build Coastguard Worker           GLuint minCoreGLMinorVersion,
107*8975f5c5SAndroid Build Coastguard Worker           ExtensionBool bool1,
108*8975f5c5SAndroid Build Coastguard Worker           ExtensionBool bool2>
RequireESOrExtAndExt(const Version & clientVersion,const Extensions & extensions)109*8975f5c5SAndroid Build Coastguard Worker static bool RequireESOrExtAndExt(const Version &clientVersion, const Extensions &extensions)
110*8975f5c5SAndroid Build Coastguard Worker {
111*8975f5c5SAndroid Build Coastguard Worker     return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
112*8975f5c5SAndroid Build Coastguard Worker            (extensions.*bool1 && extensions.*bool2);
113*8975f5c5SAndroid Build Coastguard Worker }
114*8975f5c5SAndroid Build Coastguard Worker 
115*8975f5c5SAndroid Build Coastguard Worker // Check for a minimum client version or at least one of two extensions
116*8975f5c5SAndroid Build Coastguard Worker template <GLuint minCoreGLMajorVersion,
117*8975f5c5SAndroid Build Coastguard Worker           GLuint minCoreGLMinorVersion,
118*8975f5c5SAndroid Build Coastguard Worker           ExtensionBool bool1,
119*8975f5c5SAndroid Build Coastguard Worker           ExtensionBool bool2>
RequireESOrExtOrExt(const Version & clientVersion,const Extensions & extensions)120*8975f5c5SAndroid Build Coastguard Worker static bool RequireESOrExtOrExt(const Version &clientVersion, const Extensions &extensions)
121*8975f5c5SAndroid Build Coastguard Worker {
122*8975f5c5SAndroid Build Coastguard Worker     return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
123*8975f5c5SAndroid Build Coastguard Worker            extensions.*bool1 || extensions.*bool2;
124*8975f5c5SAndroid Build Coastguard Worker }
125*8975f5c5SAndroid Build Coastguard Worker 
126*8975f5c5SAndroid Build Coastguard Worker // Check support for two extensions
127*8975f5c5SAndroid Build Coastguard Worker template <ExtensionBool bool1, ExtensionBool bool2>
RequireExtAndExt(const Version &,const Extensions & extensions)128*8975f5c5SAndroid Build Coastguard Worker static bool RequireExtAndExt(const Version &, const Extensions &extensions)
129*8975f5c5SAndroid Build Coastguard Worker {
130*8975f5c5SAndroid Build Coastguard Worker     return extensions.*bool1 && extensions.*bool2;
131*8975f5c5SAndroid Build Coastguard Worker }
132*8975f5c5SAndroid Build Coastguard Worker 
133*8975f5c5SAndroid Build Coastguard Worker // Check support for either of two extensions
134*8975f5c5SAndroid Build Coastguard Worker template <ExtensionBool bool1, ExtensionBool bool2>
RequireExtOrExt(const Version &,const Extensions & extensions)135*8975f5c5SAndroid Build Coastguard Worker static bool RequireExtOrExt(const Version &, const Extensions &extensions)
136*8975f5c5SAndroid Build Coastguard Worker {
137*8975f5c5SAndroid Build Coastguard Worker     return extensions.*bool1 || extensions.*bool2;
138*8975f5c5SAndroid Build Coastguard Worker }
139*8975f5c5SAndroid Build Coastguard Worker 
140*8975f5c5SAndroid Build Coastguard Worker // Check support for any of three extensions
141*8975f5c5SAndroid Build Coastguard Worker template <ExtensionBool bool1, ExtensionBool bool2, ExtensionBool bool3>
RequireExtOrExtOrExt(const Version &,const Extensions & extensions)142*8975f5c5SAndroid Build Coastguard Worker static bool RequireExtOrExtOrExt(const Version &, const Extensions &extensions)
143*8975f5c5SAndroid Build Coastguard Worker {
144*8975f5c5SAndroid Build Coastguard Worker     return extensions.*bool1 || extensions.*bool2 || extensions.*bool3;
145*8975f5c5SAndroid Build Coastguard Worker }
146*8975f5c5SAndroid Build Coastguard Worker 
147*8975f5c5SAndroid Build Coastguard Worker // R8, RG8
SizedRGSupport(const Version & clientVersion,const Extensions & extensions)148*8975f5c5SAndroid Build Coastguard Worker static bool SizedRGSupport(const Version &clientVersion, const Extensions &extensions)
149*8975f5c5SAndroid Build Coastguard Worker {
150*8975f5c5SAndroid Build Coastguard Worker     return clientVersion >= Version(3, 0) ||
151*8975f5c5SAndroid Build Coastguard Worker            (extensions.textureStorageEXT && extensions.textureRgEXT);
152*8975f5c5SAndroid Build Coastguard Worker }
153*8975f5c5SAndroid Build Coastguard Worker 
154*8975f5c5SAndroid Build Coastguard Worker // R16F, RG16F with HALF_FLOAT_OES type
SizedHalfFloatOESRGSupport(const Version & clientVersion,const Extensions & extensions)155*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatOESRGSupport(const Version &clientVersion, const Extensions &extensions)
156*8975f5c5SAndroid Build Coastguard Worker {
157*8975f5c5SAndroid Build Coastguard Worker     return extensions.textureStorageEXT && extensions.textureHalfFloatOES &&
158*8975f5c5SAndroid Build Coastguard Worker            extensions.textureRgEXT;
159*8975f5c5SAndroid Build Coastguard Worker }
160*8975f5c5SAndroid Build Coastguard Worker 
SizedHalfFloatOESRGTextureAttachmentSupport(const Version & clientVersion,const Extensions & extensions)161*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatOESRGTextureAttachmentSupport(const Version &clientVersion,
162*8975f5c5SAndroid Build Coastguard Worker                                                         const Extensions &extensions)
163*8975f5c5SAndroid Build Coastguard Worker {
164*8975f5c5SAndroid Build Coastguard Worker     return SizedHalfFloatOESRGSupport(clientVersion, extensions) &&
165*8975f5c5SAndroid Build Coastguard Worker            extensions.colorBufferHalfFloatEXT;
166*8975f5c5SAndroid Build Coastguard Worker }
167*8975f5c5SAndroid Build Coastguard Worker 
168*8975f5c5SAndroid Build Coastguard Worker // R16F, RG16F with either HALF_FLOAT_OES or HALF_FLOAT types
SizedHalfFloatRGSupport(const Version & clientVersion,const Extensions & extensions)169*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
170*8975f5c5SAndroid Build Coastguard Worker {
171*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT
172*8975f5c5SAndroid Build Coastguard Worker     if (clientVersion >= Version(3, 0))
173*8975f5c5SAndroid Build Coastguard Worker     {
174*8975f5c5SAndroid Build Coastguard Worker         return true;
175*8975f5c5SAndroid Build Coastguard Worker     }
176*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT_OES
177*8975f5c5SAndroid Build Coastguard Worker     else
178*8975f5c5SAndroid Build Coastguard Worker     {
179*8975f5c5SAndroid Build Coastguard Worker         return SizedHalfFloatOESRGSupport(clientVersion, extensions);
180*8975f5c5SAndroid Build Coastguard Worker     }
181*8975f5c5SAndroid Build Coastguard Worker }
182*8975f5c5SAndroid Build Coastguard Worker 
SizedHalfFloatRGTextureAttachmentSupport(const Version & clientVersion,const Extensions & extensions)183*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatRGTextureAttachmentSupport(const Version &clientVersion,
184*8975f5c5SAndroid Build Coastguard Worker                                                      const Extensions &extensions)
185*8975f5c5SAndroid Build Coastguard Worker {
186*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT
187*8975f5c5SAndroid Build Coastguard Worker     if (clientVersion >= Version(3, 0))
188*8975f5c5SAndroid Build Coastguard Worker     {
189*8975f5c5SAndroid Build Coastguard Worker         // WebGL 2 supports EXT_color_buffer_half_float.
190*8975f5c5SAndroid Build Coastguard Worker         return extensions.colorBufferFloatEXT ||
191*8975f5c5SAndroid Build Coastguard Worker                (extensions.webglCompatibilityANGLE && extensions.colorBufferHalfFloatEXT);
192*8975f5c5SAndroid Build Coastguard Worker     }
193*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT_OES
194*8975f5c5SAndroid Build Coastguard Worker     else
195*8975f5c5SAndroid Build Coastguard Worker     {
196*8975f5c5SAndroid Build Coastguard Worker         return SizedHalfFloatOESRGTextureAttachmentSupport(clientVersion, extensions);
197*8975f5c5SAndroid Build Coastguard Worker     }
198*8975f5c5SAndroid Build Coastguard Worker }
199*8975f5c5SAndroid Build Coastguard Worker 
SizedHalfFloatRGRenderbufferSupport(const Version & clientVersion,const Extensions & extensions)200*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatRGRenderbufferSupport(const Version &clientVersion,
201*8975f5c5SAndroid Build Coastguard Worker                                                 const Extensions &extensions)
202*8975f5c5SAndroid Build Coastguard Worker {
203*8975f5c5SAndroid Build Coastguard Worker     return (clientVersion >= Version(3, 0) ||
204*8975f5c5SAndroid Build Coastguard Worker             (extensions.textureHalfFloatOES && extensions.textureRgEXT)) &&
205*8975f5c5SAndroid Build Coastguard Worker            (extensions.colorBufferFloatEXT || extensions.colorBufferHalfFloatEXT);
206*8975f5c5SAndroid Build Coastguard Worker }
207*8975f5c5SAndroid Build Coastguard Worker 
208*8975f5c5SAndroid Build Coastguard Worker // RGB16F, RGBA16F with HALF_FLOAT_OES type
SizedHalfFloatOESSupport(const Version & clientVersion,const Extensions & extensions)209*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatOESSupport(const Version &clientVersion, const Extensions &extensions)
210*8975f5c5SAndroid Build Coastguard Worker {
211*8975f5c5SAndroid Build Coastguard Worker     return extensions.textureStorageEXT && extensions.textureHalfFloatOES;
212*8975f5c5SAndroid Build Coastguard Worker }
213*8975f5c5SAndroid Build Coastguard Worker 
SizedHalfFloatOESTextureAttachmentSupport(const Version & clientVersion,const Extensions & extensions)214*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatOESTextureAttachmentSupport(const Version &clientVersion,
215*8975f5c5SAndroid Build Coastguard Worker                                                       const Extensions &extensions)
216*8975f5c5SAndroid Build Coastguard Worker {
217*8975f5c5SAndroid Build Coastguard Worker     return SizedHalfFloatOESSupport(clientVersion, extensions) &&
218*8975f5c5SAndroid Build Coastguard Worker            extensions.colorBufferHalfFloatEXT;
219*8975f5c5SAndroid Build Coastguard Worker }
220*8975f5c5SAndroid Build Coastguard Worker 
221*8975f5c5SAndroid Build Coastguard Worker // RGB16F, RGBA16F with either HALF_FLOAT_OES or HALF_FLOAT types
SizedHalfFloatSupport(const Version & clientVersion,const Extensions & extensions)222*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatSupport(const Version &clientVersion, const Extensions &extensions)
223*8975f5c5SAndroid Build Coastguard Worker {
224*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT
225*8975f5c5SAndroid Build Coastguard Worker     if (clientVersion >= Version(3, 0))
226*8975f5c5SAndroid Build Coastguard Worker     {
227*8975f5c5SAndroid Build Coastguard Worker         return true;
228*8975f5c5SAndroid Build Coastguard Worker     }
229*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT_OES
230*8975f5c5SAndroid Build Coastguard Worker     else
231*8975f5c5SAndroid Build Coastguard Worker     {
232*8975f5c5SAndroid Build Coastguard Worker         return SizedHalfFloatOESSupport(clientVersion, extensions);
233*8975f5c5SAndroid Build Coastguard Worker     }
234*8975f5c5SAndroid Build Coastguard Worker }
235*8975f5c5SAndroid Build Coastguard Worker 
SizedHalfFloatFilterSupport(const Version & clientVersion,const Extensions & extensions)236*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatFilterSupport(const Version &clientVersion, const Extensions &extensions)
237*8975f5c5SAndroid Build Coastguard Worker {
238*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT
239*8975f5c5SAndroid Build Coastguard Worker     if (clientVersion >= Version(3, 0))
240*8975f5c5SAndroid Build Coastguard Worker     {
241*8975f5c5SAndroid Build Coastguard Worker         return true;
242*8975f5c5SAndroid Build Coastguard Worker     }
243*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT_OES
244*8975f5c5SAndroid Build Coastguard Worker     else
245*8975f5c5SAndroid Build Coastguard Worker     {
246*8975f5c5SAndroid Build Coastguard Worker         return extensions.textureHalfFloatLinearOES;
247*8975f5c5SAndroid Build Coastguard Worker     }
248*8975f5c5SAndroid Build Coastguard Worker }
249*8975f5c5SAndroid Build Coastguard Worker 
SizedHalfFloatRGBTextureAttachmentSupport(const Version & clientVersion,const Extensions & extensions)250*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatRGBTextureAttachmentSupport(const Version &clientVersion,
251*8975f5c5SAndroid Build Coastguard Worker                                                       const Extensions &extensions)
252*8975f5c5SAndroid Build Coastguard Worker {
253*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT
254*8975f5c5SAndroid Build Coastguard Worker     if (clientVersion >= Version(3, 0))
255*8975f5c5SAndroid Build Coastguard Worker     {
256*8975f5c5SAndroid Build Coastguard Worker         // It is unclear how EXT_color_buffer_half_float applies to ES3.0 and above, however,
257*8975f5c5SAndroid Build Coastguard Worker         // dEQP GLES3 es3fFboColorbufferTests.cpp verifies that texture attachment of GL_RGB16F
258*8975f5c5SAndroid Build Coastguard Worker         // is possible, so assume that all GLES implementations support it.
259*8975f5c5SAndroid Build Coastguard Worker         // The WebGL version of the extension explicitly forbids RGB formats.
260*8975f5c5SAndroid Build Coastguard Worker         return extensions.colorBufferHalfFloatEXT && !extensions.webglCompatibilityANGLE;
261*8975f5c5SAndroid Build Coastguard Worker     }
262*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT_OES
263*8975f5c5SAndroid Build Coastguard Worker     else
264*8975f5c5SAndroid Build Coastguard Worker     {
265*8975f5c5SAndroid Build Coastguard Worker         return SizedHalfFloatOESTextureAttachmentSupport(clientVersion, extensions);
266*8975f5c5SAndroid Build Coastguard Worker     }
267*8975f5c5SAndroid Build Coastguard Worker }
268*8975f5c5SAndroid Build Coastguard Worker 
SizedHalfFloatRGBRenderbufferSupport(const Version & clientVersion,const Extensions & extensions)269*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatRGBRenderbufferSupport(const Version &clientVersion,
270*8975f5c5SAndroid Build Coastguard Worker                                                  const Extensions &extensions)
271*8975f5c5SAndroid Build Coastguard Worker {
272*8975f5c5SAndroid Build Coastguard Worker     return !extensions.webglCompatibilityANGLE &&
273*8975f5c5SAndroid Build Coastguard Worker            ((clientVersion >= Version(3, 0) || extensions.textureHalfFloatOES) &&
274*8975f5c5SAndroid Build Coastguard Worker             extensions.colorBufferHalfFloatEXT);
275*8975f5c5SAndroid Build Coastguard Worker }
276*8975f5c5SAndroid Build Coastguard Worker 
SizedHalfFloatRGBATextureAttachmentSupport(const Version & clientVersion,const Extensions & extensions)277*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatRGBATextureAttachmentSupport(const Version &clientVersion,
278*8975f5c5SAndroid Build Coastguard Worker                                                        const Extensions &extensions)
279*8975f5c5SAndroid Build Coastguard Worker {
280*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT
281*8975f5c5SAndroid Build Coastguard Worker     if (clientVersion >= Version(3, 0))
282*8975f5c5SAndroid Build Coastguard Worker     {
283*8975f5c5SAndroid Build Coastguard Worker         // WebGL 2 supports EXT_color_buffer_half_float.
284*8975f5c5SAndroid Build Coastguard Worker         return extensions.colorBufferFloatEXT ||
285*8975f5c5SAndroid Build Coastguard Worker                (extensions.webglCompatibilityANGLE && extensions.colorBufferHalfFloatEXT);
286*8975f5c5SAndroid Build Coastguard Worker     }
287*8975f5c5SAndroid Build Coastguard Worker     // HALF_FLOAT_OES
288*8975f5c5SAndroid Build Coastguard Worker     else
289*8975f5c5SAndroid Build Coastguard Worker     {
290*8975f5c5SAndroid Build Coastguard Worker         return SizedHalfFloatOESTextureAttachmentSupport(clientVersion, extensions);
291*8975f5c5SAndroid Build Coastguard Worker     }
292*8975f5c5SAndroid Build Coastguard Worker }
293*8975f5c5SAndroid Build Coastguard Worker 
SizedHalfFloatRGBARenderbufferSupport(const Version & clientVersion,const Extensions & extensions)294*8975f5c5SAndroid Build Coastguard Worker static bool SizedHalfFloatRGBARenderbufferSupport(const Version &clientVersion,
295*8975f5c5SAndroid Build Coastguard Worker                                                   const Extensions &extensions)
296*8975f5c5SAndroid Build Coastguard Worker {
297*8975f5c5SAndroid Build Coastguard Worker     return (clientVersion >= Version(3, 0) || extensions.textureHalfFloatOES) &&
298*8975f5c5SAndroid Build Coastguard Worker            (extensions.colorBufferFloatEXT || extensions.colorBufferHalfFloatEXT);
299*8975f5c5SAndroid Build Coastguard Worker }
300*8975f5c5SAndroid Build Coastguard Worker 
301*8975f5c5SAndroid Build Coastguard Worker // R32F, RG32F
SizedFloatRGSupport(const Version & clientVersion,const Extensions & extensions)302*8975f5c5SAndroid Build Coastguard Worker static bool SizedFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
303*8975f5c5SAndroid Build Coastguard Worker {
304*8975f5c5SAndroid Build Coastguard Worker     return clientVersion >= Version(3, 0) ||
305*8975f5c5SAndroid Build Coastguard Worker            (extensions.textureStorageEXT && extensions.textureFloatOES && extensions.textureRgEXT);
306*8975f5c5SAndroid Build Coastguard Worker }
307*8975f5c5SAndroid Build Coastguard Worker 
308*8975f5c5SAndroid Build Coastguard Worker // RGB32F
SizedFloatRGBSupport(const Version & clientVersion,const Extensions & extensions)309*8975f5c5SAndroid Build Coastguard Worker static bool SizedFloatRGBSupport(const Version &clientVersion, const Extensions &extensions)
310*8975f5c5SAndroid Build Coastguard Worker {
311*8975f5c5SAndroid Build Coastguard Worker     return clientVersion >= Version(3, 0) ||
312*8975f5c5SAndroid Build Coastguard Worker            (extensions.textureStorageEXT && extensions.textureFloatOES) ||
313*8975f5c5SAndroid Build Coastguard Worker            extensions.colorBufferFloatRgbCHROMIUM;
314*8975f5c5SAndroid Build Coastguard Worker }
315*8975f5c5SAndroid Build Coastguard Worker 
316*8975f5c5SAndroid Build Coastguard Worker // RGBA32F
SizedFloatRGBASupport(const Version & clientVersion,const Extensions & extensions)317*8975f5c5SAndroid Build Coastguard Worker static bool SizedFloatRGBASupport(const Version &clientVersion, const Extensions &extensions)
318*8975f5c5SAndroid Build Coastguard Worker {
319*8975f5c5SAndroid Build Coastguard Worker     return clientVersion >= Version(3, 0) ||
320*8975f5c5SAndroid Build Coastguard Worker            (extensions.textureStorageEXT && extensions.textureFloatOES) ||
321*8975f5c5SAndroid Build Coastguard Worker            extensions.colorBufferFloatRgbaCHROMIUM;
322*8975f5c5SAndroid Build Coastguard Worker }
323*8975f5c5SAndroid Build Coastguard Worker 
SizedFloatRGBARenderableSupport(const Version & clientVersion,const Extensions & extensions)324*8975f5c5SAndroid Build Coastguard Worker static bool SizedFloatRGBARenderableSupport(const Version &clientVersion,
325*8975f5c5SAndroid Build Coastguard Worker                                             const Extensions &extensions)
326*8975f5c5SAndroid Build Coastguard Worker {
327*8975f5c5SAndroid Build Coastguard Worker     // This logic is the same for both Renderbuffers and TextureAttachment.
328*8975f5c5SAndroid Build Coastguard Worker     return extensions.colorBufferFloatRgbaCHROMIUM ||  // ES2
329*8975f5c5SAndroid Build Coastguard Worker            extensions.colorBufferFloatEXT;             // ES3
330*8975f5c5SAndroid Build Coastguard Worker }
331*8975f5c5SAndroid Build Coastguard Worker 
Float32BlendableSupport(const Version & clientVersion,const Extensions & extensions)332*8975f5c5SAndroid Build Coastguard Worker static bool Float32BlendableSupport(const Version &clientVersion, const Extensions &extensions)
333*8975f5c5SAndroid Build Coastguard Worker {
334*8975f5c5SAndroid Build Coastguard Worker     // EXT_float_blend may be exposed on ES2 client contexts. Ensure that RGBA32F is renderable.
335*8975f5c5SAndroid Build Coastguard Worker     return (extensions.colorBufferFloatRgbaCHROMIUM || extensions.colorBufferFloatEXT) &&
336*8975f5c5SAndroid Build Coastguard Worker            extensions.floatBlendEXT;
337*8975f5c5SAndroid Build Coastguard Worker }
338*8975f5c5SAndroid Build Coastguard Worker 
339*8975f5c5SAndroid Build Coastguard Worker template <ExtensionBool bool1>
ETC2EACSupport(const Version & clientVersion,const Extensions & extensions)340*8975f5c5SAndroid Build Coastguard Worker static bool ETC2EACSupport(const Version &clientVersion, const Extensions &extensions)
341*8975f5c5SAndroid Build Coastguard Worker {
342*8975f5c5SAndroid Build Coastguard Worker     if (extensions.compressedTextureEtcANGLE)
343*8975f5c5SAndroid Build Coastguard Worker     {
344*8975f5c5SAndroid Build Coastguard Worker         return true;
345*8975f5c5SAndroid Build Coastguard Worker     }
346*8975f5c5SAndroid Build Coastguard Worker 
347*8975f5c5SAndroid Build Coastguard Worker     // ETC2/EAC formats are always available in ES 3.0+ but require an extension (checked above)
348*8975f5c5SAndroid Build Coastguard Worker     // in WebGL. If that extension is not available, hide these formats from WebGL contexts.
349*8975f5c5SAndroid Build Coastguard Worker     return !extensions.webglCompatibilityANGLE &&
350*8975f5c5SAndroid Build Coastguard Worker            (clientVersion >= Version(3, 0) || extensions.*bool1);
351*8975f5c5SAndroid Build Coastguard Worker }
352*8975f5c5SAndroid Build Coastguard Worker 
InternalFormat()353*8975f5c5SAndroid Build Coastguard Worker InternalFormat::InternalFormat()
354*8975f5c5SAndroid Build Coastguard Worker     : internalFormat(GL_NONE),
355*8975f5c5SAndroid Build Coastguard Worker       sized(false),
356*8975f5c5SAndroid Build Coastguard Worker       sizedInternalFormat(GL_NONE),
357*8975f5c5SAndroid Build Coastguard Worker       redBits(0),
358*8975f5c5SAndroid Build Coastguard Worker       greenBits(0),
359*8975f5c5SAndroid Build Coastguard Worker       blueBits(0),
360*8975f5c5SAndroid Build Coastguard Worker       luminanceBits(0),
361*8975f5c5SAndroid Build Coastguard Worker       alphaBits(0),
362*8975f5c5SAndroid Build Coastguard Worker       sharedBits(0),
363*8975f5c5SAndroid Build Coastguard Worker       depthBits(0),
364*8975f5c5SAndroid Build Coastguard Worker       stencilBits(0),
365*8975f5c5SAndroid Build Coastguard Worker       pixelBytes(0),
366*8975f5c5SAndroid Build Coastguard Worker       componentCount(0),
367*8975f5c5SAndroid Build Coastguard Worker       compressed(false),
368*8975f5c5SAndroid Build Coastguard Worker       compressedBlockWidth(0),
369*8975f5c5SAndroid Build Coastguard Worker       compressedBlockHeight(0),
370*8975f5c5SAndroid Build Coastguard Worker       compressedBlockDepth(0),
371*8975f5c5SAndroid Build Coastguard Worker       paletted(false),
372*8975f5c5SAndroid Build Coastguard Worker       paletteBits(0),
373*8975f5c5SAndroid Build Coastguard Worker       format(GL_NONE),
374*8975f5c5SAndroid Build Coastguard Worker       type(GL_NONE),
375*8975f5c5SAndroid Build Coastguard Worker       componentType(GL_NONE),
376*8975f5c5SAndroid Build Coastguard Worker       colorEncoding(GL_NONE),
377*8975f5c5SAndroid Build Coastguard Worker       textureSupport(NeverSupported),
378*8975f5c5SAndroid Build Coastguard Worker       filterSupport(NeverSupported),
379*8975f5c5SAndroid Build Coastguard Worker       textureAttachmentSupport(NeverSupported),
380*8975f5c5SAndroid Build Coastguard Worker       renderbufferSupport(NeverSupported),
381*8975f5c5SAndroid Build Coastguard Worker       blendSupport(NeverSupported)
382*8975f5c5SAndroid Build Coastguard Worker {}
383*8975f5c5SAndroid Build Coastguard Worker 
384*8975f5c5SAndroid Build Coastguard Worker InternalFormat::InternalFormat(const InternalFormat &other) = default;
385*8975f5c5SAndroid Build Coastguard Worker 
386*8975f5c5SAndroid Build Coastguard Worker InternalFormat &InternalFormat::operator=(const InternalFormat &other) = default;
387*8975f5c5SAndroid Build Coastguard Worker 
isLUMA() const388*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::isLUMA() const
389*8975f5c5SAndroid Build Coastguard Worker {
390*8975f5c5SAndroid Build Coastguard Worker     return ((redBits + greenBits + blueBits + depthBits + stencilBits) == 0 &&
391*8975f5c5SAndroid Build Coastguard Worker             (luminanceBits + alphaBits) > 0);
392*8975f5c5SAndroid Build Coastguard Worker }
393*8975f5c5SAndroid Build Coastguard Worker 
getReadPixelsFormat(const Extensions & extensions) const394*8975f5c5SAndroid Build Coastguard Worker GLenum InternalFormat::getReadPixelsFormat(const Extensions &extensions) const
395*8975f5c5SAndroid Build Coastguard Worker {
396*8975f5c5SAndroid Build Coastguard Worker     switch (format)
397*8975f5c5SAndroid Build Coastguard Worker     {
398*8975f5c5SAndroid Build Coastguard Worker         case GL_BGRA_EXT:
399*8975f5c5SAndroid Build Coastguard Worker             // BGRA textures may be enabled but calling glReadPixels with BGRA is disallowed without
400*8975f5c5SAndroid Build Coastguard Worker             // GL_EXT_texture_format_BGRA8888.  Read as RGBA instead.
401*8975f5c5SAndroid Build Coastguard Worker             if (!extensions.readFormatBgraEXT)
402*8975f5c5SAndroid Build Coastguard Worker             {
403*8975f5c5SAndroid Build Coastguard Worker                 return GL_RGBA;
404*8975f5c5SAndroid Build Coastguard Worker             }
405*8975f5c5SAndroid Build Coastguard Worker             return GL_BGRA_EXT;
406*8975f5c5SAndroid Build Coastguard Worker 
407*8975f5c5SAndroid Build Coastguard Worker         default:
408*8975f5c5SAndroid Build Coastguard Worker             return format;
409*8975f5c5SAndroid Build Coastguard Worker     }
410*8975f5c5SAndroid Build Coastguard Worker }
411*8975f5c5SAndroid Build Coastguard Worker 
getReadPixelsType(const Version & version) const412*8975f5c5SAndroid Build Coastguard Worker GLenum InternalFormat::getReadPixelsType(const Version &version) const
413*8975f5c5SAndroid Build Coastguard Worker {
414*8975f5c5SAndroid Build Coastguard Worker     switch (type)
415*8975f5c5SAndroid Build Coastguard Worker     {
416*8975f5c5SAndroid Build Coastguard Worker         case GL_HALF_FLOAT:
417*8975f5c5SAndroid Build Coastguard Worker         case GL_HALF_FLOAT_OES:
418*8975f5c5SAndroid Build Coastguard Worker             if (version < Version(3, 0))
419*8975f5c5SAndroid Build Coastguard Worker             {
420*8975f5c5SAndroid Build Coastguard Worker                 // The internal format may have a type of GL_HALF_FLOAT but when exposing this type
421*8975f5c5SAndroid Build Coastguard Worker                 // as the IMPLEMENTATION_READ_TYPE, only HALF_FLOAT_OES is allowed by
422*8975f5c5SAndroid Build Coastguard Worker                 // OES_texture_half_float.  HALF_FLOAT becomes core in ES3 and is acceptable to use
423*8975f5c5SAndroid Build Coastguard Worker                 // as an IMPLEMENTATION_READ_TYPE.
424*8975f5c5SAndroid Build Coastguard Worker                 return GL_HALF_FLOAT_OES;
425*8975f5c5SAndroid Build Coastguard Worker             }
426*8975f5c5SAndroid Build Coastguard Worker             return GL_HALF_FLOAT;
427*8975f5c5SAndroid Build Coastguard Worker 
428*8975f5c5SAndroid Build Coastguard Worker         default:
429*8975f5c5SAndroid Build Coastguard Worker             return type;
430*8975f5c5SAndroid Build Coastguard Worker     }
431*8975f5c5SAndroid Build Coastguard Worker }
432*8975f5c5SAndroid Build Coastguard Worker 
supportSubImage() const433*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::supportSubImage() const
434*8975f5c5SAndroid Build Coastguard Worker {
435*8975f5c5SAndroid Build Coastguard Worker     return !CompressedFormatRequiresWholeImage(internalFormat);
436*8975f5c5SAndroid Build Coastguard Worker }
437*8975f5c5SAndroid Build Coastguard Worker 
isRequiredRenderbufferFormat(const Version & version) const438*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::isRequiredRenderbufferFormat(const Version &version) const
439*8975f5c5SAndroid Build Coastguard Worker {
440*8975f5c5SAndroid Build Coastguard Worker     // GLES 3.0.5 section 4.4.2.2:
441*8975f5c5SAndroid Build Coastguard Worker     // "Implementations are required to support the same internal formats for renderbuffers as the
442*8975f5c5SAndroid Build Coastguard Worker     // required formats for textures enumerated in section 3.8.3.1, with the exception of the color
443*8975f5c5SAndroid Build Coastguard Worker     // formats labelled "texture-only"."
444*8975f5c5SAndroid Build Coastguard Worker     if (!sized || compressed)
445*8975f5c5SAndroid Build Coastguard Worker     {
446*8975f5c5SAndroid Build Coastguard Worker         return false;
447*8975f5c5SAndroid Build Coastguard Worker     }
448*8975f5c5SAndroid Build Coastguard Worker 
449*8975f5c5SAndroid Build Coastguard Worker     // Luma formats.
450*8975f5c5SAndroid Build Coastguard Worker     if (isLUMA())
451*8975f5c5SAndroid Build Coastguard Worker     {
452*8975f5c5SAndroid Build Coastguard Worker         return false;
453*8975f5c5SAndroid Build Coastguard Worker     }
454*8975f5c5SAndroid Build Coastguard Worker 
455*8975f5c5SAndroid Build Coastguard Worker     // Depth/stencil formats.
456*8975f5c5SAndroid Build Coastguard Worker     if (depthBits > 0 || stencilBits > 0)
457*8975f5c5SAndroid Build Coastguard Worker     {
458*8975f5c5SAndroid Build Coastguard Worker         // GLES 2.0.25 table 4.5.
459*8975f5c5SAndroid Build Coastguard Worker         // GLES 3.0.5 section 3.8.3.1.
460*8975f5c5SAndroid Build Coastguard Worker         // GLES 3.1 table 8.14.
461*8975f5c5SAndroid Build Coastguard Worker 
462*8975f5c5SAndroid Build Coastguard Worker         // Required formats in all versions.
463*8975f5c5SAndroid Build Coastguard Worker         switch (internalFormat)
464*8975f5c5SAndroid Build Coastguard Worker         {
465*8975f5c5SAndroid Build Coastguard Worker             case GL_DEPTH_COMPONENT16:
466*8975f5c5SAndroid Build Coastguard Worker             case GL_STENCIL_INDEX8:
467*8975f5c5SAndroid Build Coastguard Worker                 // Note that STENCIL_INDEX8 is not mentioned in GLES 3.0.5 section 3.8.3.1, but it
468*8975f5c5SAndroid Build Coastguard Worker                 // is in section 4.4.2.2.
469*8975f5c5SAndroid Build Coastguard Worker                 return true;
470*8975f5c5SAndroid Build Coastguard Worker             default:
471*8975f5c5SAndroid Build Coastguard Worker                 break;
472*8975f5c5SAndroid Build Coastguard Worker         }
473*8975f5c5SAndroid Build Coastguard Worker         if (version.major < 3)
474*8975f5c5SAndroid Build Coastguard Worker         {
475*8975f5c5SAndroid Build Coastguard Worker             return false;
476*8975f5c5SAndroid Build Coastguard Worker         }
477*8975f5c5SAndroid Build Coastguard Worker         // Required formats in GLES 3.0 and up.
478*8975f5c5SAndroid Build Coastguard Worker         switch (internalFormat)
479*8975f5c5SAndroid Build Coastguard Worker         {
480*8975f5c5SAndroid Build Coastguard Worker             case GL_DEPTH_COMPONENT32F:
481*8975f5c5SAndroid Build Coastguard Worker             case GL_DEPTH_COMPONENT24:
482*8975f5c5SAndroid Build Coastguard Worker             case GL_DEPTH32F_STENCIL8:
483*8975f5c5SAndroid Build Coastguard Worker             case GL_DEPTH24_STENCIL8:
484*8975f5c5SAndroid Build Coastguard Worker                 return true;
485*8975f5c5SAndroid Build Coastguard Worker             default:
486*8975f5c5SAndroid Build Coastguard Worker                 return false;
487*8975f5c5SAndroid Build Coastguard Worker         }
488*8975f5c5SAndroid Build Coastguard Worker     }
489*8975f5c5SAndroid Build Coastguard Worker 
490*8975f5c5SAndroid Build Coastguard Worker     // RGBA formats.
491*8975f5c5SAndroid Build Coastguard Worker     // GLES 2.0.25 table 4.5.
492*8975f5c5SAndroid Build Coastguard Worker     // GLES 3.0.5 section 3.8.3.1.
493*8975f5c5SAndroid Build Coastguard Worker     // GLES 3.1 table 8.13.
494*8975f5c5SAndroid Build Coastguard Worker 
495*8975f5c5SAndroid Build Coastguard Worker     // Required formats in all versions.
496*8975f5c5SAndroid Build Coastguard Worker     switch (internalFormat)
497*8975f5c5SAndroid Build Coastguard Worker     {
498*8975f5c5SAndroid Build Coastguard Worker         case GL_RGBA4:
499*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB5_A1:
500*8975f5c5SAndroid Build Coastguard Worker         case GL_RGB565:
501*8975f5c5SAndroid Build Coastguard Worker             return true;
502*8975f5c5SAndroid Build Coastguard Worker         default:
503*8975f5c5SAndroid Build Coastguard Worker             break;
504*8975f5c5SAndroid Build Coastguard Worker     }
505*8975f5c5SAndroid Build Coastguard Worker     if (version.major < 3)
506*8975f5c5SAndroid Build Coastguard Worker     {
507*8975f5c5SAndroid Build Coastguard Worker         return false;
508*8975f5c5SAndroid Build Coastguard Worker     }
509*8975f5c5SAndroid Build Coastguard Worker 
510*8975f5c5SAndroid Build Coastguard Worker     if (format == GL_BGRA_EXT)
511*8975f5c5SAndroid Build Coastguard Worker     {
512*8975f5c5SAndroid Build Coastguard Worker         return false;
513*8975f5c5SAndroid Build Coastguard Worker     }
514*8975f5c5SAndroid Build Coastguard Worker 
515*8975f5c5SAndroid Build Coastguard Worker     switch (componentType)
516*8975f5c5SAndroid Build Coastguard Worker     {
517*8975f5c5SAndroid Build Coastguard Worker         case GL_SIGNED_NORMALIZED:
518*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT:
519*8975f5c5SAndroid Build Coastguard Worker             return false;
520*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT:
521*8975f5c5SAndroid Build Coastguard Worker         case GL_INT:
522*8975f5c5SAndroid Build Coastguard Worker             // Integer RGB formats are not required renderbuffer formats.
523*8975f5c5SAndroid Build Coastguard Worker             if (alphaBits == 0 && blueBits != 0)
524*8975f5c5SAndroid Build Coastguard Worker             {
525*8975f5c5SAndroid Build Coastguard Worker                 return false;
526*8975f5c5SAndroid Build Coastguard Worker             }
527*8975f5c5SAndroid Build Coastguard Worker             // All integer R and RG formats are required.
528*8975f5c5SAndroid Build Coastguard Worker             // Integer RGBA formats including RGB10_A2_UI are required.
529*8975f5c5SAndroid Build Coastguard Worker             return true;
530*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_NORMALIZED:
531*8975f5c5SAndroid Build Coastguard Worker             if (internalFormat == GL_SRGB8)
532*8975f5c5SAndroid Build Coastguard Worker             {
533*8975f5c5SAndroid Build Coastguard Worker                 return false;
534*8975f5c5SAndroid Build Coastguard Worker             }
535*8975f5c5SAndroid Build Coastguard Worker             return true;
536*8975f5c5SAndroid Build Coastguard Worker         default:
537*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
538*8975f5c5SAndroid Build Coastguard Worker             return false;
539*8975f5c5SAndroid Build Coastguard Worker     }
540*8975f5c5SAndroid Build Coastguard Worker }
541*8975f5c5SAndroid Build Coastguard Worker 
isInt() const542*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::isInt() const
543*8975f5c5SAndroid Build Coastguard Worker {
544*8975f5c5SAndroid Build Coastguard Worker     return componentType == GL_INT || componentType == GL_UNSIGNED_INT;
545*8975f5c5SAndroid Build Coastguard Worker }
546*8975f5c5SAndroid Build Coastguard Worker 
isDepthOrStencil() const547*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::isDepthOrStencil() const
548*8975f5c5SAndroid Build Coastguard Worker {
549*8975f5c5SAndroid Build Coastguard Worker     return depthBits != 0 || stencilBits != 0;
550*8975f5c5SAndroid Build Coastguard Worker }
551*8975f5c5SAndroid Build Coastguard Worker 
getEGLConfigBufferSize() const552*8975f5c5SAndroid Build Coastguard Worker GLuint InternalFormat::getEGLConfigBufferSize() const
553*8975f5c5SAndroid Build Coastguard Worker {
554*8975f5c5SAndroid Build Coastguard Worker     // EGL config's EGL_BUFFER_SIZE is measured in bits and is the sum of all the color channels for
555*8975f5c5SAndroid Build Coastguard Worker     // color formats or the luma channels for luma formats. It ignores unused bits so compute the
556*8975f5c5SAndroid Build Coastguard Worker     // bit count by summing instead of using pixelBytes.
557*8975f5c5SAndroid Build Coastguard Worker     if (isLUMA())
558*8975f5c5SAndroid Build Coastguard Worker     {
559*8975f5c5SAndroid Build Coastguard Worker         return luminanceBits + alphaBits;
560*8975f5c5SAndroid Build Coastguard Worker     }
561*8975f5c5SAndroid Build Coastguard Worker     else
562*8975f5c5SAndroid Build Coastguard Worker     {
563*8975f5c5SAndroid Build Coastguard Worker         return redBits + greenBits + blueBits + alphaBits;
564*8975f5c5SAndroid Build Coastguard Worker     }
565*8975f5c5SAndroid Build Coastguard Worker }
566*8975f5c5SAndroid Build Coastguard Worker 
Format(GLenum internalFormat)567*8975f5c5SAndroid Build Coastguard Worker Format::Format(GLenum internalFormat) : Format(GetSizedInternalFormatInfo(internalFormat)) {}
568*8975f5c5SAndroid Build Coastguard Worker 
Format(const InternalFormat & internalFormat)569*8975f5c5SAndroid Build Coastguard Worker Format::Format(const InternalFormat &internalFormat) : info(&internalFormat) {}
570*8975f5c5SAndroid Build Coastguard Worker 
Format(GLenum internalFormat,GLenum type)571*8975f5c5SAndroid Build Coastguard Worker Format::Format(GLenum internalFormat, GLenum type)
572*8975f5c5SAndroid Build Coastguard Worker     : info(&GetInternalFormatInfo(internalFormat, type))
573*8975f5c5SAndroid Build Coastguard Worker {}
574*8975f5c5SAndroid Build Coastguard Worker 
575*8975f5c5SAndroid Build Coastguard Worker Format::Format(const Format &other)            = default;
576*8975f5c5SAndroid Build Coastguard Worker Format &Format::operator=(const Format &other) = default;
577*8975f5c5SAndroid Build Coastguard Worker 
valid() const578*8975f5c5SAndroid Build Coastguard Worker bool Format::valid() const
579*8975f5c5SAndroid Build Coastguard Worker {
580*8975f5c5SAndroid Build Coastguard Worker     return info->internalFormat != GL_NONE;
581*8975f5c5SAndroid Build Coastguard Worker }
582*8975f5c5SAndroid Build Coastguard Worker 
583*8975f5c5SAndroid Build Coastguard Worker // static
SameSized(const Format & a,const Format & b)584*8975f5c5SAndroid Build Coastguard Worker bool Format::SameSized(const Format &a, const Format &b)
585*8975f5c5SAndroid Build Coastguard Worker {
586*8975f5c5SAndroid Build Coastguard Worker     return a.info->sizedInternalFormat == b.info->sizedInternalFormat;
587*8975f5c5SAndroid Build Coastguard Worker }
588*8975f5c5SAndroid Build Coastguard Worker 
EquivalentBlitInternalFormat(GLenum internalformat)589*8975f5c5SAndroid Build Coastguard Worker static GLenum EquivalentBlitInternalFormat(GLenum internalformat)
590*8975f5c5SAndroid Build Coastguard Worker {
591*8975f5c5SAndroid Build Coastguard Worker     // BlitFramebuffer works if the color channels are identically
592*8975f5c5SAndroid Build Coastguard Worker     // sized, even if there is a swizzle (for example, blitting from a
593*8975f5c5SAndroid Build Coastguard Worker     // multisampled RGBA8 renderbuffer to a BGRA8 texture). This could
594*8975f5c5SAndroid Build Coastguard Worker     // be expanded and/or autogenerated if that is found necessary.
595*8975f5c5SAndroid Build Coastguard Worker     if (internalformat == GL_BGRA8_EXT || internalformat == GL_BGRA8_SRGB_ANGLEX)
596*8975f5c5SAndroid Build Coastguard Worker     {
597*8975f5c5SAndroid Build Coastguard Worker         return GL_RGBA8;
598*8975f5c5SAndroid Build Coastguard Worker     }
599*8975f5c5SAndroid Build Coastguard Worker 
600*8975f5c5SAndroid Build Coastguard Worker     // GL_ANGLE_rgbx_internal_format: Treat RGBX8 as RGB8, since the X channel is ignored.
601*8975f5c5SAndroid Build Coastguard Worker     if (internalformat == GL_RGBX8_ANGLE || internalformat == GL_RGBX8_SRGB_ANGLEX)
602*8975f5c5SAndroid Build Coastguard Worker     {
603*8975f5c5SAndroid Build Coastguard Worker         return GL_RGB8;
604*8975f5c5SAndroid Build Coastguard Worker     }
605*8975f5c5SAndroid Build Coastguard Worker 
606*8975f5c5SAndroid Build Coastguard Worker     // Treat ANGLE's BGRX8 as RGB8 since it's swizzled and the X channel is ignored.
607*8975f5c5SAndroid Build Coastguard Worker     if (internalformat == GL_BGRX8_ANGLEX || internalformat == GL_BGRX8_SRGB_ANGLEX)
608*8975f5c5SAndroid Build Coastguard Worker     {
609*8975f5c5SAndroid Build Coastguard Worker         return GL_RGB8;
610*8975f5c5SAndroid Build Coastguard Worker     }
611*8975f5c5SAndroid Build Coastguard Worker 
612*8975f5c5SAndroid Build Coastguard Worker     return internalformat;
613*8975f5c5SAndroid Build Coastguard Worker }
614*8975f5c5SAndroid Build Coastguard Worker 
615*8975f5c5SAndroid Build Coastguard Worker // static
EquivalentForBlit(const Format & a,const Format & b)616*8975f5c5SAndroid Build Coastguard Worker bool Format::EquivalentForBlit(const Format &a, const Format &b)
617*8975f5c5SAndroid Build Coastguard Worker {
618*8975f5c5SAndroid Build Coastguard Worker     return (EquivalentBlitInternalFormat(a.info->sizedInternalFormat) ==
619*8975f5c5SAndroid Build Coastguard Worker             EquivalentBlitInternalFormat(b.info->sizedInternalFormat));
620*8975f5c5SAndroid Build Coastguard Worker }
621*8975f5c5SAndroid Build Coastguard Worker 
622*8975f5c5SAndroid Build Coastguard Worker // static
Invalid()623*8975f5c5SAndroid Build Coastguard Worker Format Format::Invalid()
624*8975f5c5SAndroid Build Coastguard Worker {
625*8975f5c5SAndroid Build Coastguard Worker     static Format invalid(GL_NONE, GL_NONE);
626*8975f5c5SAndroid Build Coastguard Worker     return invalid;
627*8975f5c5SAndroid Build Coastguard Worker }
628*8975f5c5SAndroid Build Coastguard Worker 
operator <<(std::ostream & os,const Format & fmt)629*8975f5c5SAndroid Build Coastguard Worker std::ostream &operator<<(std::ostream &os, const Format &fmt)
630*8975f5c5SAndroid Build Coastguard Worker {
631*8975f5c5SAndroid Build Coastguard Worker     // TODO(ynovikov): return string representation when available
632*8975f5c5SAndroid Build Coastguard Worker     return FmtHex(os, fmt.info->sizedInternalFormat);
633*8975f5c5SAndroid Build Coastguard Worker }
634*8975f5c5SAndroid Build Coastguard Worker 
operator ==(const InternalFormat & other) const635*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::operator==(const InternalFormat &other) const
636*8975f5c5SAndroid Build Coastguard Worker {
637*8975f5c5SAndroid Build Coastguard Worker     // We assume all internal formats are unique if they have the same internal format and type
638*8975f5c5SAndroid Build Coastguard Worker     return internalFormat == other.internalFormat && type == other.type;
639*8975f5c5SAndroid Build Coastguard Worker }
640*8975f5c5SAndroid Build Coastguard Worker 
operator !=(const InternalFormat & other) const641*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::operator!=(const InternalFormat &other) const
642*8975f5c5SAndroid Build Coastguard Worker {
643*8975f5c5SAndroid Build Coastguard Worker     return !(*this == other);
644*8975f5c5SAndroid Build Coastguard Worker }
645*8975f5c5SAndroid Build Coastguard Worker 
InsertFormatInfo(InternalFormatInfoMap * map,const InternalFormat & formatInfo)646*8975f5c5SAndroid Build Coastguard Worker void InsertFormatInfo(InternalFormatInfoMap *map, const InternalFormat &formatInfo)
647*8975f5c5SAndroid Build Coastguard Worker {
648*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!formatInfo.sized || (*map).count(formatInfo.internalFormat) == 0);
649*8975f5c5SAndroid Build Coastguard Worker     ASSERT((*map)[formatInfo.internalFormat].count(formatInfo.type) == 0);
650*8975f5c5SAndroid Build Coastguard Worker     (*map)[formatInfo.internalFormat][formatInfo.type] = formatInfo;
651*8975f5c5SAndroid Build Coastguard Worker }
652*8975f5c5SAndroid Build Coastguard Worker 
653*8975f5c5SAndroid Build Coastguard Worker // YuvFormatInfo implementation
YuvFormatInfo(GLenum internalFormat,const Extents & yPlaneExtent)654*8975f5c5SAndroid Build Coastguard Worker YuvFormatInfo::YuvFormatInfo(GLenum internalFormat, const Extents &yPlaneExtent)
655*8975f5c5SAndroid Build Coastguard Worker {
656*8975f5c5SAndroid Build Coastguard Worker     ASSERT(gl::IsYuvFormat(internalFormat));
657*8975f5c5SAndroid Build Coastguard Worker     ASSERT((gl::GetPlaneCount(internalFormat) > 0) && (gl::GetPlaneCount(internalFormat) <= 3));
658*8975f5c5SAndroid Build Coastguard Worker 
659*8975f5c5SAndroid Build Coastguard Worker     glInternalFormat = internalFormat;
660*8975f5c5SAndroid Build Coastguard Worker     planeCount       = gl::GetPlaneCount(internalFormat);
661*8975f5c5SAndroid Build Coastguard Worker 
662*8975f5c5SAndroid Build Coastguard Worker     // Chroma planes of a YUV format can be subsampled
663*8975f5c5SAndroid Build Coastguard Worker     int horizontalSubsampleFactor = 0;
664*8975f5c5SAndroid Build Coastguard Worker     int verticalSubsampleFactor   = 0;
665*8975f5c5SAndroid Build Coastguard Worker     gl::GetSubSampleFactor(internalFormat, &horizontalSubsampleFactor, &verticalSubsampleFactor);
666*8975f5c5SAndroid Build Coastguard Worker 
667*8975f5c5SAndroid Build Coastguard Worker     // Compute plane Bpp
668*8975f5c5SAndroid Build Coastguard Worker     planeBpp[0] = gl::GetYPlaneBpp(internalFormat);
669*8975f5c5SAndroid Build Coastguard Worker     planeBpp[1] = gl::GetChromaPlaneBpp(internalFormat);
670*8975f5c5SAndroid Build Coastguard Worker     planeBpp[2] = (planeCount > 2) ? planeBpp[1] : 0;
671*8975f5c5SAndroid Build Coastguard Worker 
672*8975f5c5SAndroid Build Coastguard Worker     // Compute plane extent
673*8975f5c5SAndroid Build Coastguard Worker     planeExtent[0] = yPlaneExtent;
674*8975f5c5SAndroid Build Coastguard Worker     planeExtent[1] = {(yPlaneExtent.width / horizontalSubsampleFactor),
675*8975f5c5SAndroid Build Coastguard Worker                       (yPlaneExtent.height / verticalSubsampleFactor), yPlaneExtent.depth};
676*8975f5c5SAndroid Build Coastguard Worker     planeExtent[2] = (planeCount > 2) ? planeExtent[1] : Extents();
677*8975f5c5SAndroid Build Coastguard Worker 
678*8975f5c5SAndroid Build Coastguard Worker     // Compute plane pitch
679*8975f5c5SAndroid Build Coastguard Worker     planePitch[0] = planeExtent[0].width * planeBpp[0];
680*8975f5c5SAndroid Build Coastguard Worker     planePitch[1] = planeExtent[1].width * planeBpp[1];
681*8975f5c5SAndroid Build Coastguard Worker     planePitch[2] = planeExtent[2].width * planeBpp[2];
682*8975f5c5SAndroid Build Coastguard Worker 
683*8975f5c5SAndroid Build Coastguard Worker     // Compute plane size
684*8975f5c5SAndroid Build Coastguard Worker     planeSize[0] = planePitch[0] * planeExtent[0].height;
685*8975f5c5SAndroid Build Coastguard Worker     planeSize[1] = planePitch[1] * planeExtent[1].height;
686*8975f5c5SAndroid Build Coastguard Worker     planeSize[2] = planePitch[2] * planeExtent[2].height;
687*8975f5c5SAndroid Build Coastguard Worker 
688*8975f5c5SAndroid Build Coastguard Worker     // Compute plane offset
689*8975f5c5SAndroid Build Coastguard Worker     planeOffset[0] = 0;
690*8975f5c5SAndroid Build Coastguard Worker     planeOffset[1] = planeSize[0];
691*8975f5c5SAndroid Build Coastguard Worker     planeOffset[2] = planeSize[0] + planeSize[1];
692*8975f5c5SAndroid Build Coastguard Worker }
693*8975f5c5SAndroid Build Coastguard Worker 
694*8975f5c5SAndroid Build Coastguard Worker // YUV format related helpers
IsYuvFormat(GLenum format)695*8975f5c5SAndroid Build Coastguard Worker bool IsYuvFormat(GLenum format)
696*8975f5c5SAndroid Build Coastguard Worker {
697*8975f5c5SAndroid Build Coastguard Worker     switch (format)
698*8975f5c5SAndroid Build Coastguard Worker     {
699*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
700*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
701*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
702*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
703*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
704*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
705*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
706*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
707*8975f5c5SAndroid Build Coastguard Worker             return true;
708*8975f5c5SAndroid Build Coastguard Worker         default:
709*8975f5c5SAndroid Build Coastguard Worker             return false;
710*8975f5c5SAndroid Build Coastguard Worker     }
711*8975f5c5SAndroid Build Coastguard Worker }
712*8975f5c5SAndroid Build Coastguard Worker 
GetPlaneCount(GLenum format)713*8975f5c5SAndroid Build Coastguard Worker uint32_t GetPlaneCount(GLenum format)
714*8975f5c5SAndroid Build Coastguard Worker {
715*8975f5c5SAndroid Build Coastguard Worker     switch (format)
716*8975f5c5SAndroid Build Coastguard Worker     {
717*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
718*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
719*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
720*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
721*8975f5c5SAndroid Build Coastguard Worker             return 2;
722*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
723*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
724*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
725*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
726*8975f5c5SAndroid Build Coastguard Worker             return 3;
727*8975f5c5SAndroid Build Coastguard Worker         default:
728*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
729*8975f5c5SAndroid Build Coastguard Worker             return 0;
730*8975f5c5SAndroid Build Coastguard Worker     }
731*8975f5c5SAndroid Build Coastguard Worker }
732*8975f5c5SAndroid Build Coastguard Worker 
GetYPlaneBpp(GLenum format)733*8975f5c5SAndroid Build Coastguard Worker uint32_t GetYPlaneBpp(GLenum format)
734*8975f5c5SAndroid Build Coastguard Worker {
735*8975f5c5SAndroid Build Coastguard Worker     switch (format)
736*8975f5c5SAndroid Build Coastguard Worker     {
737*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
738*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
739*8975f5c5SAndroid Build Coastguard Worker             return 1;
740*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
741*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
742*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
743*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
744*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
745*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
746*8975f5c5SAndroid Build Coastguard Worker             return 2;
747*8975f5c5SAndroid Build Coastguard Worker         default:
748*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
749*8975f5c5SAndroid Build Coastguard Worker             return 0;
750*8975f5c5SAndroid Build Coastguard Worker     }
751*8975f5c5SAndroid Build Coastguard Worker }
752*8975f5c5SAndroid Build Coastguard Worker 
GetChromaPlaneBpp(GLenum format)753*8975f5c5SAndroid Build Coastguard Worker uint32_t GetChromaPlaneBpp(GLenum format)
754*8975f5c5SAndroid Build Coastguard Worker {
755*8975f5c5SAndroid Build Coastguard Worker     // 2 plane 420 YUV formats have CbCr channels interleaved.
756*8975f5c5SAndroid Build Coastguard Worker     // 3 plane 420 YUV formats have separate Cb and Cr planes.
757*8975f5c5SAndroid Build Coastguard Worker     switch (format)
758*8975f5c5SAndroid Build Coastguard Worker     {
759*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
760*8975f5c5SAndroid Build Coastguard Worker             return 1;
761*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
762*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
763*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
764*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
765*8975f5c5SAndroid Build Coastguard Worker             return 2;
766*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
767*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
768*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
769*8975f5c5SAndroid Build Coastguard Worker             return 4;
770*8975f5c5SAndroid Build Coastguard Worker         default:
771*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
772*8975f5c5SAndroid Build Coastguard Worker             return 0;
773*8975f5c5SAndroid Build Coastguard Worker     }
774*8975f5c5SAndroid Build Coastguard Worker }
775*8975f5c5SAndroid Build Coastguard Worker 
GetSubSampleFactor(GLenum format,int * horizontalSubsampleFactor,int * verticalSubsampleFactor)776*8975f5c5SAndroid Build Coastguard Worker void GetSubSampleFactor(GLenum format, int *horizontalSubsampleFactor, int *verticalSubsampleFactor)
777*8975f5c5SAndroid Build Coastguard Worker {
778*8975f5c5SAndroid Build Coastguard Worker     ASSERT(horizontalSubsampleFactor && verticalSubsampleFactor);
779*8975f5c5SAndroid Build Coastguard Worker 
780*8975f5c5SAndroid Build Coastguard Worker     switch (format)
781*8975f5c5SAndroid Build Coastguard Worker     {
782*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
783*8975f5c5SAndroid Build Coastguard Worker         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
784*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
785*8975f5c5SAndroid Build Coastguard Worker         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
786*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
787*8975f5c5SAndroid Build Coastguard Worker         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
788*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
789*8975f5c5SAndroid Build Coastguard Worker         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
790*8975f5c5SAndroid Build Coastguard Worker             *horizontalSubsampleFactor = 2;
791*8975f5c5SAndroid Build Coastguard Worker             *verticalSubsampleFactor   = 2;
792*8975f5c5SAndroid Build Coastguard Worker             break;
793*8975f5c5SAndroid Build Coastguard Worker         default:
794*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
795*8975f5c5SAndroid Build Coastguard Worker             break;
796*8975f5c5SAndroid Build Coastguard Worker     }
797*8975f5c5SAndroid Build Coastguard Worker }
798*8975f5c5SAndroid Build Coastguard Worker 
799*8975f5c5SAndroid Build Coastguard Worker struct FormatBits
800*8975f5c5SAndroid Build Coastguard Worker {
pixelBytesgl::FormatBits801*8975f5c5SAndroid Build Coastguard Worker     constexpr GLuint pixelBytes() const
802*8975f5c5SAndroid Build Coastguard Worker     {
803*8975f5c5SAndroid Build Coastguard Worker         return (red + green + blue + alpha + shared + unused) / 8;
804*8975f5c5SAndroid Build Coastguard Worker     }
componentCountgl::FormatBits805*8975f5c5SAndroid Build Coastguard Worker     constexpr GLuint componentCount() const
806*8975f5c5SAndroid Build Coastguard Worker     {
807*8975f5c5SAndroid Build Coastguard Worker         return ((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) +
808*8975f5c5SAndroid Build Coastguard Worker                ((alpha > 0) ? 1 : 0);
809*8975f5c5SAndroid Build Coastguard Worker     }
validgl::FormatBits810*8975f5c5SAndroid Build Coastguard Worker     constexpr bool valid() const
811*8975f5c5SAndroid Build Coastguard Worker     {
812*8975f5c5SAndroid Build Coastguard Worker         return ((red + green + blue + alpha + shared + unused) % 8) == 0;
813*8975f5c5SAndroid Build Coastguard Worker     }
814*8975f5c5SAndroid Build Coastguard Worker 
815*8975f5c5SAndroid Build Coastguard Worker     GLuint red;
816*8975f5c5SAndroid Build Coastguard Worker     GLuint green;
817*8975f5c5SAndroid Build Coastguard Worker     GLuint blue;
818*8975f5c5SAndroid Build Coastguard Worker     GLuint alpha;
819*8975f5c5SAndroid Build Coastguard Worker     GLuint unused;
820*8975f5c5SAndroid Build Coastguard Worker     GLuint shared;
821*8975f5c5SAndroid Build Coastguard Worker };
822*8975f5c5SAndroid Build Coastguard Worker 
823*8975f5c5SAndroid Build Coastguard Worker template <GLuint red, GLuint green, GLuint blue, GLuint alpha, GLuint unused, GLuint shared>
FB()824*8975f5c5SAndroid Build Coastguard Worker constexpr FormatBits FB()
825*8975f5c5SAndroid Build Coastguard Worker {
826*8975f5c5SAndroid Build Coastguard Worker     constexpr FormatBits formatBits = {red, green, blue, alpha, unused, shared};
827*8975f5c5SAndroid Build Coastguard Worker     static_assert(formatBits.valid(), "Invalid FormatBits");
828*8975f5c5SAndroid Build Coastguard Worker     return formatBits;
829*8975f5c5SAndroid Build Coastguard Worker }
830*8975f5c5SAndroid Build Coastguard Worker 
AddRGBAXFormat(InternalFormatInfoMap * map,GLenum internalFormat,bool sized,const FormatBits & formatBits,GLenum format,GLenum type,GLenum componentType,bool srgb,InternalFormat::SupportCheckFunction textureSupport,InternalFormat::SupportCheckFunction filterSupport,InternalFormat::SupportCheckFunction textureAttachmentSupport,InternalFormat::SupportCheckFunction renderbufferSupport,InternalFormat::SupportCheckFunction blendSupport)831*8975f5c5SAndroid Build Coastguard Worker void AddRGBAXFormat(InternalFormatInfoMap *map,
832*8975f5c5SAndroid Build Coastguard Worker                     GLenum internalFormat,
833*8975f5c5SAndroid Build Coastguard Worker                     bool sized,
834*8975f5c5SAndroid Build Coastguard Worker                     const FormatBits &formatBits,
835*8975f5c5SAndroid Build Coastguard Worker                     GLenum format,
836*8975f5c5SAndroid Build Coastguard Worker                     GLenum type,
837*8975f5c5SAndroid Build Coastguard Worker                     GLenum componentType,
838*8975f5c5SAndroid Build Coastguard Worker                     bool srgb,
839*8975f5c5SAndroid Build Coastguard Worker                     InternalFormat::SupportCheckFunction textureSupport,
840*8975f5c5SAndroid Build Coastguard Worker                     InternalFormat::SupportCheckFunction filterSupport,
841*8975f5c5SAndroid Build Coastguard Worker                     InternalFormat::SupportCheckFunction textureAttachmentSupport,
842*8975f5c5SAndroid Build Coastguard Worker                     InternalFormat::SupportCheckFunction renderbufferSupport,
843*8975f5c5SAndroid Build Coastguard Worker                     InternalFormat::SupportCheckFunction blendSupport)
844*8975f5c5SAndroid Build Coastguard Worker {
845*8975f5c5SAndroid Build Coastguard Worker     ASSERT(formatBits.valid());
846*8975f5c5SAndroid Build Coastguard Worker 
847*8975f5c5SAndroid Build Coastguard Worker     InternalFormat formatInfo;
848*8975f5c5SAndroid Build Coastguard Worker     formatInfo.internalFormat = internalFormat;
849*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sized          = sized;
850*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sizedInternalFormat =
851*8975f5c5SAndroid Build Coastguard Worker         sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
852*8975f5c5SAndroid Build Coastguard Worker     formatInfo.redBits                  = formatBits.red;
853*8975f5c5SAndroid Build Coastguard Worker     formatInfo.greenBits                = formatBits.green;
854*8975f5c5SAndroid Build Coastguard Worker     formatInfo.blueBits                 = formatBits.blue;
855*8975f5c5SAndroid Build Coastguard Worker     formatInfo.alphaBits                = formatBits.alpha;
856*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sharedBits               = formatBits.shared;
857*8975f5c5SAndroid Build Coastguard Worker     formatInfo.pixelBytes               = formatBits.pixelBytes();
858*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentCount           = formatBits.componentCount();
859*8975f5c5SAndroid Build Coastguard Worker     formatInfo.format                   = format;
860*8975f5c5SAndroid Build Coastguard Worker     formatInfo.type                     = type;
861*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentType            = componentType;
862*8975f5c5SAndroid Build Coastguard Worker     formatInfo.colorEncoding            = (srgb ? GL_SRGB : GL_LINEAR);
863*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureSupport           = textureSupport;
864*8975f5c5SAndroid Build Coastguard Worker     formatInfo.filterSupport            = filterSupport;
865*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
866*8975f5c5SAndroid Build Coastguard Worker     formatInfo.renderbufferSupport      = renderbufferSupport;
867*8975f5c5SAndroid Build Coastguard Worker     formatInfo.blendSupport             = blendSupport;
868*8975f5c5SAndroid Build Coastguard Worker 
869*8975f5c5SAndroid Build Coastguard Worker     InsertFormatInfo(map, formatInfo);
870*8975f5c5SAndroid Build Coastguard Worker }
871*8975f5c5SAndroid Build Coastguard Worker 
AddRGBAFormat(InternalFormatInfoMap * map,GLenum internalFormat,bool sized,GLuint red,GLuint green,GLuint blue,GLuint alpha,GLuint shared,GLenum format,GLenum type,GLenum componentType,bool srgb,InternalFormat::SupportCheckFunction textureSupport,InternalFormat::SupportCheckFunction filterSupport,InternalFormat::SupportCheckFunction textureAttachmentSupport,InternalFormat::SupportCheckFunction renderbufferSupport,InternalFormat::SupportCheckFunction blendSupport)872*8975f5c5SAndroid Build Coastguard Worker void AddRGBAFormat(InternalFormatInfoMap *map,
873*8975f5c5SAndroid Build Coastguard Worker                    GLenum internalFormat,
874*8975f5c5SAndroid Build Coastguard Worker                    bool sized,
875*8975f5c5SAndroid Build Coastguard Worker                    GLuint red,
876*8975f5c5SAndroid Build Coastguard Worker                    GLuint green,
877*8975f5c5SAndroid Build Coastguard Worker                    GLuint blue,
878*8975f5c5SAndroid Build Coastguard Worker                    GLuint alpha,
879*8975f5c5SAndroid Build Coastguard Worker                    GLuint shared,
880*8975f5c5SAndroid Build Coastguard Worker                    GLenum format,
881*8975f5c5SAndroid Build Coastguard Worker                    GLenum type,
882*8975f5c5SAndroid Build Coastguard Worker                    GLenum componentType,
883*8975f5c5SAndroid Build Coastguard Worker                    bool srgb,
884*8975f5c5SAndroid Build Coastguard Worker                    InternalFormat::SupportCheckFunction textureSupport,
885*8975f5c5SAndroid Build Coastguard Worker                    InternalFormat::SupportCheckFunction filterSupport,
886*8975f5c5SAndroid Build Coastguard Worker                    InternalFormat::SupportCheckFunction textureAttachmentSupport,
887*8975f5c5SAndroid Build Coastguard Worker                    InternalFormat::SupportCheckFunction renderbufferSupport,
888*8975f5c5SAndroid Build Coastguard Worker                    InternalFormat::SupportCheckFunction blendSupport)
889*8975f5c5SAndroid Build Coastguard Worker {
890*8975f5c5SAndroid Build Coastguard Worker     return AddRGBAXFormat(map, internalFormat, sized, {red, green, blue, alpha, 0, shared}, format,
891*8975f5c5SAndroid Build Coastguard Worker                           type, componentType, srgb, textureSupport, filterSupport,
892*8975f5c5SAndroid Build Coastguard Worker                           textureAttachmentSupport, renderbufferSupport, blendSupport);
893*8975f5c5SAndroid Build Coastguard Worker }
894*8975f5c5SAndroid Build Coastguard Worker 
AddLUMAFormat(InternalFormatInfoMap * map,GLenum internalFormat,bool sized,GLuint luminance,GLuint alpha,GLenum format,GLenum type,GLenum componentType,InternalFormat::SupportCheckFunction textureSupport,InternalFormat::SupportCheckFunction filterSupport,InternalFormat::SupportCheckFunction textureAttachmentSupport,InternalFormat::SupportCheckFunction renderbufferSupport,InternalFormat::SupportCheckFunction blendSupport)895*8975f5c5SAndroid Build Coastguard Worker static void AddLUMAFormat(InternalFormatInfoMap *map,
896*8975f5c5SAndroid Build Coastguard Worker                           GLenum internalFormat,
897*8975f5c5SAndroid Build Coastguard Worker                           bool sized,
898*8975f5c5SAndroid Build Coastguard Worker                           GLuint luminance,
899*8975f5c5SAndroid Build Coastguard Worker                           GLuint alpha,
900*8975f5c5SAndroid Build Coastguard Worker                           GLenum format,
901*8975f5c5SAndroid Build Coastguard Worker                           GLenum type,
902*8975f5c5SAndroid Build Coastguard Worker                           GLenum componentType,
903*8975f5c5SAndroid Build Coastguard Worker                           InternalFormat::SupportCheckFunction textureSupport,
904*8975f5c5SAndroid Build Coastguard Worker                           InternalFormat::SupportCheckFunction filterSupport,
905*8975f5c5SAndroid Build Coastguard Worker                           InternalFormat::SupportCheckFunction textureAttachmentSupport,
906*8975f5c5SAndroid Build Coastguard Worker                           InternalFormat::SupportCheckFunction renderbufferSupport,
907*8975f5c5SAndroid Build Coastguard Worker                           InternalFormat::SupportCheckFunction blendSupport)
908*8975f5c5SAndroid Build Coastguard Worker {
909*8975f5c5SAndroid Build Coastguard Worker     InternalFormat formatInfo;
910*8975f5c5SAndroid Build Coastguard Worker     formatInfo.internalFormat = internalFormat;
911*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sized          = sized;
912*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sizedInternalFormat =
913*8975f5c5SAndroid Build Coastguard Worker         sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
914*8975f5c5SAndroid Build Coastguard Worker     formatInfo.luminanceBits            = luminance;
915*8975f5c5SAndroid Build Coastguard Worker     formatInfo.alphaBits                = alpha;
916*8975f5c5SAndroid Build Coastguard Worker     formatInfo.pixelBytes               = (luminance + alpha) / 8;
917*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentCount           = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
918*8975f5c5SAndroid Build Coastguard Worker     formatInfo.format                   = format;
919*8975f5c5SAndroid Build Coastguard Worker     formatInfo.type                     = type;
920*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentType            = componentType;
921*8975f5c5SAndroid Build Coastguard Worker     formatInfo.colorEncoding            = GL_LINEAR;
922*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureSupport           = textureSupport;
923*8975f5c5SAndroid Build Coastguard Worker     formatInfo.filterSupport            = filterSupport;
924*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
925*8975f5c5SAndroid Build Coastguard Worker     formatInfo.renderbufferSupport      = renderbufferSupport;
926*8975f5c5SAndroid Build Coastguard Worker     formatInfo.blendSupport             = blendSupport;
927*8975f5c5SAndroid Build Coastguard Worker 
928*8975f5c5SAndroid Build Coastguard Worker     InsertFormatInfo(map, formatInfo);
929*8975f5c5SAndroid Build Coastguard Worker }
930*8975f5c5SAndroid Build Coastguard Worker 
AddDepthStencilFormat(InternalFormatInfoMap * map,GLenum internalFormat,bool sized,GLuint depthBits,GLuint stencilBits,GLuint unusedBits,GLenum format,GLenum type,GLenum componentType,InternalFormat::SupportCheckFunction textureSupport,InternalFormat::SupportCheckFunction filterSupport,InternalFormat::SupportCheckFunction textureAttachmentSupport,InternalFormat::SupportCheckFunction renderbufferSupport,InternalFormat::SupportCheckFunction blendSupport)931*8975f5c5SAndroid Build Coastguard Worker void AddDepthStencilFormat(InternalFormatInfoMap *map,
932*8975f5c5SAndroid Build Coastguard Worker                            GLenum internalFormat,
933*8975f5c5SAndroid Build Coastguard Worker                            bool sized,
934*8975f5c5SAndroid Build Coastguard Worker                            GLuint depthBits,
935*8975f5c5SAndroid Build Coastguard Worker                            GLuint stencilBits,
936*8975f5c5SAndroid Build Coastguard Worker                            GLuint unusedBits,
937*8975f5c5SAndroid Build Coastguard Worker                            GLenum format,
938*8975f5c5SAndroid Build Coastguard Worker                            GLenum type,
939*8975f5c5SAndroid Build Coastguard Worker                            GLenum componentType,
940*8975f5c5SAndroid Build Coastguard Worker                            InternalFormat::SupportCheckFunction textureSupport,
941*8975f5c5SAndroid Build Coastguard Worker                            InternalFormat::SupportCheckFunction filterSupport,
942*8975f5c5SAndroid Build Coastguard Worker                            InternalFormat::SupportCheckFunction textureAttachmentSupport,
943*8975f5c5SAndroid Build Coastguard Worker                            InternalFormat::SupportCheckFunction renderbufferSupport,
944*8975f5c5SAndroid Build Coastguard Worker                            InternalFormat::SupportCheckFunction blendSupport)
945*8975f5c5SAndroid Build Coastguard Worker {
946*8975f5c5SAndroid Build Coastguard Worker     InternalFormat formatInfo;
947*8975f5c5SAndroid Build Coastguard Worker     formatInfo.internalFormat = internalFormat;
948*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sized          = sized;
949*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sizedInternalFormat =
950*8975f5c5SAndroid Build Coastguard Worker         sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
951*8975f5c5SAndroid Build Coastguard Worker     formatInfo.depthBits                = depthBits;
952*8975f5c5SAndroid Build Coastguard Worker     formatInfo.stencilBits              = stencilBits;
953*8975f5c5SAndroid Build Coastguard Worker     formatInfo.pixelBytes               = (depthBits + stencilBits + unusedBits) / 8;
954*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentCount           = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0);
955*8975f5c5SAndroid Build Coastguard Worker     formatInfo.format                   = format;
956*8975f5c5SAndroid Build Coastguard Worker     formatInfo.type                     = type;
957*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentType            = componentType;
958*8975f5c5SAndroid Build Coastguard Worker     formatInfo.colorEncoding            = GL_LINEAR;
959*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureSupport           = textureSupport;
960*8975f5c5SAndroid Build Coastguard Worker     formatInfo.filterSupport            = filterSupport;
961*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
962*8975f5c5SAndroid Build Coastguard Worker     formatInfo.renderbufferSupport      = renderbufferSupport;
963*8975f5c5SAndroid Build Coastguard Worker     formatInfo.blendSupport             = blendSupport;
964*8975f5c5SAndroid Build Coastguard Worker 
965*8975f5c5SAndroid Build Coastguard Worker     InsertFormatInfo(map, formatInfo);
966*8975f5c5SAndroid Build Coastguard Worker }
967*8975f5c5SAndroid Build Coastguard Worker 
AddCompressedFormat(InternalFormatInfoMap * map,GLenum internalFormat,GLuint compressedBlockWidth,GLuint compressedBlockHeight,GLuint compressedBlockDepth,GLuint compressedBlockSize,GLuint componentCount,bool srgb,InternalFormat::SupportCheckFunction textureSupport,InternalFormat::SupportCheckFunction filterSupport,InternalFormat::SupportCheckFunction textureAttachmentSupport,InternalFormat::SupportCheckFunction renderbufferSupport,InternalFormat::SupportCheckFunction blendSupport)968*8975f5c5SAndroid Build Coastguard Worker void AddCompressedFormat(InternalFormatInfoMap *map,
969*8975f5c5SAndroid Build Coastguard Worker                          GLenum internalFormat,
970*8975f5c5SAndroid Build Coastguard Worker                          GLuint compressedBlockWidth,
971*8975f5c5SAndroid Build Coastguard Worker                          GLuint compressedBlockHeight,
972*8975f5c5SAndroid Build Coastguard Worker                          GLuint compressedBlockDepth,
973*8975f5c5SAndroid Build Coastguard Worker                          GLuint compressedBlockSize,
974*8975f5c5SAndroid Build Coastguard Worker                          GLuint componentCount,
975*8975f5c5SAndroid Build Coastguard Worker                          bool srgb,
976*8975f5c5SAndroid Build Coastguard Worker                          InternalFormat::SupportCheckFunction textureSupport,
977*8975f5c5SAndroid Build Coastguard Worker                          InternalFormat::SupportCheckFunction filterSupport,
978*8975f5c5SAndroid Build Coastguard Worker                          InternalFormat::SupportCheckFunction textureAttachmentSupport,
979*8975f5c5SAndroid Build Coastguard Worker                          InternalFormat::SupportCheckFunction renderbufferSupport,
980*8975f5c5SAndroid Build Coastguard Worker                          InternalFormat::SupportCheckFunction blendSupport)
981*8975f5c5SAndroid Build Coastguard Worker {
982*8975f5c5SAndroid Build Coastguard Worker     InternalFormat formatInfo;
983*8975f5c5SAndroid Build Coastguard Worker     formatInfo.internalFormat           = internalFormat;
984*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sized                    = true;
985*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sizedInternalFormat      = internalFormat;
986*8975f5c5SAndroid Build Coastguard Worker     formatInfo.compressedBlockWidth     = compressedBlockWidth;
987*8975f5c5SAndroid Build Coastguard Worker     formatInfo.compressedBlockHeight    = compressedBlockHeight;
988*8975f5c5SAndroid Build Coastguard Worker     formatInfo.compressedBlockDepth     = compressedBlockDepth;
989*8975f5c5SAndroid Build Coastguard Worker     formatInfo.pixelBytes               = compressedBlockSize / 8;
990*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentCount           = componentCount;
991*8975f5c5SAndroid Build Coastguard Worker     formatInfo.format                   = internalFormat;
992*8975f5c5SAndroid Build Coastguard Worker     formatInfo.type                     = GL_UNSIGNED_BYTE;
993*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentType            = GL_UNSIGNED_NORMALIZED;
994*8975f5c5SAndroid Build Coastguard Worker     formatInfo.colorEncoding            = (srgb ? GL_SRGB : GL_LINEAR);
995*8975f5c5SAndroid Build Coastguard Worker     formatInfo.compressed               = true;
996*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureSupport           = textureSupport;
997*8975f5c5SAndroid Build Coastguard Worker     formatInfo.filterSupport            = filterSupport;
998*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
999*8975f5c5SAndroid Build Coastguard Worker     formatInfo.renderbufferSupport      = renderbufferSupport;
1000*8975f5c5SAndroid Build Coastguard Worker     formatInfo.blendSupport             = blendSupport;
1001*8975f5c5SAndroid Build Coastguard Worker 
1002*8975f5c5SAndroid Build Coastguard Worker     InsertFormatInfo(map, formatInfo);
1003*8975f5c5SAndroid Build Coastguard Worker }
1004*8975f5c5SAndroid Build Coastguard Worker 
AddPalettedFormat(InternalFormatInfoMap * map,GLenum internalFormat,GLuint paletteBits,GLuint pixelBytes,GLenum format,GLuint componentCount,InternalFormat::SupportCheckFunction textureSupport,InternalFormat::SupportCheckFunction filterSupport,InternalFormat::SupportCheckFunction textureAttachmentSupport,InternalFormat::SupportCheckFunction renderbufferSupport,InternalFormat::SupportCheckFunction blendSupport)1005*8975f5c5SAndroid Build Coastguard Worker void AddPalettedFormat(InternalFormatInfoMap *map,
1006*8975f5c5SAndroid Build Coastguard Worker                        GLenum internalFormat,
1007*8975f5c5SAndroid Build Coastguard Worker                        GLuint paletteBits,
1008*8975f5c5SAndroid Build Coastguard Worker                        GLuint pixelBytes,
1009*8975f5c5SAndroid Build Coastguard Worker                        GLenum format,
1010*8975f5c5SAndroid Build Coastguard Worker                        GLuint componentCount,
1011*8975f5c5SAndroid Build Coastguard Worker                        InternalFormat::SupportCheckFunction textureSupport,
1012*8975f5c5SAndroid Build Coastguard Worker                        InternalFormat::SupportCheckFunction filterSupport,
1013*8975f5c5SAndroid Build Coastguard Worker                        InternalFormat::SupportCheckFunction textureAttachmentSupport,
1014*8975f5c5SAndroid Build Coastguard Worker                        InternalFormat::SupportCheckFunction renderbufferSupport,
1015*8975f5c5SAndroid Build Coastguard Worker                        InternalFormat::SupportCheckFunction blendSupport)
1016*8975f5c5SAndroid Build Coastguard Worker {
1017*8975f5c5SAndroid Build Coastguard Worker     InternalFormat formatInfo;
1018*8975f5c5SAndroid Build Coastguard Worker     formatInfo.internalFormat           = internalFormat;
1019*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sized                    = true;
1020*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sizedInternalFormat      = internalFormat;
1021*8975f5c5SAndroid Build Coastguard Worker     formatInfo.paletteBits              = paletteBits;
1022*8975f5c5SAndroid Build Coastguard Worker     formatInfo.pixelBytes               = pixelBytes;
1023*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentCount           = componentCount;
1024*8975f5c5SAndroid Build Coastguard Worker     formatInfo.format                   = format;
1025*8975f5c5SAndroid Build Coastguard Worker     formatInfo.type                     = GL_UNSIGNED_BYTE;
1026*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentType            = GL_UNSIGNED_NORMALIZED;
1027*8975f5c5SAndroid Build Coastguard Worker     formatInfo.colorEncoding            = GL_LINEAR;
1028*8975f5c5SAndroid Build Coastguard Worker     formatInfo.paletted                 = true;
1029*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureSupport           = textureSupport;
1030*8975f5c5SAndroid Build Coastguard Worker     formatInfo.filterSupport            = filterSupport;
1031*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
1032*8975f5c5SAndroid Build Coastguard Worker     formatInfo.renderbufferSupport      = renderbufferSupport;
1033*8975f5c5SAndroid Build Coastguard Worker     formatInfo.blendSupport             = blendSupport;
1034*8975f5c5SAndroid Build Coastguard Worker 
1035*8975f5c5SAndroid Build Coastguard Worker     InsertFormatInfo(map, formatInfo);
1036*8975f5c5SAndroid Build Coastguard Worker }
1037*8975f5c5SAndroid Build Coastguard Worker 
AddYUVFormat(InternalFormatInfoMap * map,GLenum internalFormat,bool sized,GLuint cr,GLuint y,GLuint cb,GLuint alpha,GLuint shared,GLenum format,GLenum type,GLenum componentType,bool srgb,InternalFormat::SupportCheckFunction textureSupport,InternalFormat::SupportCheckFunction filterSupport,InternalFormat::SupportCheckFunction textureAttachmentSupport,InternalFormat::SupportCheckFunction renderbufferSupport,InternalFormat::SupportCheckFunction blendSupport)1038*8975f5c5SAndroid Build Coastguard Worker void AddYUVFormat(InternalFormatInfoMap *map,
1039*8975f5c5SAndroid Build Coastguard Worker                   GLenum internalFormat,
1040*8975f5c5SAndroid Build Coastguard Worker                   bool sized,
1041*8975f5c5SAndroid Build Coastguard Worker                   GLuint cr,
1042*8975f5c5SAndroid Build Coastguard Worker                   GLuint y,
1043*8975f5c5SAndroid Build Coastguard Worker                   GLuint cb,
1044*8975f5c5SAndroid Build Coastguard Worker                   GLuint alpha,
1045*8975f5c5SAndroid Build Coastguard Worker                   GLuint shared,
1046*8975f5c5SAndroid Build Coastguard Worker                   GLenum format,
1047*8975f5c5SAndroid Build Coastguard Worker                   GLenum type,
1048*8975f5c5SAndroid Build Coastguard Worker                   GLenum componentType,
1049*8975f5c5SAndroid Build Coastguard Worker                   bool srgb,
1050*8975f5c5SAndroid Build Coastguard Worker                   InternalFormat::SupportCheckFunction textureSupport,
1051*8975f5c5SAndroid Build Coastguard Worker                   InternalFormat::SupportCheckFunction filterSupport,
1052*8975f5c5SAndroid Build Coastguard Worker                   InternalFormat::SupportCheckFunction textureAttachmentSupport,
1053*8975f5c5SAndroid Build Coastguard Worker                   InternalFormat::SupportCheckFunction renderbufferSupport,
1054*8975f5c5SAndroid Build Coastguard Worker                   InternalFormat::SupportCheckFunction blendSupport)
1055*8975f5c5SAndroid Build Coastguard Worker {
1056*8975f5c5SAndroid Build Coastguard Worker     ASSERT(sized);
1057*8975f5c5SAndroid Build Coastguard Worker 
1058*8975f5c5SAndroid Build Coastguard Worker     InternalFormat formatInfo;
1059*8975f5c5SAndroid Build Coastguard Worker     formatInfo.internalFormat      = internalFormat;
1060*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sized               = sized;
1061*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sizedInternalFormat = internalFormat;
1062*8975f5c5SAndroid Build Coastguard Worker     formatInfo.redBits             = cr;
1063*8975f5c5SAndroid Build Coastguard Worker     formatInfo.greenBits           = y;
1064*8975f5c5SAndroid Build Coastguard Worker     formatInfo.blueBits            = cb;
1065*8975f5c5SAndroid Build Coastguard Worker     formatInfo.alphaBits           = alpha;
1066*8975f5c5SAndroid Build Coastguard Worker     formatInfo.sharedBits          = shared;
1067*8975f5c5SAndroid Build Coastguard Worker     formatInfo.pixelBytes          = (cr + y + cb + alpha + shared) / 8;
1068*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentCount =
1069*8975f5c5SAndroid Build Coastguard Worker         ((cr > 0) ? 1 : 0) + ((y > 0) ? 1 : 0) + ((cb > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
1070*8975f5c5SAndroid Build Coastguard Worker     formatInfo.format                   = format;
1071*8975f5c5SAndroid Build Coastguard Worker     formatInfo.type                     = type;
1072*8975f5c5SAndroid Build Coastguard Worker     formatInfo.componentType            = componentType;
1073*8975f5c5SAndroid Build Coastguard Worker     formatInfo.colorEncoding            = (srgb ? GL_SRGB : GL_LINEAR);
1074*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureSupport           = textureSupport;
1075*8975f5c5SAndroid Build Coastguard Worker     formatInfo.filterSupport            = filterSupport;
1076*8975f5c5SAndroid Build Coastguard Worker     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
1077*8975f5c5SAndroid Build Coastguard Worker     formatInfo.renderbufferSupport      = renderbufferSupport;
1078*8975f5c5SAndroid Build Coastguard Worker     formatInfo.blendSupport             = blendSupport;
1079*8975f5c5SAndroid Build Coastguard Worker 
1080*8975f5c5SAndroid Build Coastguard Worker     InsertFormatInfo(map, formatInfo);
1081*8975f5c5SAndroid Build Coastguard Worker }
1082*8975f5c5SAndroid Build Coastguard Worker 
1083*8975f5c5SAndroid Build Coastguard Worker // Notes:
1084*8975f5c5SAndroid Build Coastguard Worker // 1. "Texture supported" includes all the means by which texture can be created, however,
1085*8975f5c5SAndroid Build Coastguard Worker //    GL_EXT_texture_storage in ES2 is a special case, when only glTexStorage* is allowed.
1086*8975f5c5SAndroid Build Coastguard Worker //    The assumption is that ES2 validation will not check textureSupport for sized formats.
1087*8975f5c5SAndroid Build Coastguard Worker //
1088*8975f5c5SAndroid Build Coastguard Worker // 2. Sized half float types are a combination of GL_HALF_FLOAT and GL_HALF_FLOAT_OES support,
1089*8975f5c5SAndroid Build Coastguard Worker //    due to a limitation that only one type for sized formats is allowed.
1090*8975f5c5SAndroid Build Coastguard Worker //
1091*8975f5c5SAndroid Build Coastguard Worker // TODO(ynovikov): http://anglebug.com/42261549 Verify support fields of BGRA, depth, stencil
1092*8975f5c5SAndroid Build Coastguard Worker // and compressed formats. Perform texturable check as part of filterable and attachment checks.
BuildInternalFormatInfoMap()1093*8975f5c5SAndroid Build Coastguard Worker static InternalFormatInfoMap BuildInternalFormatInfoMap()
1094*8975f5c5SAndroid Build Coastguard Worker {
1095*8975f5c5SAndroid Build Coastguard Worker     InternalFormatInfoMap map;
1096*8975f5c5SAndroid Build Coastguard Worker 
1097*8975f5c5SAndroid Build Coastguard Worker     // From ES 3.0.1 spec, table 3.12
1098*8975f5c5SAndroid Build Coastguard Worker     map[GL_NONE][GL_NONE] = InternalFormat();
1099*8975f5c5SAndroid Build Coastguard Worker 
1100*8975f5c5SAndroid Build Coastguard Worker     // clang-format off
1101*8975f5c5SAndroid Build Coastguard Worker 
1102*8975f5c5SAndroid Build Coastguard Worker     //                 | Internal format     |sized| R | G | B | A |S | Format         | Type                             | Component type        | SRGB | Texture supported                                | Filterable     | Texture attachment                               | Renderbuffer                                   | Blend
1103*8975f5c5SAndroid Build Coastguard Worker     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::textureRgEXT>, RequireESOrExt<3, 0, &Extensions::textureRgEXT>);
1104*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_R8_SNORM,          true,  8,  0,  0,  0, 0, GL_RED,          GL_BYTE,                           GL_SIGNED_NORMALIZED,   false, RequireES<3, 0>,                                      AlwaysSupported, RequireExt<&Extensions::renderSnormEXT>,                 RequireExt<&Extensions::renderSnormEXT>,         RequireExt<&Extensions::renderSnormEXT>);
1105*8975f5c5SAndroid Build Coastguard Worker     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::textureRgEXT>, RequireESOrExt<3, 0, &Extensions::textureRgEXT>);
1106*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RG8_SNORM,         true,  8,  8,  0,  0, 0, GL_RG,           GL_BYTE,                           GL_SIGNED_NORMALIZED,   false, RequireES<3, 0>,                                      AlwaysSupported, RequireExt<&Extensions::renderSnormEXT>,                 RequireExt<&Extensions::renderSnormEXT>,         RequireExt<&Extensions::renderSnormEXT>);
1107*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB8,              true,  8,  8,  8,  0, 0, GL_RGB,          GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, AlwaysSupported, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, RequireESOrExt<3, 0, &Extensions::rgb8Rgba8OES>,    RequireESOrExt<3, 0, &Extensions::rgb8Rgba8OES>);
1108*8975f5c5SAndroid Build Coastguard Worker     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,                                  NeverSupported);
1109*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB565,            true,  5,  6,  5,  0, 0, GL_RGB,          GL_UNSIGNED_SHORT_5_6_5,           GL_UNSIGNED_NORMALIZED, false, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, AlwaysSupported, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>, RequireES<2, 0>);
1110*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA4,             true,  4,  4,  4,  4, 0, GL_RGBA,         GL_UNSIGNED_SHORT_4_4_4_4,         GL_UNSIGNED_NORMALIZED, false, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, AlwaysSupported, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>, RequireES<2, 0>);
1111*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB5_A1,           true,  5,  5,  5,  1, 0, GL_RGBA,         GL_UNSIGNED_SHORT_5_5_5_1,         GL_UNSIGNED_NORMALIZED, false, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, AlwaysSupported, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>, RequireES<2, 0>);
1112*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA8,             true,  8,  8,  8,  8, 0, GL_RGBA,         GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, AlwaysSupported, RequireESOrExtOrExt<3, 0, &Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, RequireESOrExt<3, 0, &Extensions::rgb8Rgba8OES>,    RequireESOrExt<3, 0, &Extensions::rgb8Rgba8OES>);
1113*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA8_SNORM,       true,  8,  8,  8,  8, 0, GL_RGBA,         GL_BYTE,                           GL_SIGNED_NORMALIZED,   false, RequireES<3, 0>,                                      AlwaysSupported, RequireExt<&Extensions::renderSnormEXT>,                 RequireExt<&Extensions::renderSnormEXT>,         RequireExt<&Extensions::renderSnormEXT>);
1114*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1115*8975f5c5SAndroid Build Coastguard Worker     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,                                  NeverSupported);
1116*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_SRGB8_ALPHA8,      true,  8,  8,  8,  8, 0, GL_RGBA,         GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, true,  RequireESOrExt<3, 0, &Extensions::sRGBEXT>,           AlwaysSupported, RequireES<3, 0>,                                         RequireESOrExt<3, 0, &Extensions::sRGBEXT>,      RequireESOrExt<3, 0, &Extensions::sRGBEXT>);
1117*8975f5c5SAndroid Build Coastguard Worker     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::colorBufferFloatEXT>,            RequireExt<&Extensions::colorBufferFloatEXT>,    RequireExt<&Extensions::colorBufferFloatEXT>);
1118*8975f5c5SAndroid Build Coastguard Worker     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, RequireExt<&Extensions::renderSharedExponentQCOM>,    RequireExt<&Extensions::renderSharedExponentQCOM>,  RequireExt<&Extensions::renderSharedExponentQCOM>);
1119*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1120*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1121*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1122*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1123*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1124*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1125*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1126*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1127*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1128*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1129*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1130*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1131*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB8I,             true,  8,  8,  8,  0, 0, GL_RGB_INTEGER,  GL_BYTE,                           GL_INT,                 false, RequireES<3, 0>,                                      NeverSupported,  NeverSupported,                                          NeverSupported,                                  NeverSupported);
1132*8975f5c5SAndroid Build Coastguard Worker     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,                                  NeverSupported);
1133*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB16I,            true, 16, 16, 16,  0, 0, GL_RGB_INTEGER,  GL_SHORT,                          GL_INT,                 false, RequireES<3, 0>,                                      NeverSupported,  NeverSupported,                                          NeverSupported,                                  NeverSupported);
1134*8975f5c5SAndroid Build Coastguard Worker     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,                                  NeverSupported);
1135*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB32I,            true, 32, 32, 32,  0, 0, GL_RGB_INTEGER,  GL_INT,                            GL_INT,                 false, RequireES<3, 0>,                                      NeverSupported,  NeverSupported,                                          NeverSupported,                                  NeverSupported);
1136*8975f5c5SAndroid Build Coastguard Worker     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,                                  NeverSupported);
1137*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1138*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1139*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1140*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1141*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1142*8975f5c5SAndroid Build Coastguard Worker     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>,                                 NeverSupported);
1143*8975f5c5SAndroid Build Coastguard Worker 
1144*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_BGRA8_EXT,         true,  8,  8,  8,  8, 0, GL_BGRA_EXT,     GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888EXT>,    AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>,    RequireExt<&Extensions::textureFormatBGRA8888EXT>, RequireExt<&Extensions::textureFormatBGRA8888EXT>);
1145*8975f5c5SAndroid Build Coastguard Worker     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::textureFormatBGRA8888EXT>,    AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>,    RequireExt<&Extensions::textureFormatBGRA8888EXT>, RequireExt<&Extensions::textureFormatBGRA8888EXT>);
1146*8975f5c5SAndroid Build Coastguard Worker     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::textureFormatBGRA8888EXT>,    AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>,    RequireExt<&Extensions::textureFormatBGRA8888EXT>, RequireExt<&Extensions::textureFormatBGRA8888EXT>);
1147*8975f5c5SAndroid Build Coastguard Worker 
1148*8975f5c5SAndroid Build Coastguard Worker     // Special format that is used for D3D textures that are used within ANGLE via the
1149*8975f5c5SAndroid Build Coastguard Worker     // EGL_ANGLE_d3d_texture_client_buffer extension. We don't allow uploading texture images with
1150*8975f5c5SAndroid Build Coastguard Worker     // this format, but textures in this format can be created from D3D textures, and filtering them
1151*8975f5c5SAndroid Build Coastguard Worker     // and rendering to them is allowed.
1152*8975f5c5SAndroid Build Coastguard Worker     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,                               AlwaysSupported);
1153*8975f5c5SAndroid Build Coastguard Worker 
1154*8975f5c5SAndroid Build Coastguard Worker     // Special format which is not really supported, so always false for all supports.
1155*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_BGR565_ANGLEX,     true,  5,  6,  5,  0, 0, GL_BGRA_EXT,     GL_UNSIGNED_SHORT_5_6_5,           GL_UNSIGNED_NORMALIZED, false, NeverSupported,                                    NeverSupported,  NeverSupported,                                    NeverSupported,                                NeverSupported);
1156*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_BGR10_A2_ANGLEX,   true, 10, 10, 10,  2, 0, GL_BGRA_EXT,     GL_UNSIGNED_INT_2_10_10_10_REV,    GL_UNSIGNED_NORMALIZED, false, NeverSupported,                                    NeverSupported,  NeverSupported,                                    NeverSupported,                                NeverSupported);
1157*8975f5c5SAndroid Build Coastguard Worker 
1158*8975f5c5SAndroid Build Coastguard Worker     // Special format to emulate RGB8 with RGBA8 within ANGLE.
1159*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGBX8_ANGLE,      true,   FB< 8,  8,  8,  0, 8, 0>(), GL_RGB,          GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                   AlwaysSupported, AlwaysSupported,                                   AlwaysSupported,                               NeverSupported);
1160*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGBX8_SRGB_ANGLEX,      true,   FB< 8,  8,  8,  0, 8, 0>(), GL_RGB,          GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, true, AlwaysSupported,                                   AlwaysSupported, AlwaysSupported,                                   AlwaysSupported,                               NeverSupported);
1161*8975f5c5SAndroid Build Coastguard Worker 
1162*8975f5c5SAndroid Build Coastguard Worker     // Special format to emulate BGR8 with BGRA8 within ANGLE.
1163*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_BGRX8_ANGLEX,      true,  FB< 8,  8,  8,  0, 8, 0>(), GL_BGRA_EXT,     GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, NeverSupported,                                    AlwaysSupported,  NeverSupported,                                    NeverSupported,                                NeverSupported);
1164*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_BGRX8_SRGB_ANGLEX,      true,  FB< 8,  8,  8,  0, 8, 0>(), GL_BGRA_EXT,     GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, true, NeverSupported,                                    AlwaysSupported,  NeverSupported,                                    NeverSupported,                                NeverSupported);
1165*8975f5c5SAndroid Build Coastguard Worker 
1166*8975f5c5SAndroid Build Coastguard Worker     // This format is supported on ES 2.0 with two extensions, so keep it out-of-line to not widen the table above even more.
1167*8975f5c5SAndroid Build Coastguard Worker     //                 | Internal format     |sized| R | G | B | A |S | Format         | Type                             | Component type        | SRGB | Texture supported                                                                            | Filterable     | Texture attachment                               | Renderbuffer                                   | Blend
1168*8975f5c5SAndroid Build Coastguard Worker     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, RequireESOrExtAndExt<3, 0, &Extensions::textureStorageEXT, &Extensions::textureType2101010REVEXT>,  AlwaysSupported, RequireES<3, 0>,                                   RequireES<3, 0>,                                 RequireES<3, 0>);
1169*8975f5c5SAndroid Build Coastguard Worker 
1170*8975f5c5SAndroid Build Coastguard Worker     // Floating point formats
1171*8975f5c5SAndroid Build Coastguard Worker     //                 | Internal format |sized| R | G | B | A |S | Format | Type             | Component type | SRGB | Texture supported         | Filterable                                    | Texture attachment                          | Renderbuffer                            | Blend
1172*8975f5c5SAndroid Build Coastguard Worker     // It's not possible to have two entries per sized format.
1173*8975f5c5SAndroid Build Coastguard Worker     // E.g. for GL_RG16F, one with GL_HALF_FLOAT type and the other with GL_HALF_FLOAT_OES type.
1174*8975f5c5SAndroid Build Coastguard Worker     // So, GL_HALF_FLOAT type formats conditions are merged with GL_HALF_FLOAT_OES type conditions.
1175*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_R16F,          true, 16,  0,  0,  0, 0, GL_RED,  GL_HALF_FLOAT,     GL_FLOAT,        false, SizedHalfFloatRGSupport,    SizedHalfFloatFilterSupport,                    SizedHalfFloatRGTextureAttachmentSupport,     SizedHalfFloatRGRenderbufferSupport,       SizedHalfFloatRGRenderbufferSupport);
1176*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RG16F,         true, 16, 16,  0,  0, 0, GL_RG,   GL_HALF_FLOAT,     GL_FLOAT,        false, SizedHalfFloatRGSupport,    SizedHalfFloatFilterSupport,                    SizedHalfFloatRGTextureAttachmentSupport,     SizedHalfFloatRGRenderbufferSupport,       SizedHalfFloatRGRenderbufferSupport);
1177*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB16F,        true, 16, 16, 16,  0, 0, GL_RGB,  GL_HALF_FLOAT,     GL_FLOAT,        false, SizedHalfFloatSupport,      SizedHalfFloatFilterSupport,                    SizedHalfFloatRGBTextureAttachmentSupport,    SizedHalfFloatRGBRenderbufferSupport,      SizedHalfFloatRGBRenderbufferSupport);
1178*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA16F,       true, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT,     GL_FLOAT,        false, SizedHalfFloatSupport,      SizedHalfFloatFilterSupport,                    SizedHalfFloatRGBATextureAttachmentSupport,   SizedHalfFloatRGBARenderbufferSupport,     SizedHalfFloatRGBARenderbufferSupport);
1179*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_R32F,          true, 32,  0,  0,  0, 0, GL_RED,  GL_FLOAT,          GL_FLOAT,        false, SizedFloatRGSupport,        RequireExt<&Extensions::textureFloatLinearOES>, RequireExt<&Extensions::colorBufferFloatEXT>,    RequireExt<&Extensions::colorBufferFloatEXT>, Float32BlendableSupport);
1180*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RG32F,         true, 32, 32,  0,  0, 0, GL_RG,   GL_FLOAT,          GL_FLOAT,        false, SizedFloatRGSupport,        RequireExt<&Extensions::textureFloatLinearOES>, RequireExt<&Extensions::colorBufferFloatEXT>,    RequireExt<&Extensions::colorBufferFloatEXT>, Float32BlendableSupport);
1181*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB32F,        true, 32, 32, 32,  0, 0, GL_RGB,  GL_FLOAT,          GL_FLOAT,        false, SizedFloatRGBSupport,       RequireExt<&Extensions::textureFloatLinearOES>, RequireExt<&Extensions::colorBufferFloatRgbCHROMIUM>, NeverSupported,                            NeverSupported);
1182*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA32F,       true, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT,          GL_FLOAT,        false, SizedFloatRGBASupport,      RequireExt<&Extensions::textureFloatLinearOES>, SizedFloatRGBARenderableSupport,              SizedFloatRGBARenderableSupport,           Float32BlendableSupport);
1183*8975f5c5SAndroid Build Coastguard Worker 
1184*8975f5c5SAndroid Build Coastguard Worker     // ANGLE Depth stencil formats
1185*8975f5c5SAndroid Build Coastguard Worker     //                         | Internal format         |sized| D |S | X | Format            | Type                             | Component type        | Texture supported                                                                            | Filterable                                                                             | Texture attachment                                                                           | Renderbuffer                                                                                              | Blend
1186*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT16,     true, 16, 0,  0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT,                 GL_UNSIGNED_NORMALIZED, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::depthTextureOES>,       RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::depthTextureOES>, RequireES<1, 0>,                                                                               RequireES<1, 0>,                                                                                             NeverSupported);
1187*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT24,     true, 24, 0,  8, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,                   GL_UNSIGNED_NORMALIZED, RequireES<3, 0>,                                                                               RequireESOrExt<3, 0, &Extensions::depthTextureANGLE>,                                    RequireES<3, 0>,                                                                               RequireESOrExt<3, 0, &Extensions::depth24OES>,                                                               NeverSupported);
1188*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32F,    true, 32, 0,  0, GL_DEPTH_COMPONENT, GL_FLOAT,                          GL_FLOAT,               RequireES<3, 0>,                                                                               RequireESOrExt<3, 0, &Extensions::depthTextureANGLE>,                                    RequireES<3, 0>,                                                                               RequireES<3, 0>,                                                                                             NeverSupported);
1189*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32_OES, true, 32, 0,  0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,                   GL_UNSIGNED_NORMALIZED, RequireExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES>,                 AlwaysSupported,                                                                         RequireExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES>,                 RequireExtOrExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES, &Extensions::depth32OES>, NeverSupported);
1190*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH24_STENCIL8,      true, 24, 8,  0, GL_DEPTH_STENCIL,   GL_UNSIGNED_INT_24_8,              GL_UNSIGNED_NORMALIZED, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencilOES>, AlwaysSupported,                                                                         RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencilOES>, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencilOES>,               NeverSupported);
1191*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH32F_STENCIL8,     true, 32, 8, 24, GL_DEPTH_STENCIL,   GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT,               RequireESOrExt<3, 0, &Extensions::depthBufferFloat2NV>,                                        AlwaysSupported,                                                                         RequireESOrExt<3, 0, &Extensions::depthBufferFloat2NV>,                                        RequireESOrExt<3, 0, &Extensions::depthBufferFloat2NV>,                                                      NeverSupported);
1192*8975f5c5SAndroid Build Coastguard Worker     // STENCIL_INDEX8 is special-cased, see around the bottom of the list.
1193*8975f5c5SAndroid Build Coastguard Worker 
1194*8975f5c5SAndroid Build Coastguard Worker     // Luminance alpha formats
1195*8975f5c5SAndroid Build Coastguard Worker     //                | Internal format           |sized| L | A | Format            | Type             | Component type        | Texture supported                                                           | Filterable                                     | Texture attachment | Renderbuffer | Blend
1196*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_ALPHA8_EXT,             true,  0,  8, GL_ALPHA,           GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, RequireExtOrExt<&Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, AlwaysSupported,                         NeverSupported,      NeverSupported, NeverSupported);
1197*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE8_EXT,         true,  8,  0, GL_LUMINANCE,       GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, RequireExtOrExt<&Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, AlwaysSupported,                         NeverSupported,      NeverSupported, NeverSupported);
1198*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE4_ALPHA4_OES,  true,  8,  8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::requiredInternalformatOES>,                              AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1199*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE8_ALPHA8_EXT,  true,  8,  8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, RequireExtOrExt<&Extensions::textureStorageEXT, &Extensions::requiredInternalformatOES>, AlwaysSupported,                         NeverSupported,      NeverSupported, NeverSupported);
1200*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_ALPHA16F_EXT,           true,  0, 16, GL_ALPHA,           GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1201*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE16F_EXT,       true, 16,  0, GL_LUMINANCE,       GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1202*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA16F_EXT, true, 16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1203*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_ALPHA32F_EXT,           true,  0, 32, GL_ALPHA,           GL_FLOAT,          GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1204*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE32F_EXT,       true, 32,  0, GL_LUMINANCE,       GL_FLOAT,          GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1205*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA32F_EXT, true, 32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT,          GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1206*8975f5c5SAndroid Build Coastguard Worker 
1207*8975f5c5SAndroid Build Coastguard Worker     // Compressed formats, From ES 3.0.1 spec, table 3.16
1208*8975f5c5SAndroid Build Coastguard Worker     //                       | Internal format                             |W |H |D | BS |CC| SRGB | Texture supported                                                          | Filterable     | Texture attachment | Renderbuffer  | Blend
1209*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_R11_EAC,                        4, 4, 1,  64, 1, false, ETC2EACSupport<&Extensions::compressedEACR11UnsignedTextureOES>,              AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1210*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_R11_EAC,                 4, 4, 1,  64, 1, false, ETC2EACSupport<&Extensions::compressedEACR11SignedTextureOES>,                AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1211*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RG11_EAC,                       4, 4, 1, 128, 2, false, ETC2EACSupport<&Extensions::compressedEACRG11UnsignedTextureOES>,             AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1212*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_RG11_EAC,                4, 4, 1, 128, 2, false, ETC2EACSupport<&Extensions::compressedEACRG11SignedTextureOES>,               AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1213*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGB8_ETC2,                      4, 4, 1,  64, 3, false, ETC2EACSupport<&Extensions::compressedETC2RGB8TextureOES>,                    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1214*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ETC2,                     4, 4, 1,  64, 3, true,  ETC2EACSupport<&Extensions::compressedETC2SRGB8TextureOES>,                   AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1215*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,  4, 4, 1,  64, 4, false, ETC2EACSupport<&Extensions::compressedETC2PunchthroughARGBA8TextureOES>,      AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1216*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 4, 1,  64, 4, true,  ETC2EACSupport<&Extensions::compressedETC2PunchthroughASRGB8AlphaTextureOES>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1217*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA8_ETC2_EAC,                 4, 4, 1, 128, 4, false, ETC2EACSupport<&Extensions::compressedETC2RGBA8TextureOES>,                   AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1218*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,          4, 4, 1, 128, 4, true,  ETC2EACSupport<&Extensions::compressedETC2SRGB8Alpha8TextureOES>,             AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1219*8975f5c5SAndroid Build Coastguard Worker 
1220*8975f5c5SAndroid Build Coastguard Worker     // From GL_EXT_texture_compression_dxt1
1221*8975f5c5SAndroid Build Coastguard Worker     //                       | Internal format                   |W |H |D | BS |CC| SRGB | Texture supported                                    | Filterable     | Texture attachment | Renderbuffer  | Blend
1222*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,    4, 4, 1,  64, 3, false, RequireExt<&Extensions::textureCompressionDxt1EXT>,       AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1223*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,   4, 4, 1,  64, 4, false, RequireExt<&Extensions::textureCompressionDxt1EXT>,       AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1224*8975f5c5SAndroid Build Coastguard Worker 
1225*8975f5c5SAndroid Build Coastguard Worker     // From GL_ANGLE_texture_compression_dxt3
1226*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, 4, 4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionDxt3ANGLE>,       AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1227*8975f5c5SAndroid Build Coastguard Worker 
1228*8975f5c5SAndroid Build Coastguard Worker     // From GL_ANGLE_texture_compression_dxt5
1229*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, 4, 4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionDxt5ANGLE>,       AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1230*8975f5c5SAndroid Build Coastguard Worker 
1231*8975f5c5SAndroid Build Coastguard Worker     // From GL_OES_compressed_ETC1_RGB8_texture
1232*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_ETC1_RGB8_OES,                   4, 4, 1,  64, 3, false, RequireExt<&Extensions::compressedETC1RGB8TextureOES>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1233*8975f5c5SAndroid Build Coastguard Worker 
1234*8975f5c5SAndroid Build Coastguard Worker     // From GL_EXT_texture_compression_s3tc_srgb
1235*8975f5c5SAndroid Build Coastguard Worker     //                       | Internal format                       |W |H |D | BS |CC|SRGB | Texture supported                                 | Filterable     | Texture attachment | Renderbuffer  | Blend
1236*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,       4, 4, 1,  64, 3, true, RequireExt<&Extensions::textureCompressionS3tcSrgbEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1237*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 4, 4, 1,  64, 4, true, RequireExt<&Extensions::textureCompressionS3tcSrgbEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1238*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 4, 4, 1, 128, 4, true, RequireExt<&Extensions::textureCompressionS3tcSrgbEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1239*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 4, 4, 1, 128, 4, true, RequireExt<&Extensions::textureCompressionS3tcSrgbEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1240*8975f5c5SAndroid Build Coastguard Worker 
1241*8975f5c5SAndroid Build Coastguard Worker     // From GL_KHR_texture_compression_astc_ldr and KHR_texture_compression_astc_hdr and GL_OES_texture_compression_astc
1242*8975f5c5SAndroid Build Coastguard Worker     //                       | Internal format                          | W | H |D | BS |CC| SRGB | Texture supported                                    | Filterable     | Texture attachment | Renderbuffer  | Blend
1243*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x4_KHR,            4,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1244*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x4_KHR,            5,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1245*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x5_KHR,            5,  5, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1246*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x5_KHR,            6,  5, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1247*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x6_KHR,            6,  6, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1248*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x5_KHR,            8,  5, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1249*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x6_KHR,            8,  6, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1250*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x8_KHR,            8,  8, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1251*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x5_KHR,          10,  5, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1252*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x6_KHR,          10,  6, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1253*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x8_KHR,          10,  8, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1254*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x10_KHR,         10, 10, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1255*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_12x10_KHR,         12, 10, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1256*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_12x12_KHR,         12, 12, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1257*8975f5c5SAndroid Build Coastguard Worker 
1258*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,    4,  4, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1259*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,    5,  4, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1260*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,    5,  5, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1261*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,    6,  5, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1262*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,    6,  6, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1263*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,    8,  5, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1264*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,    8,  6, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1265*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,    8,  8, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1266*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,  10,  5, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1267*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,  10,  6, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1268*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,  10,  8, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1269*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 10, 10, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1270*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 12, 10, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1271*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 12, 12, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1272*8975f5c5SAndroid Build Coastguard Worker 
1273*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_3x3x3_OES,          3,  3, 3, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1274*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x3x3_OES,          4,  3, 3, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1275*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x4x3_OES,          4,  4, 3, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1276*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x4x4_OES,          4,  4, 4, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1277*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x4x4_OES,          5,  4, 4, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1278*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x5x4_OES,          5,  5, 4, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1279*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x5x5_OES,          5,  5, 5, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1280*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x5x5_OES,          6,  5, 5, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1281*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x6x5_OES,          6,  6, 5, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1282*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x6x6_OES,          6,  6, 6, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1283*8975f5c5SAndroid Build Coastguard Worker 
1284*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES,  3,  3, 3, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1285*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES,  4,  3, 3, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1286*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES,  4,  4, 3, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1287*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES,  4,  4, 4, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1288*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES,  5,  4, 4, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1289*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES,  5,  5, 4, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1290*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES,  5,  5, 5, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1291*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES,  6,  5, 5, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1292*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES,  6,  6, 5, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1293*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES,  6,  6, 6, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1294*8975f5c5SAndroid Build Coastguard Worker 
1295*8975f5c5SAndroid Build Coastguard Worker     // From EXT_texture_compression_rgtc
1296*8975f5c5SAndroid Build Coastguard Worker     //                       | Internal format                        | W | H |D | BS |CC| SRGB | Texture supported                              | Filterable     | Texture attachment | Renderbuffer  | Blend
1297*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RED_RGTC1_EXT,              4,  4, 1,  64, 1, false, RequireExt<&Extensions::textureCompressionRgtcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1298*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,       4,  4, 1,  64, 1, false, RequireExt<&Extensions::textureCompressionRgtcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1299*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RED_GREEN_RGTC2_EXT,        4,  4, 1, 128, 2, false, RequireExt<&Extensions::textureCompressionRgtcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1300*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, 4,  4, 1, 128, 2, false, RequireExt<&Extensions::textureCompressionRgtcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1301*8975f5c5SAndroid Build Coastguard Worker 
1302*8975f5c5SAndroid Build Coastguard Worker     // From EXT_texture_compression_bptc
1303*8975f5c5SAndroid Build Coastguard Worker     //                       | Internal format                         | W | H |D | BS |CC| SRGB | Texture supported                              | Filterable     | Texture attachment | Renderbuffer  | Blend
1304*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,         4,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionBptcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1305*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,   4,  4, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionBptcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1306*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,   4,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionBptcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1307*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, 4,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionBptcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1308*8975f5c5SAndroid Build Coastguard Worker 
1309*8975f5c5SAndroid Build Coastguard Worker     // Paletted formats
1310*8975f5c5SAndroid Build Coastguard Worker     //                      | Internal format       |    | PS | Format | CC | Texture supported | Filterable     | Texture attachment | Renderbuffer  | Blend
1311*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE4_RGB8_OES,      4,   3, GL_RGB,    3, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1312*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE4_RGBA8_OES,     4,   4, GL_RGBA,   4, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1313*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE4_R5_G6_B5_OES,  4,   2, GL_RGB,    3, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1314*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE4_RGBA4_OES,     4,   2, GL_RGBA,   4, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1315*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE4_RGB5_A1_OES,   4,   2, GL_RGBA,   4, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1316*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE8_RGB8_OES,      8,   3, GL_RGB,    3, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1317*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE8_RGBA8_OES,     8,   4, GL_RGBA,   4, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1318*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE8_R5_G6_B5_OES,  8,   2, GL_RGB,    3, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1319*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE8_RGBA4_OES,     8,   2, GL_RGBA,   4, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1320*8975f5c5SAndroid Build Coastguard Worker     AddPalettedFormat(&map, GL_PALETTE8_RGB5_A1_OES,   8,   2, GL_RGBA,   4, RequireES1,         AlwaysSupported, NeverSupported,     NeverSupported, NeverSupported);
1321*8975f5c5SAndroid Build Coastguard Worker 
1322*8975f5c5SAndroid Build Coastguard Worker     // From GL_IMG_texture_compression_pvrtc
1323*8975f5c5SAndroid Build Coastguard Worker     //                       | Internal format                       | W | H | D | BS |CC| SRGB | Texture supported                                 | Filterable     | Texture attachment | Renderbuffer  | Blend
1324*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,      4,  4,  1,  64,  3, false, RequireExt<&Extensions::textureCompressionPvrtcIMG>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1325*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,      8,  4,  1,  64,  3, false, RequireExt<&Extensions::textureCompressionPvrtcIMG>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1326*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,     4,  4,  1,  64,  4, false, RequireExt<&Extensions::textureCompressionPvrtcIMG>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1327*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,     8,  4,  1,  64,  4, false, RequireExt<&Extensions::textureCompressionPvrtcIMG>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1328*8975f5c5SAndroid Build Coastguard Worker 
1329*8975f5c5SAndroid Build Coastguard Worker     // From GL_EXT_pvrtc_sRGB
1330*8975f5c5SAndroid Build Coastguard Worker     //                       | Internal format                             | W | H | D | BS |CC| SRGB | Texture supported                                                                               | Filterable     | Texture attachment | Renderbuffer  | Blend
1331*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT,           8,  4,  1,  64,  3, true, RequireExtAndExt<&Extensions::textureCompressionPvrtcIMG, &Extensions::pvrtcSRGBEXT>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1332*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT,           4,  4,  1,  64,  3, true, RequireExtAndExt<&Extensions::textureCompressionPvrtcIMG, &Extensions::pvrtcSRGBEXT>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1333*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT,     8,  4,  1,  64,  4, true, RequireExtAndExt<&Extensions::textureCompressionPvrtcIMG, &Extensions::pvrtcSRGBEXT>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1334*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT,     4,  4,  1,  64,  4, true, RequireExtAndExt<&Extensions::textureCompressionPvrtcIMG, &Extensions::pvrtcSRGBEXT>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1335*8975f5c5SAndroid Build Coastguard Worker 
1336*8975f5c5SAndroid Build Coastguard Worker     // For STENCIL_INDEX8 we chose a normalized component type for the following reasons:
1337*8975f5c5SAndroid Build Coastguard Worker     // - Multisampled buffer are disallowed for non-normalized integer component types and we want to support it for STENCIL_INDEX8
1338*8975f5c5SAndroid Build Coastguard Worker     // - All other stencil formats (all depth-stencil) are either float or normalized
1339*8975f5c5SAndroid Build Coastguard Worker     // - It affects only validation of internalformat in RenderbufferStorageMultisample.
1340*8975f5c5SAndroid Build Coastguard Worker     //                         | Internal format  |sized|D |S |X | Format          | Type            | Component type        | Texture supported                                    | Filterable    | Texture attachment                                   | Renderbuffer   | Blend
1341*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_STENCIL_INDEX8, true, 0, 8, 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 2, &Extensions::textureStencil8OES>, NeverSupported, RequireESOrExt<3, 2, &Extensions::textureStencil8OES>, RequireES<1, 0>, NeverSupported);
1342*8975f5c5SAndroid Build Coastguard Worker 
1343*8975f5c5SAndroid Build Coastguard Worker     // From GL_ANGLE_lossy_etc_decode
1344*8975f5c5SAndroid Build Coastguard Worker     //                       | Internal format                                                |W |H |D |BS |CC| SRGB | Texture supported                      | Filterable     | Texture attachment | Renderbuffer  | Blend
1345*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_ETC1_RGB8_LOSSY_DECODE_ANGLE,                                 4, 4, 1, 64, 3, false, RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1346*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE,                      4, 4, 1, 64, 3, false, RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1347*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE,                     4, 4, 1, 64, 3, true,  RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1348*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE,  4, 4, 1, 64, 3, false, RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1349*8975f5c5SAndroid Build Coastguard Worker     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 1, 64, 3, true,  RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1350*8975f5c5SAndroid Build Coastguard Worker 
1351*8975f5c5SAndroid Build Coastguard Worker     // From GL_EXT_texture_norm16
1352*8975f5c5SAndroid Build Coastguard Worker     //                 | Internal format    |sized| R | G | B | A |S | Format | Type             | Component type        | SRGB | Texture supported                        | Filterable     | Texture attachment                                                          | Renderbuffer                                                                | Blend
1353*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_R16_EXT,          true, 16,  0,  0,  0, 0, GL_RED,  GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,                                    RequireExt<&Extensions::textureNorm16EXT>,                                    RequireExt<&Extensions::textureNorm16EXT>);
1354*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_R16_SNORM_EXT,    true, 16,  0,  0,  0, 0, GL_RED,  GL_SHORT,          GL_SIGNED_NORMALIZED,   false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, RequireExtAndExt<&Extensions::textureNorm16EXT, &Extensions::renderSnormEXT>, RequireExtAndExt<&Extensions::textureNorm16EXT, &Extensions::renderSnormEXT>, RequireExtAndExt<&Extensions::textureNorm16EXT, &Extensions::renderSnormEXT>);
1355*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RG16_EXT,         true, 16, 16,  0,  0, 0, GL_RG,   GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,                                    RequireExt<&Extensions::textureNorm16EXT>,                                    RequireExt<&Extensions::textureNorm16EXT>);
1356*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RG16_SNORM_EXT,   true, 16, 16,  0,  0, 0, GL_RG,   GL_SHORT,          GL_SIGNED_NORMALIZED,   false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, RequireExtAndExt<&Extensions::textureNorm16EXT, &Extensions::renderSnormEXT>, RequireExtAndExt<&Extensions::textureNorm16EXT, &Extensions::renderSnormEXT>, RequireExtAndExt<&Extensions::textureNorm16EXT, &Extensions::renderSnormEXT>);
1357*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB16_EXT,        true, 16, 16, 16,  0, 0, GL_RGB,  GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, NeverSupported,                                                               NeverSupported,                                                               NeverSupported);
1358*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB16_SNORM_EXT,  true, 16, 16, 16,  0, 0, GL_RGB,  GL_SHORT,          GL_SIGNED_NORMALIZED,   false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, NeverSupported,                                                               NeverSupported,                                                               NeverSupported);
1359*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA16_EXT,       true, 16, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,                                    RequireExt<&Extensions::textureNorm16EXT>,                                    RequireExt<&Extensions::textureNorm16EXT>);
1360*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA16_SNORM_EXT, true, 16, 16, 16, 16, 0, GL_RGBA, GL_SHORT,          GL_SIGNED_NORMALIZED,   false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, RequireExtAndExt<&Extensions::textureNorm16EXT, &Extensions::renderSnormEXT>, RequireExtAndExt<&Extensions::textureNorm16EXT, &Extensions::renderSnormEXT>, RequireExtAndExt<&Extensions::textureNorm16EXT, &Extensions::renderSnormEXT>);
1361*8975f5c5SAndroid Build Coastguard Worker 
1362*8975f5c5SAndroid Build Coastguard Worker     // From EXT_texture_sRGB_R8
1363*8975f5c5SAndroid Build Coastguard Worker     //                 | Internal format    |sized| R | G | B | A |S | Format | Type             | Component type        | SRGB | Texture supported                     | Filterable     | Texture attachment                    | Renderbuffer                          | Blend
1364*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_SR8_EXT,          true,  8,  0,  0,  0, 0, GL_RED,  GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::textureSRGBR8EXT>,     AlwaysSupported, NeverSupported,                         NeverSupported,                         NeverSupported);
1365*8975f5c5SAndroid Build Coastguard Worker 
1366*8975f5c5SAndroid Build Coastguard Worker     // From EXT_texture_sRGB_RG8
1367*8975f5c5SAndroid Build Coastguard Worker     //                 | Internal format    |sized| R | G | B | A |S | Format | Type             | Component type        | SRGB | Texture supported                     | Filterable     | Texture attachment                    | Renderbuffer                          | Blend
1368*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_SRG8_EXT,         true,  8,  8,  0,  0, 0, GL_RG,   GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::textureSRGBRG8EXT>,    AlwaysSupported, NeverSupported,                         NeverSupported,                         NeverSupported);
1369*8975f5c5SAndroid Build Coastguard Worker 
1370*8975f5c5SAndroid Build Coastguard Worker     // From GL_OES_required_internalformat
1371*8975f5c5SAndroid Build Coastguard Worker     // The |shared| bit shouldn't be 2. But given this hits assertion when bits
1372*8975f5c5SAndroid Build Coastguard Worker     // are checked, it's fine to have this bit set as 2 as a workaround.
1373*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB10_EXT,           true,   10, 10, 10, 0, 2,         GL_RGB,            GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireExtAndExt<&Extensions::textureType2101010REVEXT,&Extensions::requiredInternalformatOES>, NeverSupported,  NeverSupported, NeverSupported, NeverSupported);
1374*8975f5c5SAndroid Build Coastguard Worker 
1375*8975f5c5SAndroid Build Coastguard Worker     // Unsized formats
1376*8975f5c5SAndroid Build Coastguard Worker     //                  | Internal format  |sized |    R | G | B | A |S |X   | Format           | Type                          | Component type        | SRGB | Texture supported                                  | Filterable     | Texture attachment                               | Renderbuffer  | Blend
1377*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RED,            false, FB< 8,  0,  0,  0, 0, 0>(), GL_RED,            GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRgEXT>,               AlwaysSupported, RequireExt<&Extensions::textureRgEXT>,             NeverSupported, NeverSupported);
1378*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RED,            false, FB< 8,  0,  0,  0, 0, 0>(), GL_RED,            GL_BYTE,                        GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      NeverSupported,  NeverSupported,                                    NeverSupported, NeverSupported);
1379*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RED,            false, FB<16,  0,  0,  0, 0, 0>(), GL_RED,            GL_UNSIGNED_SHORT,              GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>,           AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,         NeverSupported, NeverSupported);
1380*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RED,            false, FB<16,  0,  0,  0, 0, 0>(), GL_RED,            GL_SHORT,                       GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1381*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RG,             false, FB< 8,  8,  0,  0, 0, 0>(), GL_RG,             GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRgEXT>,               AlwaysSupported, RequireExt<&Extensions::textureRgEXT>,             NeverSupported, NeverSupported);
1382*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RG,             false, FB< 8,  8,  0,  0, 0, 0>(), GL_RG,             GL_BYTE,                        GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      NeverSupported,  NeverSupported,                                    NeverSupported, NeverSupported);
1383*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RG,             false, FB<16, 16,  0,  0, 0, 0>(), GL_RG,             GL_UNSIGNED_SHORT,              GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>,           AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,         NeverSupported, NeverSupported);
1384*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RG,             false, FB<16, 16,  0,  0, 0, 0>(), GL_RG,             GL_SHORT,                       GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1385*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGB,            false, FB< 8,  8,  8,  0, 0, 0>(), GL_RGB,            GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1386*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGB,            false, FB< 5,  6,  5,  0, 0, 0>(), GL_RGB,            GL_UNSIGNED_SHORT_5_6_5,        GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1387*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGB,            false, FB< 8,  8,  8,  0, 0, 0>(), GL_RGB,            GL_BYTE,                        GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      NeverSupported,  NeverSupported,                                    NeverSupported, NeverSupported);
1388*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGB,            false, FB<10, 10, 10,  0, 0, 2>(), GL_RGB,            GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureType2101010REVEXT>, AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1389*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGB,            false, FB<16, 16, 16,  0, 0, 0>(), GL_RGB,            GL_UNSIGNED_SHORT,              GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>,           AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,         NeverSupported, NeverSupported);
1390*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGB,            false, FB<16, 16, 16,  0, 0, 0>(), GL_RGB,            GL_SHORT,                       GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1391*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGBA,           false, FB< 4,  4,  4,  4, 0, 0>(), GL_RGBA,           GL_UNSIGNED_SHORT_4_4_4_4,      GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1392*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGBA,           false, FB< 5,  5,  5,  1, 0, 0>(), GL_RGBA,           GL_UNSIGNED_SHORT_5_5_5_1,      GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1393*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGBA,           false, FB< 8,  8,  8,  8, 0, 0>(), GL_RGBA,           GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1394*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGBA,           false, FB<16, 16, 16, 16, 0, 0>(), GL_RGBA,           GL_UNSIGNED_SHORT,              GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>,           AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,         NeverSupported, NeverSupported);
1395*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGBA,           false, FB<16, 16, 16, 16, 0, 0>(), GL_RGBA,           GL_SHORT,                       GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1396*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGBA,           false, FB<10, 10, 10,  2, 0, 0>(), GL_RGBA,           GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureType2101010REVEXT>, AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1397*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_RGBA,           false, FB< 8,  8,  8,  8, 0, 0>(), GL_RGBA,           GL_BYTE,                        GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      NeverSupported,  NeverSupported,                                    NeverSupported, NeverSupported);
1398*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_SRGB,           false, FB< 8,  8,  8,  0, 0, 0>(), GL_SRGB,           GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::sRGBEXT>,                    AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1399*8975f5c5SAndroid Build Coastguard Worker     AddRGBAXFormat(&map, GL_SRGB_ALPHA_EXT, false, FB< 8,  8,  8,  8, 0, 0>(), GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::sRGBEXT>,                    AlwaysSupported, RequireExt<&Extensions::sRGBEXT>,                  NeverSupported, NeverSupported);
1400*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_BGRA_EXT,       false,  8,  8,  8,  8, 0, GL_BGRA_EXT,       GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888EXT>,   AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>, NeverSupported, NeverSupported);
1401*8975f5c5SAndroid Build Coastguard Worker 
1402*8975f5c5SAndroid Build Coastguard Worker     // Unsized integer formats
1403*8975f5c5SAndroid Build Coastguard Worker     //                 |Internal format |sized | R | G | B | A |S | Format         | Type                          | Component type | SRGB | Texture supported | Filterable    | Texture attachment | Renderbuffer  | Blend
1404*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1405*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1406*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1407*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1408*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1409*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1410*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1411*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1412*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1413*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1414*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1415*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1416*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1417*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1418*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1419*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1420*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1421*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1422*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1423*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1424*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1425*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1426*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1427*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1428*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1429*8975f5c5SAndroid Build Coastguard Worker 
1430*8975f5c5SAndroid Build Coastguard Worker     // Unsized floating point formats
1431*8975f5c5SAndroid Build Coastguard Worker     //                 |Internal format |sized | R | G | B | A |S | Format | Type                           | Comp    | SRGB | Texture supported                                                         | Filterable                                     | Texture attachment                             | Renderbuffer  | Blend
1432*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RED,          false, 16,  0,  0,  0, 0, GL_RED,  GL_HALF_FLOAT,                   GL_FLOAT, false, NeverSupported,                                                             NeverSupported,                                  NeverSupported,                                  NeverSupported, NeverSupported);
1433*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RG,           false, 16, 16,  0,  0, 0, GL_RG,   GL_HALF_FLOAT,                   GL_FLOAT, false, NeverSupported,                                                             NeverSupported,                                  NeverSupported,                                  NeverSupported, NeverSupported);
1434*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB,          false, 16, 16, 16,  0, 0, GL_RGB,  GL_HALF_FLOAT,                   GL_FLOAT, false, NeverSupported,                                                             NeverSupported,                                  NeverSupported,                                  NeverSupported, NeverSupported);
1435*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA,         false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT,                   GL_FLOAT, false, NeverSupported,                                                             NeverSupported,                                  NeverSupported,                                  NeverSupported, NeverSupported);
1436*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RED,          false, 16,  0,  0,  0, 0, GL_RED,  GL_HALF_FLOAT_OES,               GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloatOES, &Extensions::textureRgEXT>,    RequireExt<&Extensions::textureHalfFloatLinearOES>, AlwaysSupported,                                 NeverSupported, NeverSupported);
1437*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RG,           false, 16, 16,  0,  0, 0, GL_RG,   GL_HALF_FLOAT_OES,               GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloatOES, &Extensions::textureRgEXT>,    RequireExt<&Extensions::textureHalfFloatLinearOES>, AlwaysSupported,                                 NeverSupported, NeverSupported);
1438*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB,          false, 16, 16, 16,  0, 0, GL_RGB,  GL_HALF_FLOAT_OES,               GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloatOES>,                                  RequireExt<&Extensions::textureHalfFloatLinearOES>, RequireExt<&Extensions::colorBufferHalfFloatEXT>,   NeverSupported, NeverSupported);
1439*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA,         false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES,               GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloatOES>,                                  RequireExt<&Extensions::textureHalfFloatLinearOES>, RequireExt<&Extensions::colorBufferHalfFloatEXT>,   NeverSupported, NeverSupported);
1440*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RED,          false, 32,  0,  0,  0, 0, GL_RED,  GL_FLOAT,                        GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloatOES, &Extensions::textureRgEXT>,     RequireExt<&Extensions::textureFloatLinearOES>,  AlwaysSupported,                                 NeverSupported, NeverSupported);
1441*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RG,           false, 32, 32,  0,  0, 0, GL_RG,   GL_FLOAT,                        GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloatOES, &Extensions::textureRgEXT>,     RequireExt<&Extensions::textureFloatLinearOES>,  AlwaysSupported,                                 NeverSupported, NeverSupported);
1442*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGB,          false, 32, 32, 32,  0, 0, GL_RGB,  GL_FLOAT,                        GL_FLOAT, false, RequireExt<&Extensions::textureFloatOES>,                                   RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,                                  NeverSupported, NeverSupported);
1443*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1444*8975f5c5SAndroid Build Coastguard Worker     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, NeverSupported);
1445*8975f5c5SAndroid Build Coastguard Worker     AddRGBAFormat(&map, GL_RGBA,         false, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT,                        GL_FLOAT, false, RequireExt<&Extensions::textureFloatOES>,                                   RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,                                  NeverSupported, NeverSupported);
1446*8975f5c5SAndroid Build Coastguard Worker 
1447*8975f5c5SAndroid Build Coastguard Worker     // Unsized luminance alpha formats
1448*8975f5c5SAndroid Build Coastguard Worker     //                 | Internal format   |sized | L | A | Format            | Type             | Component type        | Texture supported                        | Filterable                                     | Texture attachment | Renderbuffer  | Blend
1449*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_ALPHA,           false,  0,  8, GL_ALPHA,           GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, AlwaysSupported,                           AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1450*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE,       false,  8,  0, GL_LUMINANCE,       GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, AlwaysSupported,                           AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1451*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false,  8,  8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, AlwaysSupported,                           AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1452*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_ALPHA,           false,  0, 16, GL_ALPHA,           GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExt<&Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1453*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE,       false, 16,  0, GL_LUMINANCE,       GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExt<&Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1454*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExt<&Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1455*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_ALPHA,           false,  0, 32, GL_ALPHA,           GL_FLOAT,          GL_FLOAT,               RequireExt<&Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1456*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE,       false, 32,  0, GL_LUMINANCE,       GL_FLOAT,          GL_FLOAT,               RequireExt<&Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1457*8975f5c5SAndroid Build Coastguard Worker     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT,          GL_FLOAT,               RequireExt<&Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1458*8975f5c5SAndroid Build Coastguard Worker 
1459*8975f5c5SAndroid Build Coastguard Worker     // Unsized depth stencil formats
1460*8975f5c5SAndroid Build Coastguard Worker     //                         | Internal format   |sized | D |S | X | Format            | Type                             | Component type        | Texture supported                                       | Filterable     | Texture attachment                                                                  | Renderbuffer                                                                       | Blend
1461*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 16, 0,  0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT,                 GL_UNSIGNED_NORMALIZED, RequireES<1, 0>,                                          AlwaysSupported, RequireExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES>,        RequireExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES>,        RequireExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES>);
1462*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 24, 0,  8, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,                   GL_UNSIGNED_NORMALIZED, RequireES<1, 0>,                                          AlwaysSupported, RequireExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES>,        RequireExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES>,        RequireExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES>);
1463*8975f5c5SAndroid Build Coastguard Worker     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>,                                                                      RequireES<1, 0>);
1464*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 24, 8,  0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_24_8,              GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 0, &Extensions::packedDepthStencilOES>, AlwaysSupported, RequireExtAndExt<&Extensions::packedDepthStencilOES, &Extensions::depthTextureANGLE>, RequireExtAndExt<&Extensions::packedDepthStencilOES, &Extensions::depthTextureANGLE>, RequireExtAndExt<&Extensions::packedDepthStencilOES, &Extensions::depthTextureANGLE>);
1465*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_DEPTH_STENCIL,   false, 24, 8,  0, GL_DEPTH_STENCIL,   GL_UNSIGNED_INT_24_8,              GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 0, &Extensions::packedDepthStencilOES>, AlwaysSupported, RequireExtAndExt<&Extensions::packedDepthStencilOES, &Extensions::depthTextureANGLE>, RequireExtAndExt<&Extensions::packedDepthStencilOES, &Extensions::depthTextureANGLE>, RequireExtAndExt<&Extensions::packedDepthStencilOES, &Extensions::depthTextureANGLE>);
1466*8975f5c5SAndroid Build Coastguard Worker     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::packedDepthStencilOES>, AlwaysSupported, RequireExt<&Extensions::packedDepthStencilOES>,                                       RequireExt<&Extensions::packedDepthStencilOES>,                                       RequireExt<&Extensions::packedDepthStencilOES>);
1467*8975f5c5SAndroid Build Coastguard Worker     AddDepthStencilFormat(&map, GL_STENCIL_INDEX,   false,  0, 8,  0, GL_STENCIL_INDEX,   GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, NeverSupported,                                           NeverSupported , NeverSupported,                                                                       NeverSupported,                                                                       NeverSupported);
1468*8975f5c5SAndroid Build Coastguard Worker 
1469*8975f5c5SAndroid Build Coastguard Worker     // Non-standard YUV formats
1470*8975f5c5SAndroid Build Coastguard Worker     //                 | Internal format                             | sized | Cr | Y | Cb | A | S | Format                              | Type            | Comp                  | SRGB | Texture supported                                       | Filterable                                              | Texture attachment                                      | Renderbuffer  | Blend
1471*8975f5c5SAndroid Build Coastguard Worker     AddYUVFormat(&map,  GL_G8_B8R8_2PLANE_420_UNORM_ANGLE,            true,   8,   8,  8,   0,  0,  GL_G8_B8R8_2PLANE_420_UNORM_ANGLE,    GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::yuvInternalFormatANGLE>,          RequireExt<&Extensions::yuvInternalFormatANGLE>,          RequireExt<&Extensions::yuvInternalFormatANGLE>,          NeverSupported, NeverSupported);
1472*8975f5c5SAndroid Build Coastguard Worker     AddYUVFormat(&map,  GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE,           true,   8,   8,  8,   0,  0,  GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE,   GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::yuvInternalFormatANGLE>,          RequireExt<&Extensions::yuvInternalFormatANGLE>,          RequireExt<&Extensions::yuvInternalFormatANGLE>,          NeverSupported, NeverSupported);
1473*8975f5c5SAndroid Build Coastguard Worker 
1474*8975f5c5SAndroid Build Coastguard Worker     // clang-format on
1475*8975f5c5SAndroid Build Coastguard Worker 
1476*8975f5c5SAndroid Build Coastguard Worker     return map;
1477*8975f5c5SAndroid Build Coastguard Worker }
1478*8975f5c5SAndroid Build Coastguard Worker 
GetInternalFormatMap()1479*8975f5c5SAndroid Build Coastguard Worker const InternalFormatInfoMap &GetInternalFormatMap()
1480*8975f5c5SAndroid Build Coastguard Worker {
1481*8975f5c5SAndroid Build Coastguard Worker     static const angle::base::NoDestructor<InternalFormatInfoMap> formatMap(
1482*8975f5c5SAndroid Build Coastguard Worker         BuildInternalFormatInfoMap());
1483*8975f5c5SAndroid Build Coastguard Worker     return *formatMap;
1484*8975f5c5SAndroid Build Coastguard Worker }
1485*8975f5c5SAndroid Build Coastguard Worker 
GetAndroidHardwareBufferFormatFromChannelSizes(const egl::AttributeMap & attribMap)1486*8975f5c5SAndroid Build Coastguard Worker int GetAndroidHardwareBufferFormatFromChannelSizes(const egl::AttributeMap &attribMap)
1487*8975f5c5SAndroid Build Coastguard Worker {
1488*8975f5c5SAndroid Build Coastguard Worker     // Retrieve channel size from attribute map. The default value should be 0, per spec.
1489*8975f5c5SAndroid Build Coastguard Worker     GLuint redSize   = static_cast<GLuint>(attribMap.getAsInt(EGL_RED_SIZE, 0));
1490*8975f5c5SAndroid Build Coastguard Worker     GLuint greenSize = static_cast<GLuint>(attribMap.getAsInt(EGL_GREEN_SIZE, 0));
1491*8975f5c5SAndroid Build Coastguard Worker     GLuint blueSize  = static_cast<GLuint>(attribMap.getAsInt(EGL_BLUE_SIZE, 0));
1492*8975f5c5SAndroid Build Coastguard Worker     GLuint alphaSize = static_cast<GLuint>(attribMap.getAsInt(EGL_ALPHA_SIZE, 0));
1493*8975f5c5SAndroid Build Coastguard Worker 
1494*8975f5c5SAndroid Build Coastguard Worker     GLenum glInternalFormat = 0;
1495*8975f5c5SAndroid Build Coastguard Worker     for (GLenum sizedInternalFormat : angle::android::kSupportedSizedInternalFormats)
1496*8975f5c5SAndroid Build Coastguard Worker     {
1497*8975f5c5SAndroid Build Coastguard Worker         const gl::InternalFormat &internalFormat = GetSizedInternalFormatInfo(sizedInternalFormat);
1498*8975f5c5SAndroid Build Coastguard Worker         ASSERT(internalFormat.internalFormat != GL_NONE && internalFormat.sized);
1499*8975f5c5SAndroid Build Coastguard Worker 
1500*8975f5c5SAndroid Build Coastguard Worker         if (internalFormat.isChannelSizeCompatible(redSize, greenSize, blueSize, alphaSize))
1501*8975f5c5SAndroid Build Coastguard Worker         {
1502*8975f5c5SAndroid Build Coastguard Worker             glInternalFormat = sizedInternalFormat;
1503*8975f5c5SAndroid Build Coastguard Worker             break;
1504*8975f5c5SAndroid Build Coastguard Worker         }
1505*8975f5c5SAndroid Build Coastguard Worker     }
1506*8975f5c5SAndroid Build Coastguard Worker 
1507*8975f5c5SAndroid Build Coastguard Worker     return (glInternalFormat != 0)
1508*8975f5c5SAndroid Build Coastguard Worker                ? angle::android::GLInternalFormatToNativePixelFormat(glInternalFormat)
1509*8975f5c5SAndroid Build Coastguard Worker                : 0;
1510*8975f5c5SAndroid Build Coastguard Worker }
1511*8975f5c5SAndroid Build Coastguard Worker 
GetConfigColorBufferFormat(const egl::Config * config)1512*8975f5c5SAndroid Build Coastguard Worker GLenum GetConfigColorBufferFormat(const egl::Config *config)
1513*8975f5c5SAndroid Build Coastguard Worker {
1514*8975f5c5SAndroid Build Coastguard Worker     GLenum componentType = GL_NONE;
1515*8975f5c5SAndroid Build Coastguard Worker     switch (config->colorComponentType)
1516*8975f5c5SAndroid Build Coastguard Worker     {
1517*8975f5c5SAndroid Build Coastguard Worker         case EGL_COLOR_COMPONENT_TYPE_FIXED_EXT:
1518*8975f5c5SAndroid Build Coastguard Worker             componentType = GL_UNSIGNED_NORMALIZED;
1519*8975f5c5SAndroid Build Coastguard Worker             break;
1520*8975f5c5SAndroid Build Coastguard Worker         case EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT:
1521*8975f5c5SAndroid Build Coastguard Worker             componentType = GL_FLOAT;
1522*8975f5c5SAndroid Build Coastguard Worker             break;
1523*8975f5c5SAndroid Build Coastguard Worker         default:
1524*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
1525*8975f5c5SAndroid Build Coastguard Worker             return GL_NONE;
1526*8975f5c5SAndroid Build Coastguard Worker     }
1527*8975f5c5SAndroid Build Coastguard Worker 
1528*8975f5c5SAndroid Build Coastguard Worker     GLenum colorEncoding = GL_LINEAR;
1529*8975f5c5SAndroid Build Coastguard Worker 
1530*8975f5c5SAndroid Build Coastguard Worker     for (GLenum sizedInternalFormat : GetAllSizedInternalFormats())
1531*8975f5c5SAndroid Build Coastguard Worker     {
1532*8975f5c5SAndroid Build Coastguard Worker         const gl::InternalFormat &internalFormat = GetSizedInternalFormatInfo(sizedInternalFormat);
1533*8975f5c5SAndroid Build Coastguard Worker 
1534*8975f5c5SAndroid Build Coastguard Worker         if (internalFormat.componentType == componentType &&
1535*8975f5c5SAndroid Build Coastguard Worker             internalFormat.colorEncoding == colorEncoding &&
1536*8975f5c5SAndroid Build Coastguard Worker             internalFormat.isChannelSizeCompatible(config->redSize, config->greenSize,
1537*8975f5c5SAndroid Build Coastguard Worker                                                    config->blueSize, config->alphaSize))
1538*8975f5c5SAndroid Build Coastguard Worker         {
1539*8975f5c5SAndroid Build Coastguard Worker             return sizedInternalFormat;
1540*8975f5c5SAndroid Build Coastguard Worker         }
1541*8975f5c5SAndroid Build Coastguard Worker     }
1542*8975f5c5SAndroid Build Coastguard Worker 
1543*8975f5c5SAndroid Build Coastguard Worker     // Only expect to get here if there is no color bits in the config
1544*8975f5c5SAndroid Build Coastguard Worker     ASSERT(config->redSize == 0 && config->greenSize == 0 && config->blueSize == 0 &&
1545*8975f5c5SAndroid Build Coastguard Worker            config->alphaSize == 0);
1546*8975f5c5SAndroid Build Coastguard Worker     return GL_NONE;
1547*8975f5c5SAndroid Build Coastguard Worker }
1548*8975f5c5SAndroid Build Coastguard Worker 
GetConfigDepthStencilBufferFormat(const egl::Config * config)1549*8975f5c5SAndroid Build Coastguard Worker GLenum GetConfigDepthStencilBufferFormat(const egl::Config *config)
1550*8975f5c5SAndroid Build Coastguard Worker {
1551*8975f5c5SAndroid Build Coastguard Worker     GLenum componentType = GL_UNSIGNED_NORMALIZED;
1552*8975f5c5SAndroid Build Coastguard Worker 
1553*8975f5c5SAndroid Build Coastguard Worker     for (GLenum sizedInternalFormat : GetAllSizedInternalFormats())
1554*8975f5c5SAndroid Build Coastguard Worker     {
1555*8975f5c5SAndroid Build Coastguard Worker         const gl::InternalFormat &internalFormat = GetSizedInternalFormatInfo(sizedInternalFormat);
1556*8975f5c5SAndroid Build Coastguard Worker 
1557*8975f5c5SAndroid Build Coastguard Worker         if (internalFormat.componentType == componentType &&
1558*8975f5c5SAndroid Build Coastguard Worker             static_cast<EGLint>(internalFormat.depthBits) == config->depthSize &&
1559*8975f5c5SAndroid Build Coastguard Worker             static_cast<EGLint>(internalFormat.stencilBits) == config->stencilSize)
1560*8975f5c5SAndroid Build Coastguard Worker         {
1561*8975f5c5SAndroid Build Coastguard Worker             return sizedInternalFormat;
1562*8975f5c5SAndroid Build Coastguard Worker         }
1563*8975f5c5SAndroid Build Coastguard Worker     }
1564*8975f5c5SAndroid Build Coastguard Worker 
1565*8975f5c5SAndroid Build Coastguard Worker     // Only expect to get here if there is no depth or stencil bits in the config
1566*8975f5c5SAndroid Build Coastguard Worker     ASSERT(config->depthSize == 0 && config->stencilSize == 0);
1567*8975f5c5SAndroid Build Coastguard Worker     return GL_NONE;
1568*8975f5c5SAndroid Build Coastguard Worker }
1569*8975f5c5SAndroid Build Coastguard Worker 
BuildAllSizedInternalFormatSet()1570*8975f5c5SAndroid Build Coastguard Worker static FormatSet BuildAllSizedInternalFormatSet()
1571*8975f5c5SAndroid Build Coastguard Worker {
1572*8975f5c5SAndroid Build Coastguard Worker     FormatSet result;
1573*8975f5c5SAndroid Build Coastguard Worker 
1574*8975f5c5SAndroid Build Coastguard Worker     for (const auto &internalFormat : GetInternalFormatMap())
1575*8975f5c5SAndroid Build Coastguard Worker     {
1576*8975f5c5SAndroid Build Coastguard Worker         for (const auto &type : internalFormat.second)
1577*8975f5c5SAndroid Build Coastguard Worker         {
1578*8975f5c5SAndroid Build Coastguard Worker             if (type.second.sized)
1579*8975f5c5SAndroid Build Coastguard Worker             {
1580*8975f5c5SAndroid Build Coastguard Worker                 // TODO(jmadill): Fix this hack.
1581*8975f5c5SAndroid Build Coastguard Worker                 if (internalFormat.first == GL_BGR565_ANGLEX)
1582*8975f5c5SAndroid Build Coastguard Worker                     continue;
1583*8975f5c5SAndroid Build Coastguard Worker 
1584*8975f5c5SAndroid Build Coastguard Worker                 result.insert(internalFormat.first);
1585*8975f5c5SAndroid Build Coastguard Worker             }
1586*8975f5c5SAndroid Build Coastguard Worker         }
1587*8975f5c5SAndroid Build Coastguard Worker     }
1588*8975f5c5SAndroid Build Coastguard Worker 
1589*8975f5c5SAndroid Build Coastguard Worker     return result;
1590*8975f5c5SAndroid Build Coastguard Worker }
1591*8975f5c5SAndroid Build Coastguard Worker 
GetPackedTypeInfo(GLenum type)1592*8975f5c5SAndroid Build Coastguard Worker uint32_t GetPackedTypeInfo(GLenum type)
1593*8975f5c5SAndroid Build Coastguard Worker {
1594*8975f5c5SAndroid Build Coastguard Worker     switch (type)
1595*8975f5c5SAndroid Build Coastguard Worker     {
1596*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_BYTE:
1597*8975f5c5SAndroid Build Coastguard Worker         case GL_BYTE:
1598*8975f5c5SAndroid Build Coastguard Worker         {
1599*8975f5c5SAndroid Build Coastguard Worker             static constexpr uint32_t kPacked = PackTypeInfo(1, false);
1600*8975f5c5SAndroid Build Coastguard Worker             return kPacked;
1601*8975f5c5SAndroid Build Coastguard Worker         }
1602*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_SHORT:
1603*8975f5c5SAndroid Build Coastguard Worker         case GL_SHORT:
1604*8975f5c5SAndroid Build Coastguard Worker         case GL_HALF_FLOAT:
1605*8975f5c5SAndroid Build Coastguard Worker         case GL_HALF_FLOAT_OES:
1606*8975f5c5SAndroid Build Coastguard Worker         {
1607*8975f5c5SAndroid Build Coastguard Worker             static constexpr uint32_t kPacked = PackTypeInfo(2, false);
1608*8975f5c5SAndroid Build Coastguard Worker             return kPacked;
1609*8975f5c5SAndroid Build Coastguard Worker         }
1610*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT:
1611*8975f5c5SAndroid Build Coastguard Worker         case GL_INT:
1612*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT:
1613*8975f5c5SAndroid Build Coastguard Worker         {
1614*8975f5c5SAndroid Build Coastguard Worker             static constexpr uint32_t kPacked = PackTypeInfo(4, false);
1615*8975f5c5SAndroid Build Coastguard Worker             return kPacked;
1616*8975f5c5SAndroid Build Coastguard Worker         }
1617*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_SHORT_5_6_5:
1618*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_SHORT_4_4_4_4:
1619*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_SHORT_5_5_5_1:
1620*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1621*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1622*8975f5c5SAndroid Build Coastguard Worker         {
1623*8975f5c5SAndroid Build Coastguard Worker             static constexpr uint32_t kPacked = PackTypeInfo(2, true);
1624*8975f5c5SAndroid Build Coastguard Worker             return kPacked;
1625*8975f5c5SAndroid Build Coastguard Worker         }
1626*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT_2_10_10_10_REV:
1627*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT_24_8:
1628*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT_10F_11F_11F_REV:
1629*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT_5_9_9_9_REV:
1630*8975f5c5SAndroid Build Coastguard Worker         {
1631*8975f5c5SAndroid Build Coastguard Worker             ASSERT(GL_UNSIGNED_INT_24_8_OES == GL_UNSIGNED_INT_24_8);
1632*8975f5c5SAndroid Build Coastguard Worker             static constexpr uint32_t kPacked = PackTypeInfo(4, true);
1633*8975f5c5SAndroid Build Coastguard Worker             return kPacked;
1634*8975f5c5SAndroid Build Coastguard Worker         }
1635*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
1636*8975f5c5SAndroid Build Coastguard Worker         {
1637*8975f5c5SAndroid Build Coastguard Worker             static constexpr uint32_t kPacked = PackTypeInfo(8, true);
1638*8975f5c5SAndroid Build Coastguard Worker             return kPacked;
1639*8975f5c5SAndroid Build Coastguard Worker         }
1640*8975f5c5SAndroid Build Coastguard Worker         default:
1641*8975f5c5SAndroid Build Coastguard Worker         {
1642*8975f5c5SAndroid Build Coastguard Worker             return 0;
1643*8975f5c5SAndroid Build Coastguard Worker         }
1644*8975f5c5SAndroid Build Coastguard Worker     }
1645*8975f5c5SAndroid Build Coastguard Worker }
1646*8975f5c5SAndroid Build Coastguard Worker 
GetSizedInternalFormatInfo(GLenum internalFormat)1647*8975f5c5SAndroid Build Coastguard Worker const InternalFormat &GetSizedInternalFormatInfo(GLenum internalFormat)
1648*8975f5c5SAndroid Build Coastguard Worker {
1649*8975f5c5SAndroid Build Coastguard Worker     static const InternalFormat defaultInternalFormat;
1650*8975f5c5SAndroid Build Coastguard Worker     const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
1651*8975f5c5SAndroid Build Coastguard Worker     auto iter                              = formatMap.find(internalFormat);
1652*8975f5c5SAndroid Build Coastguard Worker 
1653*8975f5c5SAndroid Build Coastguard Worker     // Sized internal formats only have one type per entry
1654*8975f5c5SAndroid Build Coastguard Worker     if (iter == formatMap.end() || iter->second.size() != 1)
1655*8975f5c5SAndroid Build Coastguard Worker     {
1656*8975f5c5SAndroid Build Coastguard Worker         return defaultInternalFormat;
1657*8975f5c5SAndroid Build Coastguard Worker     }
1658*8975f5c5SAndroid Build Coastguard Worker 
1659*8975f5c5SAndroid Build Coastguard Worker     const InternalFormat &internalFormatInfo = iter->second.begin()->second;
1660*8975f5c5SAndroid Build Coastguard Worker     if (!internalFormatInfo.sized)
1661*8975f5c5SAndroid Build Coastguard Worker     {
1662*8975f5c5SAndroid Build Coastguard Worker         return defaultInternalFormat;
1663*8975f5c5SAndroid Build Coastguard Worker     }
1664*8975f5c5SAndroid Build Coastguard Worker 
1665*8975f5c5SAndroid Build Coastguard Worker     return internalFormatInfo;
1666*8975f5c5SAndroid Build Coastguard Worker }
1667*8975f5c5SAndroid Build Coastguard Worker 
GetInternalFormatInfo(GLenum internalFormat,GLenum type)1668*8975f5c5SAndroid Build Coastguard Worker const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, GLenum type)
1669*8975f5c5SAndroid Build Coastguard Worker {
1670*8975f5c5SAndroid Build Coastguard Worker     static const InternalFormat defaultInternalFormat;
1671*8975f5c5SAndroid Build Coastguard Worker     const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
1672*8975f5c5SAndroid Build Coastguard Worker 
1673*8975f5c5SAndroid Build Coastguard Worker     auto internalFormatIter = formatMap.find(internalFormat);
1674*8975f5c5SAndroid Build Coastguard Worker     if (internalFormatIter == formatMap.end())
1675*8975f5c5SAndroid Build Coastguard Worker     {
1676*8975f5c5SAndroid Build Coastguard Worker         return defaultInternalFormat;
1677*8975f5c5SAndroid Build Coastguard Worker     }
1678*8975f5c5SAndroid Build Coastguard Worker 
1679*8975f5c5SAndroid Build Coastguard Worker     // If the internal format is sized, simply return it without the type check.
1680*8975f5c5SAndroid Build Coastguard Worker     if (internalFormatIter->second.size() == 1 && internalFormatIter->second.begin()->second.sized)
1681*8975f5c5SAndroid Build Coastguard Worker     {
1682*8975f5c5SAndroid Build Coastguard Worker         return internalFormatIter->second.begin()->second;
1683*8975f5c5SAndroid Build Coastguard Worker     }
1684*8975f5c5SAndroid Build Coastguard Worker 
1685*8975f5c5SAndroid Build Coastguard Worker     auto typeIter = internalFormatIter->second.find(type);
1686*8975f5c5SAndroid Build Coastguard Worker     if (typeIter == internalFormatIter->second.end())
1687*8975f5c5SAndroid Build Coastguard Worker     {
1688*8975f5c5SAndroid Build Coastguard Worker         return defaultInternalFormat;
1689*8975f5c5SAndroid Build Coastguard Worker     }
1690*8975f5c5SAndroid Build Coastguard Worker 
1691*8975f5c5SAndroid Build Coastguard Worker     return typeIter->second;
1692*8975f5c5SAndroid Build Coastguard Worker }
1693*8975f5c5SAndroid Build Coastguard Worker 
computePixelBytes(GLenum formatType) const1694*8975f5c5SAndroid Build Coastguard Worker GLuint InternalFormat::computePixelBytes(GLenum formatType) const
1695*8975f5c5SAndroid Build Coastguard Worker {
1696*8975f5c5SAndroid Build Coastguard Worker     const auto &typeInfo = GetTypeInfo(formatType);
1697*8975f5c5SAndroid Build Coastguard Worker     GLuint components    = componentCount;
1698*8975f5c5SAndroid Build Coastguard Worker     // It shouldn't be these internal formats
1699*8975f5c5SAndroid Build Coastguard Worker     ASSERT(sizedInternalFormat != GL_RGBX8_SRGB_ANGLEX &&
1700*8975f5c5SAndroid Build Coastguard Worker            sizedInternalFormat != GL_BGRX8_SRGB_ANGLEX);
1701*8975f5c5SAndroid Build Coastguard Worker     if (sizedInternalFormat == GL_RGBX8_ANGLE)
1702*8975f5c5SAndroid Build Coastguard Worker     {
1703*8975f5c5SAndroid Build Coastguard Worker         components = 4;
1704*8975f5c5SAndroid Build Coastguard Worker     }
1705*8975f5c5SAndroid Build Coastguard Worker     else if (typeInfo.specialInterpretation)
1706*8975f5c5SAndroid Build Coastguard Worker     {
1707*8975f5c5SAndroid Build Coastguard Worker         components = 1;
1708*8975f5c5SAndroid Build Coastguard Worker     }
1709*8975f5c5SAndroid Build Coastguard Worker     return components * typeInfo.bytes;
1710*8975f5c5SAndroid Build Coastguard Worker }
1711*8975f5c5SAndroid Build Coastguard Worker 
computeBufferRowLength(uint32_t width,uint32_t * resultOut) const1712*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computeBufferRowLength(uint32_t width, uint32_t *resultOut) const
1713*8975f5c5SAndroid Build Coastguard Worker {
1714*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedWidth(width);
1715*8975f5c5SAndroid Build Coastguard Worker 
1716*8975f5c5SAndroid Build Coastguard Worker     if (compressed)
1717*8975f5c5SAndroid Build Coastguard Worker     {
1718*8975f5c5SAndroid Build Coastguard Worker         angle::CheckedNumeric<uint32_t> checkedRowLength =
1719*8975f5c5SAndroid Build Coastguard Worker             rx::CheckedRoundUp<uint32_t>(width, compressedBlockWidth);
1720*8975f5c5SAndroid Build Coastguard Worker 
1721*8975f5c5SAndroid Build Coastguard Worker         return CheckedMathResult(checkedRowLength, resultOut);
1722*8975f5c5SAndroid Build Coastguard Worker     }
1723*8975f5c5SAndroid Build Coastguard Worker 
1724*8975f5c5SAndroid Build Coastguard Worker     return CheckedMathResult(checkedWidth, resultOut);
1725*8975f5c5SAndroid Build Coastguard Worker }
1726*8975f5c5SAndroid Build Coastguard Worker 
computeBufferImageHeight(uint32_t height,uint32_t * resultOut) const1727*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computeBufferImageHeight(uint32_t height, uint32_t *resultOut) const
1728*8975f5c5SAndroid Build Coastguard Worker {
1729*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedHeight(height);
1730*8975f5c5SAndroid Build Coastguard Worker 
1731*8975f5c5SAndroid Build Coastguard Worker     if (compressed)
1732*8975f5c5SAndroid Build Coastguard Worker     {
1733*8975f5c5SAndroid Build Coastguard Worker         angle::CheckedNumeric<uint32_t> checkedImageHeight =
1734*8975f5c5SAndroid Build Coastguard Worker             rx::CheckedRoundUp<uint32_t>(height, compressedBlockHeight);
1735*8975f5c5SAndroid Build Coastguard Worker 
1736*8975f5c5SAndroid Build Coastguard Worker         return CheckedMathResult(checkedImageHeight, resultOut);
1737*8975f5c5SAndroid Build Coastguard Worker     }
1738*8975f5c5SAndroid Build Coastguard Worker 
1739*8975f5c5SAndroid Build Coastguard Worker     return CheckedMathResult(checkedHeight, resultOut);
1740*8975f5c5SAndroid Build Coastguard Worker }
1741*8975f5c5SAndroid Build Coastguard Worker 
computePalettedImageRowPitch(GLsizei width,GLuint * resultOut) const1742*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computePalettedImageRowPitch(GLsizei width, GLuint *resultOut) const
1743*8975f5c5SAndroid Build Coastguard Worker {
1744*8975f5c5SAndroid Build Coastguard Worker     ASSERT(paletted);
1745*8975f5c5SAndroid Build Coastguard Worker     switch (paletteBits)
1746*8975f5c5SAndroid Build Coastguard Worker     {
1747*8975f5c5SAndroid Build Coastguard Worker         case 4:
1748*8975f5c5SAndroid Build Coastguard Worker             *resultOut = (width + 1) / 2;
1749*8975f5c5SAndroid Build Coastguard Worker             return true;
1750*8975f5c5SAndroid Build Coastguard Worker         case 8:
1751*8975f5c5SAndroid Build Coastguard Worker             *resultOut = width;
1752*8975f5c5SAndroid Build Coastguard Worker             return true;
1753*8975f5c5SAndroid Build Coastguard Worker         default:
1754*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
1755*8975f5c5SAndroid Build Coastguard Worker             return false;
1756*8975f5c5SAndroid Build Coastguard Worker     }
1757*8975f5c5SAndroid Build Coastguard Worker }
1758*8975f5c5SAndroid Build Coastguard Worker 
computeRowPitch(GLenum formatType,GLsizei width,GLint alignment,GLint rowLength,GLuint * resultOut) const1759*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computeRowPitch(GLenum formatType,
1760*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei width,
1761*8975f5c5SAndroid Build Coastguard Worker                                      GLint alignment,
1762*8975f5c5SAndroid Build Coastguard Worker                                      GLint rowLength,
1763*8975f5c5SAndroid Build Coastguard Worker                                      GLuint *resultOut) const
1764*8975f5c5SAndroid Build Coastguard Worker {
1765*8975f5c5SAndroid Build Coastguard Worker     if (paletted)
1766*8975f5c5SAndroid Build Coastguard Worker     {
1767*8975f5c5SAndroid Build Coastguard Worker         return computePalettedImageRowPitch(width, resultOut);
1768*8975f5c5SAndroid Build Coastguard Worker     }
1769*8975f5c5SAndroid Build Coastguard Worker 
1770*8975f5c5SAndroid Build Coastguard Worker     // Compressed images do not use pack/unpack parameters (rowLength).
1771*8975f5c5SAndroid Build Coastguard Worker     if (compressed)
1772*8975f5c5SAndroid Build Coastguard Worker     {
1773*8975f5c5SAndroid Build Coastguard Worker         return computeCompressedImageRowPitch(width, resultOut);
1774*8975f5c5SAndroid Build Coastguard Worker     }
1775*8975f5c5SAndroid Build Coastguard Worker 
1776*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedWidth(rowLength > 0 ? rowLength : width);
1777*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * computePixelBytes(formatType);
1778*8975f5c5SAndroid Build Coastguard Worker 
1779*8975f5c5SAndroid Build Coastguard Worker     ASSERT(alignment > 0 && isPow2(alignment));
1780*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedAlignment(alignment);
1781*8975f5c5SAndroid Build Coastguard Worker     auto aligned = rx::roundUp(checkedRowBytes, checkedAlignment);
1782*8975f5c5SAndroid Build Coastguard Worker     return CheckedMathResult(aligned, resultOut);
1783*8975f5c5SAndroid Build Coastguard Worker }
1784*8975f5c5SAndroid Build Coastguard Worker 
computeDepthPitch(GLsizei height,GLint imageHeight,GLuint rowPitch,GLuint * resultOut) const1785*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computeDepthPitch(GLsizei height,
1786*8975f5c5SAndroid Build Coastguard Worker                                        GLint imageHeight,
1787*8975f5c5SAndroid Build Coastguard Worker                                        GLuint rowPitch,
1788*8975f5c5SAndroid Build Coastguard Worker                                        GLuint *resultOut) const
1789*8975f5c5SAndroid Build Coastguard Worker {
1790*8975f5c5SAndroid Build Coastguard Worker     // Compressed images do not use pack/unpack parameters (imageHeight).
1791*8975f5c5SAndroid Build Coastguard Worker     if (compressed)
1792*8975f5c5SAndroid Build Coastguard Worker     {
1793*8975f5c5SAndroid Build Coastguard Worker         return computeCompressedImageDepthPitch(height, rowPitch, resultOut);
1794*8975f5c5SAndroid Build Coastguard Worker     }
1795*8975f5c5SAndroid Build Coastguard Worker 
1796*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> rowCount((imageHeight > 0) ? static_cast<GLuint>(imageHeight)
1797*8975f5c5SAndroid Build Coastguard Worker                                                       : static_cast<GLuint>(height));
1798*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1799*8975f5c5SAndroid Build Coastguard Worker 
1800*8975f5c5SAndroid Build Coastguard Worker     return CheckedMathResult(checkedRowPitch * rowCount, resultOut);
1801*8975f5c5SAndroid Build Coastguard Worker }
1802*8975f5c5SAndroid Build Coastguard Worker 
computeDepthPitch(GLenum formatType,GLsizei width,GLsizei height,GLint alignment,GLint rowLength,GLint imageHeight,GLuint * resultOut) const1803*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computeDepthPitch(GLenum formatType,
1804*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei width,
1805*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei height,
1806*8975f5c5SAndroid Build Coastguard Worker                                        GLint alignment,
1807*8975f5c5SAndroid Build Coastguard Worker                                        GLint rowLength,
1808*8975f5c5SAndroid Build Coastguard Worker                                        GLint imageHeight,
1809*8975f5c5SAndroid Build Coastguard Worker                                        GLuint *resultOut) const
1810*8975f5c5SAndroid Build Coastguard Worker {
1811*8975f5c5SAndroid Build Coastguard Worker     GLuint rowPitch = 0;
1812*8975f5c5SAndroid Build Coastguard Worker     if (!computeRowPitch(formatType, width, alignment, rowLength, &rowPitch))
1813*8975f5c5SAndroid Build Coastguard Worker     {
1814*8975f5c5SAndroid Build Coastguard Worker         return false;
1815*8975f5c5SAndroid Build Coastguard Worker     }
1816*8975f5c5SAndroid Build Coastguard Worker     return computeDepthPitch(height, imageHeight, rowPitch, resultOut);
1817*8975f5c5SAndroid Build Coastguard Worker }
1818*8975f5c5SAndroid Build Coastguard Worker 
computeCompressedImageRowPitch(GLsizei width,GLuint * resultOut) const1819*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computeCompressedImageRowPitch(GLsizei width, GLuint *resultOut) const
1820*8975f5c5SAndroid Build Coastguard Worker {
1821*8975f5c5SAndroid Build Coastguard Worker     ASSERT(compressed);
1822*8975f5c5SAndroid Build Coastguard Worker 
1823*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedWidth(width);
1824*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedBlockWidth(compressedBlockWidth);
1825*8975f5c5SAndroid Build Coastguard Worker     const GLuint minBlockWidth = getCompressedImageMinBlocks().first;
1826*8975f5c5SAndroid Build Coastguard Worker 
1827*8975f5c5SAndroid Build Coastguard Worker     auto numBlocksWide = (checkedWidth + checkedBlockWidth - 1u) / checkedBlockWidth;
1828*8975f5c5SAndroid Build Coastguard Worker     if (numBlocksWide.IsValid() && numBlocksWide.ValueOrDie() < minBlockWidth)
1829*8975f5c5SAndroid Build Coastguard Worker     {
1830*8975f5c5SAndroid Build Coastguard Worker         numBlocksWide = minBlockWidth;
1831*8975f5c5SAndroid Build Coastguard Worker     }
1832*8975f5c5SAndroid Build Coastguard Worker     return CheckedMathResult(numBlocksWide * pixelBytes, resultOut);
1833*8975f5c5SAndroid Build Coastguard Worker }
1834*8975f5c5SAndroid Build Coastguard Worker 
computeCompressedImageDepthPitch(GLsizei height,GLuint rowPitch,GLuint * resultOut) const1835*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computeCompressedImageDepthPitch(GLsizei height,
1836*8975f5c5SAndroid Build Coastguard Worker                                                       GLuint rowPitch,
1837*8975f5c5SAndroid Build Coastguard Worker                                                       GLuint *resultOut) const
1838*8975f5c5SAndroid Build Coastguard Worker {
1839*8975f5c5SAndroid Build Coastguard Worker     ASSERT(compressed);
1840*8975f5c5SAndroid Build Coastguard Worker     ASSERT(rowPitch > 0 && rowPitch % pixelBytes == 0);
1841*8975f5c5SAndroid Build Coastguard Worker 
1842*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedHeight(height);
1843*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1844*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight);
1845*8975f5c5SAndroid Build Coastguard Worker     const GLuint minBlockHeight = getCompressedImageMinBlocks().second;
1846*8975f5c5SAndroid Build Coastguard Worker 
1847*8975f5c5SAndroid Build Coastguard Worker     auto numBlocksHigh = (checkedHeight + checkedBlockHeight - 1u) / checkedBlockHeight;
1848*8975f5c5SAndroid Build Coastguard Worker     if (numBlocksHigh.IsValid() && numBlocksHigh.ValueOrDie() < minBlockHeight)
1849*8975f5c5SAndroid Build Coastguard Worker     {
1850*8975f5c5SAndroid Build Coastguard Worker         numBlocksHigh = minBlockHeight;
1851*8975f5c5SAndroid Build Coastguard Worker     }
1852*8975f5c5SAndroid Build Coastguard Worker     return CheckedMathResult(numBlocksHigh * checkedRowPitch, resultOut);
1853*8975f5c5SAndroid Build Coastguard Worker }
1854*8975f5c5SAndroid Build Coastguard Worker 
computeCompressedImageSize(const Extents & size,GLuint * resultOut) const1855*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computeCompressedImageSize(const Extents &size, GLuint *resultOut) const
1856*8975f5c5SAndroid Build Coastguard Worker {
1857*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedWidth(size.width);
1858*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedHeight(size.height);
1859*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedDepth(size.depth);
1860*8975f5c5SAndroid Build Coastguard Worker 
1861*8975f5c5SAndroid Build Coastguard Worker     if (paletted)
1862*8975f5c5SAndroid Build Coastguard Worker     {
1863*8975f5c5SAndroid Build Coastguard Worker         ASSERT(!compressed);
1864*8975f5c5SAndroid Build Coastguard Worker 
1865*8975f5c5SAndroid Build Coastguard Worker         GLuint paletteSize  = 1 << paletteBits;
1866*8975f5c5SAndroid Build Coastguard Worker         GLuint paletteBytes = paletteSize * pixelBytes;
1867*8975f5c5SAndroid Build Coastguard Worker 
1868*8975f5c5SAndroid Build Coastguard Worker         GLuint rowPitch;
1869*8975f5c5SAndroid Build Coastguard Worker         if (!computePalettedImageRowPitch(size.width, &rowPitch))
1870*8975f5c5SAndroid Build Coastguard Worker         {
1871*8975f5c5SAndroid Build Coastguard Worker             return false;
1872*8975f5c5SAndroid Build Coastguard Worker         }
1873*8975f5c5SAndroid Build Coastguard Worker 
1874*8975f5c5SAndroid Build Coastguard Worker         if (size.depth != 1)
1875*8975f5c5SAndroid Build Coastguard Worker         {
1876*8975f5c5SAndroid Build Coastguard Worker             return false;
1877*8975f5c5SAndroid Build Coastguard Worker         }
1878*8975f5c5SAndroid Build Coastguard Worker 
1879*8975f5c5SAndroid Build Coastguard Worker         CheckedNumeric<GLuint> checkedPaletteBytes(paletteBytes);
1880*8975f5c5SAndroid Build Coastguard Worker         CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1881*8975f5c5SAndroid Build Coastguard Worker 
1882*8975f5c5SAndroid Build Coastguard Worker         return CheckedMathResult(checkedPaletteBytes + checkedRowPitch * checkedHeight, resultOut);
1883*8975f5c5SAndroid Build Coastguard Worker     }
1884*8975f5c5SAndroid Build Coastguard Worker 
1885*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedBlockWidth(compressedBlockWidth);
1886*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight);
1887*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedBlockDepth(compressedBlockDepth);
1888*8975f5c5SAndroid Build Coastguard Worker     GLuint minBlockWidth, minBlockHeight;
1889*8975f5c5SAndroid Build Coastguard Worker     std::tie(minBlockWidth, minBlockHeight) = getCompressedImageMinBlocks();
1890*8975f5c5SAndroid Build Coastguard Worker 
1891*8975f5c5SAndroid Build Coastguard Worker     ASSERT(compressed);
1892*8975f5c5SAndroid Build Coastguard Worker     auto numBlocksWide = (checkedWidth + checkedBlockWidth - 1u) / checkedBlockWidth;
1893*8975f5c5SAndroid Build Coastguard Worker     auto numBlocksHigh = (checkedHeight + checkedBlockHeight - 1u) / checkedBlockHeight;
1894*8975f5c5SAndroid Build Coastguard Worker     auto numBlocksDeep = (checkedDepth + checkedBlockDepth - 1u) / checkedBlockDepth;
1895*8975f5c5SAndroid Build Coastguard Worker     if (numBlocksWide.IsValid() && numBlocksWide.ValueOrDie() < minBlockWidth)
1896*8975f5c5SAndroid Build Coastguard Worker     {
1897*8975f5c5SAndroid Build Coastguard Worker         numBlocksWide = minBlockWidth;
1898*8975f5c5SAndroid Build Coastguard Worker     }
1899*8975f5c5SAndroid Build Coastguard Worker     if (numBlocksHigh.IsValid() && numBlocksHigh.ValueOrDie() < minBlockHeight)
1900*8975f5c5SAndroid Build Coastguard Worker     {
1901*8975f5c5SAndroid Build Coastguard Worker         numBlocksHigh = minBlockHeight;
1902*8975f5c5SAndroid Build Coastguard Worker     }
1903*8975f5c5SAndroid Build Coastguard Worker     auto bytes = numBlocksWide * numBlocksHigh * numBlocksDeep * pixelBytes;
1904*8975f5c5SAndroid Build Coastguard Worker     return CheckedMathResult(bytes, resultOut);
1905*8975f5c5SAndroid Build Coastguard Worker }
1906*8975f5c5SAndroid Build Coastguard Worker 
getCompressedImageMinBlocks() const1907*8975f5c5SAndroid Build Coastguard Worker std::pair<GLuint, GLuint> InternalFormat::getCompressedImageMinBlocks() const
1908*8975f5c5SAndroid Build Coastguard Worker {
1909*8975f5c5SAndroid Build Coastguard Worker     GLuint minBlockWidth  = 0;
1910*8975f5c5SAndroid Build Coastguard Worker     GLuint minBlockHeight = 0;
1911*8975f5c5SAndroid Build Coastguard Worker 
1912*8975f5c5SAndroid Build Coastguard Worker     // Per the specification, a PVRTC block needs information from the 3 nearest blocks.
1913*8975f5c5SAndroid Build Coastguard Worker     // GL_IMG_texture_compression_pvrtc specifies the minimum size requirement in pixels, but
1914*8975f5c5SAndroid Build Coastguard Worker     // ANGLE's texture tables are written in terms of blocks. The 4BPP formats use 4x4 blocks, and
1915*8975f5c5SAndroid Build Coastguard Worker     // the 2BPP formats, 8x4 blocks. Therefore, both kinds of formats require a minimum of 2x2
1916*8975f5c5SAndroid Build Coastguard Worker     // blocks.
1917*8975f5c5SAndroid Build Coastguard Worker     if (IsPVRTC1Format(internalFormat))
1918*8975f5c5SAndroid Build Coastguard Worker     {
1919*8975f5c5SAndroid Build Coastguard Worker         minBlockWidth  = 2;
1920*8975f5c5SAndroid Build Coastguard Worker         minBlockHeight = 2;
1921*8975f5c5SAndroid Build Coastguard Worker     }
1922*8975f5c5SAndroid Build Coastguard Worker 
1923*8975f5c5SAndroid Build Coastguard Worker     return std::make_pair(minBlockWidth, minBlockHeight);
1924*8975f5c5SAndroid Build Coastguard Worker }
1925*8975f5c5SAndroid Build Coastguard Worker 
computeSkipBytes(GLenum formatType,GLuint rowPitch,GLuint depthPitch,const PixelStoreStateBase & state,bool is3D,GLuint * resultOut) const1926*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computeSkipBytes(GLenum formatType,
1927*8975f5c5SAndroid Build Coastguard Worker                                       GLuint rowPitch,
1928*8975f5c5SAndroid Build Coastguard Worker                                       GLuint depthPitch,
1929*8975f5c5SAndroid Build Coastguard Worker                                       const PixelStoreStateBase &state,
1930*8975f5c5SAndroid Build Coastguard Worker                                       bool is3D,
1931*8975f5c5SAndroid Build Coastguard Worker                                       GLuint *resultOut) const
1932*8975f5c5SAndroid Build Coastguard Worker {
1933*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1934*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedDepthPitch(depthPitch);
1935*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedSkipImages(static_cast<GLuint>(state.skipImages));
1936*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedSkipRows(static_cast<GLuint>(state.skipRows));
1937*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedSkipPixels(static_cast<GLuint>(state.skipPixels));
1938*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedPixelBytes(computePixelBytes(formatType));
1939*8975f5c5SAndroid Build Coastguard Worker     auto checkedSkipImagesBytes = checkedSkipImages * checkedDepthPitch;
1940*8975f5c5SAndroid Build Coastguard Worker     if (!is3D)
1941*8975f5c5SAndroid Build Coastguard Worker     {
1942*8975f5c5SAndroid Build Coastguard Worker         checkedSkipImagesBytes = 0;
1943*8975f5c5SAndroid Build Coastguard Worker     }
1944*8975f5c5SAndroid Build Coastguard Worker     auto skipBytes = checkedSkipImagesBytes + checkedSkipRows * checkedRowPitch +
1945*8975f5c5SAndroid Build Coastguard Worker                      checkedSkipPixels * checkedPixelBytes;
1946*8975f5c5SAndroid Build Coastguard Worker     return CheckedMathResult(skipBytes, resultOut);
1947*8975f5c5SAndroid Build Coastguard Worker }
1948*8975f5c5SAndroid Build Coastguard Worker 
computePackUnpackEndByte(GLenum formatType,const Extents & size,const PixelStoreStateBase & state,bool is3D,GLuint * resultOut) const1949*8975f5c5SAndroid Build Coastguard Worker bool InternalFormat::computePackUnpackEndByte(GLenum formatType,
1950*8975f5c5SAndroid Build Coastguard Worker                                               const Extents &size,
1951*8975f5c5SAndroid Build Coastguard Worker                                               const PixelStoreStateBase &state,
1952*8975f5c5SAndroid Build Coastguard Worker                                               bool is3D,
1953*8975f5c5SAndroid Build Coastguard Worker                                               GLuint *resultOut) const
1954*8975f5c5SAndroid Build Coastguard Worker {
1955*8975f5c5SAndroid Build Coastguard Worker     GLuint rowPitch = 0;
1956*8975f5c5SAndroid Build Coastguard Worker     if (!computeRowPitch(formatType, size.width, state.alignment, state.rowLength, &rowPitch))
1957*8975f5c5SAndroid Build Coastguard Worker     {
1958*8975f5c5SAndroid Build Coastguard Worker         return false;
1959*8975f5c5SAndroid Build Coastguard Worker     }
1960*8975f5c5SAndroid Build Coastguard Worker 
1961*8975f5c5SAndroid Build Coastguard Worker     GLuint depthPitch = 0;
1962*8975f5c5SAndroid Build Coastguard Worker     if (is3D && !computeDepthPitch(size.height, state.imageHeight, rowPitch, &depthPitch))
1963*8975f5c5SAndroid Build Coastguard Worker     {
1964*8975f5c5SAndroid Build Coastguard Worker         return false;
1965*8975f5c5SAndroid Build Coastguard Worker     }
1966*8975f5c5SAndroid Build Coastguard Worker 
1967*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> checkedCopyBytes(0);
1968*8975f5c5SAndroid Build Coastguard Worker     if (compressed)
1969*8975f5c5SAndroid Build Coastguard Worker     {
1970*8975f5c5SAndroid Build Coastguard Worker         GLuint copyBytes = 0;
1971*8975f5c5SAndroid Build Coastguard Worker         if (!computeCompressedImageSize(size, &copyBytes))
1972*8975f5c5SAndroid Build Coastguard Worker         {
1973*8975f5c5SAndroid Build Coastguard Worker             return false;
1974*8975f5c5SAndroid Build Coastguard Worker         }
1975*8975f5c5SAndroid Build Coastguard Worker         checkedCopyBytes = copyBytes;
1976*8975f5c5SAndroid Build Coastguard Worker     }
1977*8975f5c5SAndroid Build Coastguard Worker     else if (size.height != 0 && (!is3D || size.depth != 0))
1978*8975f5c5SAndroid Build Coastguard Worker     {
1979*8975f5c5SAndroid Build Coastguard Worker         CheckedNumeric<GLuint> bytes = computePixelBytes(formatType);
1980*8975f5c5SAndroid Build Coastguard Worker         checkedCopyBytes += size.width * bytes;
1981*8975f5c5SAndroid Build Coastguard Worker 
1982*8975f5c5SAndroid Build Coastguard Worker         CheckedNumeric<GLuint> heightMinusOne = size.height - 1;
1983*8975f5c5SAndroid Build Coastguard Worker         checkedCopyBytes += heightMinusOne * rowPitch;
1984*8975f5c5SAndroid Build Coastguard Worker 
1985*8975f5c5SAndroid Build Coastguard Worker         if (is3D)
1986*8975f5c5SAndroid Build Coastguard Worker         {
1987*8975f5c5SAndroid Build Coastguard Worker             CheckedNumeric<GLuint> depthMinusOne = size.depth - 1;
1988*8975f5c5SAndroid Build Coastguard Worker             checkedCopyBytes += depthMinusOne * depthPitch;
1989*8975f5c5SAndroid Build Coastguard Worker         }
1990*8975f5c5SAndroid Build Coastguard Worker     }
1991*8975f5c5SAndroid Build Coastguard Worker 
1992*8975f5c5SAndroid Build Coastguard Worker     GLuint skipBytes = 0;
1993*8975f5c5SAndroid Build Coastguard Worker     if (!computeSkipBytes(formatType, rowPitch, depthPitch, state, is3D, &skipBytes))
1994*8975f5c5SAndroid Build Coastguard Worker     {
1995*8975f5c5SAndroid Build Coastguard Worker         return false;
1996*8975f5c5SAndroid Build Coastguard Worker     }
1997*8975f5c5SAndroid Build Coastguard Worker 
1998*8975f5c5SAndroid Build Coastguard Worker     CheckedNumeric<GLuint> endByte = checkedCopyBytes + CheckedNumeric<GLuint>(skipBytes);
1999*8975f5c5SAndroid Build Coastguard Worker 
2000*8975f5c5SAndroid Build Coastguard Worker     return CheckedMathResult(endByte, resultOut);
2001*8975f5c5SAndroid Build Coastguard Worker }
2002*8975f5c5SAndroid Build Coastguard Worker 
GetUnsizedFormat(GLenum internalFormat)2003*8975f5c5SAndroid Build Coastguard Worker GLenum GetUnsizedFormat(GLenum internalFormat)
2004*8975f5c5SAndroid Build Coastguard Worker {
2005*8975f5c5SAndroid Build Coastguard Worker     auto sizedFormatInfo = GetSizedInternalFormatInfo(internalFormat);
2006*8975f5c5SAndroid Build Coastguard Worker     if (sizedFormatInfo.internalFormat != GL_NONE)
2007*8975f5c5SAndroid Build Coastguard Worker     {
2008*8975f5c5SAndroid Build Coastguard Worker         return sizedFormatInfo.format;
2009*8975f5c5SAndroid Build Coastguard Worker     }
2010*8975f5c5SAndroid Build Coastguard Worker 
2011*8975f5c5SAndroid Build Coastguard Worker     return internalFormat;
2012*8975f5c5SAndroid Build Coastguard Worker }
2013*8975f5c5SAndroid Build Coastguard Worker 
CompressedFormatRequiresWholeImage(GLenum internalFormat)2014*8975f5c5SAndroid Build Coastguard Worker bool CompressedFormatRequiresWholeImage(GLenum internalFormat)
2015*8975f5c5SAndroid Build Coastguard Worker {
2016*8975f5c5SAndroid Build Coastguard Worker     // List of compressed texture format that require that the sub-image size is equal to texture's
2017*8975f5c5SAndroid Build Coastguard Worker     // respective mip level's size
2018*8975f5c5SAndroid Build Coastguard Worker     return IsPVRTC1Format(internalFormat);
2019*8975f5c5SAndroid Build Coastguard Worker }
2020*8975f5c5SAndroid Build Coastguard Worker 
MaybeOverrideLuminance(GLenum & format,GLenum & type,GLenum actualFormat,GLenum actualType)2021*8975f5c5SAndroid Build Coastguard Worker void MaybeOverrideLuminance(GLenum &format, GLenum &type, GLenum actualFormat, GLenum actualType)
2022*8975f5c5SAndroid Build Coastguard Worker {
2023*8975f5c5SAndroid Build Coastguard Worker     gl::InternalFormat internalFormat = gl::GetInternalFormatInfo(format, type);
2024*8975f5c5SAndroid Build Coastguard Worker     if (internalFormat.isLUMA())
2025*8975f5c5SAndroid Build Coastguard Worker     {
2026*8975f5c5SAndroid Build Coastguard Worker         // Ensure the format and type are compatible
2027*8975f5c5SAndroid Build Coastguard Worker         ASSERT(internalFormat.pixelBytes ==
2028*8975f5c5SAndroid Build Coastguard Worker                gl::GetInternalFormatInfo(actualFormat, actualType).pixelBytes);
2029*8975f5c5SAndroid Build Coastguard Worker 
2030*8975f5c5SAndroid Build Coastguard Worker         // For Luminance formats, override with the internal format. Since this is not
2031*8975f5c5SAndroid Build Coastguard Worker         // renderable, our pixel pack routines don't handle it correctly.
2032*8975f5c5SAndroid Build Coastguard Worker         format = actualFormat;
2033*8975f5c5SAndroid Build Coastguard Worker         type   = actualType;
2034*8975f5c5SAndroid Build Coastguard Worker     }
2035*8975f5c5SAndroid Build Coastguard Worker }
2036*8975f5c5SAndroid Build Coastguard Worker 
GetAllSizedInternalFormats()2037*8975f5c5SAndroid Build Coastguard Worker const FormatSet &GetAllSizedInternalFormats()
2038*8975f5c5SAndroid Build Coastguard Worker {
2039*8975f5c5SAndroid Build Coastguard Worker     static angle::base::NoDestructor<FormatSet> formatSet(BuildAllSizedInternalFormatSet());
2040*8975f5c5SAndroid Build Coastguard Worker     return *formatSet;
2041*8975f5c5SAndroid Build Coastguard Worker }
2042*8975f5c5SAndroid Build Coastguard Worker 
GetAttributeType(GLenum enumValue)2043*8975f5c5SAndroid Build Coastguard Worker AttributeType GetAttributeType(GLenum enumValue)
2044*8975f5c5SAndroid Build Coastguard Worker {
2045*8975f5c5SAndroid Build Coastguard Worker     switch (enumValue)
2046*8975f5c5SAndroid Build Coastguard Worker     {
2047*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT:
2048*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_FLOAT;
2049*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_VEC2:
2050*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_VEC2;
2051*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_VEC3:
2052*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_VEC3;
2053*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_VEC4:
2054*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_VEC4;
2055*8975f5c5SAndroid Build Coastguard Worker         case GL_INT:
2056*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_INT;
2057*8975f5c5SAndroid Build Coastguard Worker         case GL_INT_VEC2:
2058*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_IVEC2;
2059*8975f5c5SAndroid Build Coastguard Worker         case GL_INT_VEC3:
2060*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_IVEC3;
2061*8975f5c5SAndroid Build Coastguard Worker         case GL_INT_VEC4:
2062*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_IVEC4;
2063*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT:
2064*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_UINT;
2065*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT_VEC2:
2066*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_UVEC2;
2067*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT_VEC3:
2068*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_UVEC3;
2069*8975f5c5SAndroid Build Coastguard Worker         case GL_UNSIGNED_INT_VEC4:
2070*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_UVEC4;
2071*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_MAT2:
2072*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_MAT2;
2073*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_MAT3:
2074*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_MAT3;
2075*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_MAT4:
2076*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_MAT4;
2077*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_MAT2x3:
2078*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_MAT2x3;
2079*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_MAT2x4:
2080*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_MAT2x4;
2081*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_MAT3x2:
2082*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_MAT3x2;
2083*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_MAT3x4:
2084*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_MAT3x4;
2085*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_MAT4x2:
2086*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_MAT4x2;
2087*8975f5c5SAndroid Build Coastguard Worker         case GL_FLOAT_MAT4x3:
2088*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_MAT4x3;
2089*8975f5c5SAndroid Build Coastguard Worker         default:
2090*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
2091*8975f5c5SAndroid Build Coastguard Worker             return ATTRIBUTE_FLOAT;
2092*8975f5c5SAndroid Build Coastguard Worker     }
2093*8975f5c5SAndroid Build Coastguard Worker }
2094*8975f5c5SAndroid Build Coastguard Worker 
GetVertexFormatID(VertexAttribType type,GLboolean normalized,GLuint components,bool pureInteger)2095*8975f5c5SAndroid Build Coastguard Worker angle::FormatID GetVertexFormatID(VertexAttribType type,
2096*8975f5c5SAndroid Build Coastguard Worker                                   GLboolean normalized,
2097*8975f5c5SAndroid Build Coastguard Worker                                   GLuint components,
2098*8975f5c5SAndroid Build Coastguard Worker                                   bool pureInteger)
2099*8975f5c5SAndroid Build Coastguard Worker {
2100*8975f5c5SAndroid Build Coastguard Worker     switch (type)
2101*8975f5c5SAndroid Build Coastguard Worker     {
2102*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::Byte:
2103*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2104*8975f5c5SAndroid Build Coastguard Worker             {
2105*8975f5c5SAndroid Build Coastguard Worker                 case 1:
2106*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2107*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8_SINT;
2108*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2109*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8_SNORM;
2110*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R8_SSCALED;
2111*8975f5c5SAndroid Build Coastguard Worker                 case 2:
2112*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2113*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8_SINT;
2114*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2115*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8_SNORM;
2116*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R8G8_SSCALED;
2117*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2118*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2119*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8B8_SINT;
2120*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2121*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8B8_SNORM;
2122*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R8G8B8_SSCALED;
2123*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2124*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2125*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8B8A8_SINT;
2126*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2127*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8B8A8_SNORM;
2128*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R8G8B8A8_SSCALED;
2129*8975f5c5SAndroid Build Coastguard Worker                 default:
2130*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2131*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2132*8975f5c5SAndroid Build Coastguard Worker             }
2133*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::UnsignedByte:
2134*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2135*8975f5c5SAndroid Build Coastguard Worker             {
2136*8975f5c5SAndroid Build Coastguard Worker                 case 1:
2137*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2138*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8_UINT;
2139*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2140*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8_UNORM;
2141*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R8_USCALED;
2142*8975f5c5SAndroid Build Coastguard Worker                 case 2:
2143*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2144*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8_UINT;
2145*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2146*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8_UNORM;
2147*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R8G8_USCALED;
2148*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2149*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2150*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8B8_UINT;
2151*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2152*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8B8_UNORM;
2153*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R8G8B8_USCALED;
2154*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2155*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2156*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8B8A8_UINT;
2157*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2158*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R8G8B8A8_UNORM;
2159*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R8G8B8A8_USCALED;
2160*8975f5c5SAndroid Build Coastguard Worker                 default:
2161*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2162*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2163*8975f5c5SAndroid Build Coastguard Worker             }
2164*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::Short:
2165*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2166*8975f5c5SAndroid Build Coastguard Worker             {
2167*8975f5c5SAndroid Build Coastguard Worker                 case 1:
2168*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2169*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16_SINT;
2170*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2171*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16_SNORM;
2172*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16_SSCALED;
2173*8975f5c5SAndroid Build Coastguard Worker                 case 2:
2174*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2175*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16_SINT;
2176*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2177*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16_SNORM;
2178*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16G16_SSCALED;
2179*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2180*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2181*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16B16_SINT;
2182*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2183*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16B16_SNORM;
2184*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16G16B16_SSCALED;
2185*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2186*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2187*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16B16A16_SINT;
2188*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2189*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16B16A16_SNORM;
2190*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16G16B16A16_SSCALED;
2191*8975f5c5SAndroid Build Coastguard Worker                 default:
2192*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2193*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2194*8975f5c5SAndroid Build Coastguard Worker             }
2195*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::UnsignedShort:
2196*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2197*8975f5c5SAndroid Build Coastguard Worker             {
2198*8975f5c5SAndroid Build Coastguard Worker                 case 1:
2199*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2200*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16_UINT;
2201*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2202*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16_UNORM;
2203*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16_USCALED;
2204*8975f5c5SAndroid Build Coastguard Worker                 case 2:
2205*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2206*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16_UINT;
2207*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2208*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16_UNORM;
2209*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16G16_USCALED;
2210*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2211*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2212*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16B16_UINT;
2213*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2214*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16B16_UNORM;
2215*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16G16B16_USCALED;
2216*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2217*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2218*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16B16A16_UINT;
2219*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2220*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R16G16B16A16_UNORM;
2221*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16G16B16A16_USCALED;
2222*8975f5c5SAndroid Build Coastguard Worker                 default:
2223*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2224*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2225*8975f5c5SAndroid Build Coastguard Worker             }
2226*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::Int:
2227*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2228*8975f5c5SAndroid Build Coastguard Worker             {
2229*8975f5c5SAndroid Build Coastguard Worker                 case 1:
2230*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2231*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32_SINT;
2232*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2233*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32_SNORM;
2234*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32_SSCALED;
2235*8975f5c5SAndroid Build Coastguard Worker                 case 2:
2236*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2237*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32_SINT;
2238*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2239*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32_SNORM;
2240*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32_SSCALED;
2241*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2242*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2243*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32B32_SINT;
2244*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2245*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32B32_SNORM;
2246*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32B32_SSCALED;
2247*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2248*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2249*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32B32A32_SINT;
2250*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2251*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32B32A32_SNORM;
2252*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32B32A32_SSCALED;
2253*8975f5c5SAndroid Build Coastguard Worker                 default:
2254*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2255*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2256*8975f5c5SAndroid Build Coastguard Worker             }
2257*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::UnsignedInt:
2258*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2259*8975f5c5SAndroid Build Coastguard Worker             {
2260*8975f5c5SAndroid Build Coastguard Worker                 case 1:
2261*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2262*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32_UINT;
2263*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2264*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32_UNORM;
2265*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32_USCALED;
2266*8975f5c5SAndroid Build Coastguard Worker                 case 2:
2267*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2268*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32_UINT;
2269*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2270*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32_UNORM;
2271*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32_USCALED;
2272*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2273*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2274*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32B32_UINT;
2275*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2276*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32B32_UNORM;
2277*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32B32_USCALED;
2278*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2279*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2280*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32B32A32_UINT;
2281*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2282*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::R32G32B32A32_UNORM;
2283*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32B32A32_USCALED;
2284*8975f5c5SAndroid Build Coastguard Worker                 default:
2285*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2286*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2287*8975f5c5SAndroid Build Coastguard Worker             }
2288*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::Float:
2289*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2290*8975f5c5SAndroid Build Coastguard Worker             {
2291*8975f5c5SAndroid Build Coastguard Worker                 case 1:
2292*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32_FLOAT;
2293*8975f5c5SAndroid Build Coastguard Worker                 case 2:
2294*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32_FLOAT;
2295*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2296*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32B32_FLOAT;
2297*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2298*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32B32A32_FLOAT;
2299*8975f5c5SAndroid Build Coastguard Worker                 default:
2300*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2301*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2302*8975f5c5SAndroid Build Coastguard Worker             }
2303*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::HalfFloat:
2304*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::HalfFloatOES:
2305*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2306*8975f5c5SAndroid Build Coastguard Worker             {
2307*8975f5c5SAndroid Build Coastguard Worker                 case 1:
2308*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16_FLOAT;
2309*8975f5c5SAndroid Build Coastguard Worker                 case 2:
2310*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16G16_FLOAT;
2311*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2312*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16G16B16_FLOAT;
2313*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2314*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R16G16B16A16_FLOAT;
2315*8975f5c5SAndroid Build Coastguard Worker                 default:
2316*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2317*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2318*8975f5c5SAndroid Build Coastguard Worker             }
2319*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::Fixed:
2320*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2321*8975f5c5SAndroid Build Coastguard Worker             {
2322*8975f5c5SAndroid Build Coastguard Worker                 case 1:
2323*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32_FIXED;
2324*8975f5c5SAndroid Build Coastguard Worker                 case 2:
2325*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32_FIXED;
2326*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2327*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32B32_FIXED;
2328*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2329*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::R32G32B32A32_FIXED;
2330*8975f5c5SAndroid Build Coastguard Worker                 default:
2331*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2332*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2333*8975f5c5SAndroid Build Coastguard Worker             }
2334*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::Int2101010:
2335*8975f5c5SAndroid Build Coastguard Worker             if (pureInteger)
2336*8975f5c5SAndroid Build Coastguard Worker                 return angle::FormatID::R10G10B10A2_SINT;
2337*8975f5c5SAndroid Build Coastguard Worker             if (normalized)
2338*8975f5c5SAndroid Build Coastguard Worker                 return angle::FormatID::R10G10B10A2_SNORM;
2339*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R10G10B10A2_SSCALED;
2340*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::UnsignedInt2101010:
2341*8975f5c5SAndroid Build Coastguard Worker             if (pureInteger)
2342*8975f5c5SAndroid Build Coastguard Worker                 return angle::FormatID::R10G10B10A2_UINT;
2343*8975f5c5SAndroid Build Coastguard Worker             if (normalized)
2344*8975f5c5SAndroid Build Coastguard Worker                 return angle::FormatID::R10G10B10A2_UNORM;
2345*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R10G10B10A2_USCALED;
2346*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::Int1010102:
2347*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2348*8975f5c5SAndroid Build Coastguard Worker             {
2349*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2350*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2351*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::X2R10G10B10_SINT_VERTEX;
2352*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2353*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::X2R10G10B10_SNORM_VERTEX;
2354*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::X2R10G10B10_SSCALED_VERTEX;
2355*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2356*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2357*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::A2R10G10B10_SINT_VERTEX;
2358*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2359*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::A2R10G10B10_SNORM_VERTEX;
2360*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::A2R10G10B10_SSCALED_VERTEX;
2361*8975f5c5SAndroid Build Coastguard Worker                 default:
2362*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2363*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2364*8975f5c5SAndroid Build Coastguard Worker             }
2365*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::UnsignedInt1010102:
2366*8975f5c5SAndroid Build Coastguard Worker             switch (components)
2367*8975f5c5SAndroid Build Coastguard Worker             {
2368*8975f5c5SAndroid Build Coastguard Worker                 case 3:
2369*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2370*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::X2R10G10B10_UINT_VERTEX;
2371*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2372*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::X2R10G10B10_UNORM_VERTEX;
2373*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::X2R10G10B10_USCALED_VERTEX;
2374*8975f5c5SAndroid Build Coastguard Worker 
2375*8975f5c5SAndroid Build Coastguard Worker                 case 4:
2376*8975f5c5SAndroid Build Coastguard Worker                     if (pureInteger)
2377*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::A2R10G10B10_UINT_VERTEX;
2378*8975f5c5SAndroid Build Coastguard Worker                     if (normalized)
2379*8975f5c5SAndroid Build Coastguard Worker                         return angle::FormatID::A2R10G10B10_UNORM_VERTEX;
2380*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::A2R10G10B10_USCALED_VERTEX;
2381*8975f5c5SAndroid Build Coastguard Worker                 default:
2382*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
2383*8975f5c5SAndroid Build Coastguard Worker                     return angle::FormatID::NONE;
2384*8975f5c5SAndroid Build Coastguard Worker             }
2385*8975f5c5SAndroid Build Coastguard Worker         default:
2386*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
2387*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::NONE;
2388*8975f5c5SAndroid Build Coastguard Worker     }
2389*8975f5c5SAndroid Build Coastguard Worker }
2390*8975f5c5SAndroid Build Coastguard Worker 
GetVertexFormatID(const VertexAttribute & attrib,VertexAttribType currentValueType)2391*8975f5c5SAndroid Build Coastguard Worker angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribType currentValueType)
2392*8975f5c5SAndroid Build Coastguard Worker {
2393*8975f5c5SAndroid Build Coastguard Worker     if (!attrib.enabled)
2394*8975f5c5SAndroid Build Coastguard Worker     {
2395*8975f5c5SAndroid Build Coastguard Worker         return GetCurrentValueFormatID(currentValueType);
2396*8975f5c5SAndroid Build Coastguard Worker     }
2397*8975f5c5SAndroid Build Coastguard Worker     return attrib.format->id;
2398*8975f5c5SAndroid Build Coastguard Worker }
2399*8975f5c5SAndroid Build Coastguard Worker 
GetCurrentValueFormatID(VertexAttribType currentValueType)2400*8975f5c5SAndroid Build Coastguard Worker angle::FormatID GetCurrentValueFormatID(VertexAttribType currentValueType)
2401*8975f5c5SAndroid Build Coastguard Worker {
2402*8975f5c5SAndroid Build Coastguard Worker     switch (currentValueType)
2403*8975f5c5SAndroid Build Coastguard Worker     {
2404*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::Float:
2405*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32A32_FLOAT;
2406*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::Int:
2407*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32A32_SINT;
2408*8975f5c5SAndroid Build Coastguard Worker         case VertexAttribType::UnsignedInt:
2409*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32A32_UINT;
2410*8975f5c5SAndroid Build Coastguard Worker         default:
2411*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
2412*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::NONE;
2413*8975f5c5SAndroid Build Coastguard Worker     }
2414*8975f5c5SAndroid Build Coastguard Worker }
2415*8975f5c5SAndroid Build Coastguard Worker 
GetVertexFormatFromID(angle::FormatID vertexFormatID)2416*8975f5c5SAndroid Build Coastguard Worker const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID)
2417*8975f5c5SAndroid Build Coastguard Worker {
2418*8975f5c5SAndroid Build Coastguard Worker     switch (vertexFormatID)
2419*8975f5c5SAndroid Build Coastguard Worker     {
2420*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_SSCALED:
2421*8975f5c5SAndroid Build Coastguard Worker         {
2422*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_FALSE, 1, false);
2423*8975f5c5SAndroid Build Coastguard Worker             return format;
2424*8975f5c5SAndroid Build Coastguard Worker         }
2425*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_SNORM:
2426*8975f5c5SAndroid Build Coastguard Worker         {
2427*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_TRUE, 1, false);
2428*8975f5c5SAndroid Build Coastguard Worker             return format;
2429*8975f5c5SAndroid Build Coastguard Worker         }
2430*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_SSCALED:
2431*8975f5c5SAndroid Build Coastguard Worker         {
2432*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_FALSE, 2, false);
2433*8975f5c5SAndroid Build Coastguard Worker             return format;
2434*8975f5c5SAndroid Build Coastguard Worker         }
2435*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_SNORM:
2436*8975f5c5SAndroid Build Coastguard Worker         {
2437*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_TRUE, 2, false);
2438*8975f5c5SAndroid Build Coastguard Worker             return format;
2439*8975f5c5SAndroid Build Coastguard Worker         }
2440*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_SSCALED:
2441*8975f5c5SAndroid Build Coastguard Worker         {
2442*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_FALSE, 3, false);
2443*8975f5c5SAndroid Build Coastguard Worker             return format;
2444*8975f5c5SAndroid Build Coastguard Worker         }
2445*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_SNORM:
2446*8975f5c5SAndroid Build Coastguard Worker         {
2447*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_TRUE, 3, false);
2448*8975f5c5SAndroid Build Coastguard Worker             return format;
2449*8975f5c5SAndroid Build Coastguard Worker         }
2450*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_SSCALED:
2451*8975f5c5SAndroid Build Coastguard Worker         {
2452*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_FALSE, 4, false);
2453*8975f5c5SAndroid Build Coastguard Worker             return format;
2454*8975f5c5SAndroid Build Coastguard Worker         }
2455*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_SNORM:
2456*8975f5c5SAndroid Build Coastguard Worker         {
2457*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_TRUE, 4, false);
2458*8975f5c5SAndroid Build Coastguard Worker             return format;
2459*8975f5c5SAndroid Build Coastguard Worker         }
2460*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_USCALED:
2461*8975f5c5SAndroid Build Coastguard Worker         {
2462*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, false);
2463*8975f5c5SAndroid Build Coastguard Worker             return format;
2464*8975f5c5SAndroid Build Coastguard Worker         }
2465*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_UNORM:
2466*8975f5c5SAndroid Build Coastguard Worker         {
2467*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 1, false);
2468*8975f5c5SAndroid Build Coastguard Worker             return format;
2469*8975f5c5SAndroid Build Coastguard Worker         }
2470*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_USCALED:
2471*8975f5c5SAndroid Build Coastguard Worker         {
2472*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, false);
2473*8975f5c5SAndroid Build Coastguard Worker             return format;
2474*8975f5c5SAndroid Build Coastguard Worker         }
2475*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_UNORM:
2476*8975f5c5SAndroid Build Coastguard Worker         {
2477*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 2, false);
2478*8975f5c5SAndroid Build Coastguard Worker             return format;
2479*8975f5c5SAndroid Build Coastguard Worker         }
2480*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_USCALED:
2481*8975f5c5SAndroid Build Coastguard Worker         {
2482*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, false);
2483*8975f5c5SAndroid Build Coastguard Worker             return format;
2484*8975f5c5SAndroid Build Coastguard Worker         }
2485*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_UNORM:
2486*8975f5c5SAndroid Build Coastguard Worker         {
2487*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 3, false);
2488*8975f5c5SAndroid Build Coastguard Worker             return format;
2489*8975f5c5SAndroid Build Coastguard Worker         }
2490*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_USCALED:
2491*8975f5c5SAndroid Build Coastguard Worker         {
2492*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, false);
2493*8975f5c5SAndroid Build Coastguard Worker             return format;
2494*8975f5c5SAndroid Build Coastguard Worker         }
2495*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_UNORM:
2496*8975f5c5SAndroid Build Coastguard Worker         {
2497*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 4, false);
2498*8975f5c5SAndroid Build Coastguard Worker             return format;
2499*8975f5c5SAndroid Build Coastguard Worker         }
2500*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_SSCALED:
2501*8975f5c5SAndroid Build Coastguard Worker         {
2502*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_FALSE, 1, false);
2503*8975f5c5SAndroid Build Coastguard Worker             return format;
2504*8975f5c5SAndroid Build Coastguard Worker         }
2505*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_SNORM:
2506*8975f5c5SAndroid Build Coastguard Worker         {
2507*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_TRUE, 1, false);
2508*8975f5c5SAndroid Build Coastguard Worker             return format;
2509*8975f5c5SAndroid Build Coastguard Worker         }
2510*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_SSCALED:
2511*8975f5c5SAndroid Build Coastguard Worker         {
2512*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_FALSE, 2, false);
2513*8975f5c5SAndroid Build Coastguard Worker             return format;
2514*8975f5c5SAndroid Build Coastguard Worker         }
2515*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_SNORM:
2516*8975f5c5SAndroid Build Coastguard Worker         {
2517*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_TRUE, 2, false);
2518*8975f5c5SAndroid Build Coastguard Worker             return format;
2519*8975f5c5SAndroid Build Coastguard Worker         }
2520*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_SSCALED:
2521*8975f5c5SAndroid Build Coastguard Worker         {
2522*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_FALSE, 3, false);
2523*8975f5c5SAndroid Build Coastguard Worker             return format;
2524*8975f5c5SAndroid Build Coastguard Worker         }
2525*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_SNORM:
2526*8975f5c5SAndroid Build Coastguard Worker         {
2527*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_TRUE, 3, false);
2528*8975f5c5SAndroid Build Coastguard Worker             return format;
2529*8975f5c5SAndroid Build Coastguard Worker         }
2530*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_SSCALED:
2531*8975f5c5SAndroid Build Coastguard Worker         {
2532*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_FALSE, 4, false);
2533*8975f5c5SAndroid Build Coastguard Worker             return format;
2534*8975f5c5SAndroid Build Coastguard Worker         }
2535*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_SNORM:
2536*8975f5c5SAndroid Build Coastguard Worker         {
2537*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_TRUE, 4, false);
2538*8975f5c5SAndroid Build Coastguard Worker             return format;
2539*8975f5c5SAndroid Build Coastguard Worker         }
2540*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_USCALED:
2541*8975f5c5SAndroid Build Coastguard Worker         {
2542*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, false);
2543*8975f5c5SAndroid Build Coastguard Worker             return format;
2544*8975f5c5SAndroid Build Coastguard Worker         }
2545*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_UNORM:
2546*8975f5c5SAndroid Build Coastguard Worker         {
2547*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 1, false);
2548*8975f5c5SAndroid Build Coastguard Worker             return format;
2549*8975f5c5SAndroid Build Coastguard Worker         }
2550*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_USCALED:
2551*8975f5c5SAndroid Build Coastguard Worker         {
2552*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, false);
2553*8975f5c5SAndroid Build Coastguard Worker             return format;
2554*8975f5c5SAndroid Build Coastguard Worker         }
2555*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_UNORM:
2556*8975f5c5SAndroid Build Coastguard Worker         {
2557*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 2, false);
2558*8975f5c5SAndroid Build Coastguard Worker             return format;
2559*8975f5c5SAndroid Build Coastguard Worker         }
2560*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_USCALED:
2561*8975f5c5SAndroid Build Coastguard Worker         {
2562*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, false);
2563*8975f5c5SAndroid Build Coastguard Worker             return format;
2564*8975f5c5SAndroid Build Coastguard Worker         }
2565*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_UNORM:
2566*8975f5c5SAndroid Build Coastguard Worker         {
2567*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 3, false);
2568*8975f5c5SAndroid Build Coastguard Worker             return format;
2569*8975f5c5SAndroid Build Coastguard Worker         }
2570*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_USCALED:
2571*8975f5c5SAndroid Build Coastguard Worker         {
2572*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, false);
2573*8975f5c5SAndroid Build Coastguard Worker             return format;
2574*8975f5c5SAndroid Build Coastguard Worker         }
2575*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_UNORM:
2576*8975f5c5SAndroid Build Coastguard Worker         {
2577*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 4, false);
2578*8975f5c5SAndroid Build Coastguard Worker             return format;
2579*8975f5c5SAndroid Build Coastguard Worker         }
2580*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_SSCALED:
2581*8975f5c5SAndroid Build Coastguard Worker         {
2582*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_FALSE, 1, false);
2583*8975f5c5SAndroid Build Coastguard Worker             return format;
2584*8975f5c5SAndroid Build Coastguard Worker         }
2585*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_SNORM:
2586*8975f5c5SAndroid Build Coastguard Worker         {
2587*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_TRUE, 1, false);
2588*8975f5c5SAndroid Build Coastguard Worker             return format;
2589*8975f5c5SAndroid Build Coastguard Worker         }
2590*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_SSCALED:
2591*8975f5c5SAndroid Build Coastguard Worker         {
2592*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_FALSE, 2, false);
2593*8975f5c5SAndroid Build Coastguard Worker             return format;
2594*8975f5c5SAndroid Build Coastguard Worker         }
2595*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_SNORM:
2596*8975f5c5SAndroid Build Coastguard Worker         {
2597*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_TRUE, 2, false);
2598*8975f5c5SAndroid Build Coastguard Worker             return format;
2599*8975f5c5SAndroid Build Coastguard Worker         }
2600*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_SSCALED:
2601*8975f5c5SAndroid Build Coastguard Worker         {
2602*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_FALSE, 3, false);
2603*8975f5c5SAndroid Build Coastguard Worker             return format;
2604*8975f5c5SAndroid Build Coastguard Worker         }
2605*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_SNORM:
2606*8975f5c5SAndroid Build Coastguard Worker         {
2607*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_TRUE, 3, false);
2608*8975f5c5SAndroid Build Coastguard Worker             return format;
2609*8975f5c5SAndroid Build Coastguard Worker         }
2610*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_SSCALED:
2611*8975f5c5SAndroid Build Coastguard Worker         {
2612*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_FALSE, 4, false);
2613*8975f5c5SAndroid Build Coastguard Worker             return format;
2614*8975f5c5SAndroid Build Coastguard Worker         }
2615*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_SNORM:
2616*8975f5c5SAndroid Build Coastguard Worker         {
2617*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_TRUE, 4, false);
2618*8975f5c5SAndroid Build Coastguard Worker             return format;
2619*8975f5c5SAndroid Build Coastguard Worker         }
2620*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_USCALED:
2621*8975f5c5SAndroid Build Coastguard Worker         {
2622*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, false);
2623*8975f5c5SAndroid Build Coastguard Worker             return format;
2624*8975f5c5SAndroid Build Coastguard Worker         }
2625*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_UNORM:
2626*8975f5c5SAndroid Build Coastguard Worker         {
2627*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 1, false);
2628*8975f5c5SAndroid Build Coastguard Worker             return format;
2629*8975f5c5SAndroid Build Coastguard Worker         }
2630*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_USCALED:
2631*8975f5c5SAndroid Build Coastguard Worker         {
2632*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, false);
2633*8975f5c5SAndroid Build Coastguard Worker             return format;
2634*8975f5c5SAndroid Build Coastguard Worker         }
2635*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_UNORM:
2636*8975f5c5SAndroid Build Coastguard Worker         {
2637*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 2, false);
2638*8975f5c5SAndroid Build Coastguard Worker             return format;
2639*8975f5c5SAndroid Build Coastguard Worker         }
2640*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_USCALED:
2641*8975f5c5SAndroid Build Coastguard Worker         {
2642*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, false);
2643*8975f5c5SAndroid Build Coastguard Worker             return format;
2644*8975f5c5SAndroid Build Coastguard Worker         }
2645*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_UNORM:
2646*8975f5c5SAndroid Build Coastguard Worker         {
2647*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 3, false);
2648*8975f5c5SAndroid Build Coastguard Worker             return format;
2649*8975f5c5SAndroid Build Coastguard Worker         }
2650*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_USCALED:
2651*8975f5c5SAndroid Build Coastguard Worker         {
2652*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, false);
2653*8975f5c5SAndroid Build Coastguard Worker             return format;
2654*8975f5c5SAndroid Build Coastguard Worker         }
2655*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_UNORM:
2656*8975f5c5SAndroid Build Coastguard Worker         {
2657*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 4, false);
2658*8975f5c5SAndroid Build Coastguard Worker             return format;
2659*8975f5c5SAndroid Build Coastguard Worker         }
2660*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_SINT:
2661*8975f5c5SAndroid Build Coastguard Worker         {
2662*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_FALSE, 1, true);
2663*8975f5c5SAndroid Build Coastguard Worker             return format;
2664*8975f5c5SAndroid Build Coastguard Worker         }
2665*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_SINT:
2666*8975f5c5SAndroid Build Coastguard Worker         {
2667*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_FALSE, 2, true);
2668*8975f5c5SAndroid Build Coastguard Worker             return format;
2669*8975f5c5SAndroid Build Coastguard Worker         }
2670*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_SINT:
2671*8975f5c5SAndroid Build Coastguard Worker         {
2672*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_FALSE, 3, true);
2673*8975f5c5SAndroid Build Coastguard Worker             return format;
2674*8975f5c5SAndroid Build Coastguard Worker         }
2675*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_SINT:
2676*8975f5c5SAndroid Build Coastguard Worker         {
2677*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_BYTE, GL_FALSE, 4, true);
2678*8975f5c5SAndroid Build Coastguard Worker             return format;
2679*8975f5c5SAndroid Build Coastguard Worker         }
2680*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_UINT:
2681*8975f5c5SAndroid Build Coastguard Worker         {
2682*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, true);
2683*8975f5c5SAndroid Build Coastguard Worker             return format;
2684*8975f5c5SAndroid Build Coastguard Worker         }
2685*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_UINT:
2686*8975f5c5SAndroid Build Coastguard Worker         {
2687*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, true);
2688*8975f5c5SAndroid Build Coastguard Worker             return format;
2689*8975f5c5SAndroid Build Coastguard Worker         }
2690*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_UINT:
2691*8975f5c5SAndroid Build Coastguard Worker         {
2692*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, true);
2693*8975f5c5SAndroid Build Coastguard Worker             return format;
2694*8975f5c5SAndroid Build Coastguard Worker         }
2695*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_UINT:
2696*8975f5c5SAndroid Build Coastguard Worker         {
2697*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, true);
2698*8975f5c5SAndroid Build Coastguard Worker             return format;
2699*8975f5c5SAndroid Build Coastguard Worker         }
2700*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_SINT:
2701*8975f5c5SAndroid Build Coastguard Worker         {
2702*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_FALSE, 1, true);
2703*8975f5c5SAndroid Build Coastguard Worker             return format;
2704*8975f5c5SAndroid Build Coastguard Worker         }
2705*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_SINT:
2706*8975f5c5SAndroid Build Coastguard Worker         {
2707*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_FALSE, 2, true);
2708*8975f5c5SAndroid Build Coastguard Worker             return format;
2709*8975f5c5SAndroid Build Coastguard Worker         }
2710*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_SINT:
2711*8975f5c5SAndroid Build Coastguard Worker         {
2712*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_FALSE, 3, true);
2713*8975f5c5SAndroid Build Coastguard Worker             return format;
2714*8975f5c5SAndroid Build Coastguard Worker         }
2715*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_SINT:
2716*8975f5c5SAndroid Build Coastguard Worker         {
2717*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_SHORT, GL_FALSE, 4, true);
2718*8975f5c5SAndroid Build Coastguard Worker             return format;
2719*8975f5c5SAndroid Build Coastguard Worker         }
2720*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_UINT:
2721*8975f5c5SAndroid Build Coastguard Worker         {
2722*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, true);
2723*8975f5c5SAndroid Build Coastguard Worker             return format;
2724*8975f5c5SAndroid Build Coastguard Worker         }
2725*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_UINT:
2726*8975f5c5SAndroid Build Coastguard Worker         {
2727*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, true);
2728*8975f5c5SAndroid Build Coastguard Worker             return format;
2729*8975f5c5SAndroid Build Coastguard Worker         }
2730*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_UINT:
2731*8975f5c5SAndroid Build Coastguard Worker         {
2732*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, true);
2733*8975f5c5SAndroid Build Coastguard Worker             return format;
2734*8975f5c5SAndroid Build Coastguard Worker         }
2735*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_UINT:
2736*8975f5c5SAndroid Build Coastguard Worker         {
2737*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, true);
2738*8975f5c5SAndroid Build Coastguard Worker             return format;
2739*8975f5c5SAndroid Build Coastguard Worker         }
2740*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_SINT:
2741*8975f5c5SAndroid Build Coastguard Worker         {
2742*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_FALSE, 1, true);
2743*8975f5c5SAndroid Build Coastguard Worker             return format;
2744*8975f5c5SAndroid Build Coastguard Worker         }
2745*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_SINT:
2746*8975f5c5SAndroid Build Coastguard Worker         {
2747*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_FALSE, 2, true);
2748*8975f5c5SAndroid Build Coastguard Worker             return format;
2749*8975f5c5SAndroid Build Coastguard Worker         }
2750*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_SINT:
2751*8975f5c5SAndroid Build Coastguard Worker         {
2752*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_FALSE, 3, true);
2753*8975f5c5SAndroid Build Coastguard Worker             return format;
2754*8975f5c5SAndroid Build Coastguard Worker         }
2755*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_SINT:
2756*8975f5c5SAndroid Build Coastguard Worker         {
2757*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT, GL_FALSE, 4, true);
2758*8975f5c5SAndroid Build Coastguard Worker             return format;
2759*8975f5c5SAndroid Build Coastguard Worker         }
2760*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_UINT:
2761*8975f5c5SAndroid Build Coastguard Worker         {
2762*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, true);
2763*8975f5c5SAndroid Build Coastguard Worker             return format;
2764*8975f5c5SAndroid Build Coastguard Worker         }
2765*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_UINT:
2766*8975f5c5SAndroid Build Coastguard Worker         {
2767*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, true);
2768*8975f5c5SAndroid Build Coastguard Worker             return format;
2769*8975f5c5SAndroid Build Coastguard Worker         }
2770*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_UINT:
2771*8975f5c5SAndroid Build Coastguard Worker         {
2772*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, true);
2773*8975f5c5SAndroid Build Coastguard Worker             return format;
2774*8975f5c5SAndroid Build Coastguard Worker         }
2775*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_UINT:
2776*8975f5c5SAndroid Build Coastguard Worker         {
2777*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, true);
2778*8975f5c5SAndroid Build Coastguard Worker             return format;
2779*8975f5c5SAndroid Build Coastguard Worker         }
2780*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_FIXED:
2781*8975f5c5SAndroid Build Coastguard Worker         {
2782*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_FIXED, GL_FALSE, 1, false);
2783*8975f5c5SAndroid Build Coastguard Worker             return format;
2784*8975f5c5SAndroid Build Coastguard Worker         }
2785*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_FIXED:
2786*8975f5c5SAndroid Build Coastguard Worker         {
2787*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_FIXED, GL_FALSE, 2, false);
2788*8975f5c5SAndroid Build Coastguard Worker             return format;
2789*8975f5c5SAndroid Build Coastguard Worker         }
2790*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_FIXED:
2791*8975f5c5SAndroid Build Coastguard Worker         {
2792*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_FIXED, GL_FALSE, 3, false);
2793*8975f5c5SAndroid Build Coastguard Worker             return format;
2794*8975f5c5SAndroid Build Coastguard Worker         }
2795*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_FIXED:
2796*8975f5c5SAndroid Build Coastguard Worker         {
2797*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_FIXED, GL_FALSE, 4, false);
2798*8975f5c5SAndroid Build Coastguard Worker             return format;
2799*8975f5c5SAndroid Build Coastguard Worker         }
2800*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_FLOAT:
2801*8975f5c5SAndroid Build Coastguard Worker         {
2802*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 1, false);
2803*8975f5c5SAndroid Build Coastguard Worker             return format;
2804*8975f5c5SAndroid Build Coastguard Worker         }
2805*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_FLOAT:
2806*8975f5c5SAndroid Build Coastguard Worker         {
2807*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 2, false);
2808*8975f5c5SAndroid Build Coastguard Worker             return format;
2809*8975f5c5SAndroid Build Coastguard Worker         }
2810*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_FLOAT:
2811*8975f5c5SAndroid Build Coastguard Worker         {
2812*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 3, false);
2813*8975f5c5SAndroid Build Coastguard Worker             return format;
2814*8975f5c5SAndroid Build Coastguard Worker         }
2815*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_FLOAT:
2816*8975f5c5SAndroid Build Coastguard Worker         {
2817*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 4, false);
2818*8975f5c5SAndroid Build Coastguard Worker             return format;
2819*8975f5c5SAndroid Build Coastguard Worker         }
2820*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_FLOAT:
2821*8975f5c5SAndroid Build Coastguard Worker         {
2822*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_FLOAT, GL_FALSE, 1, false);
2823*8975f5c5SAndroid Build Coastguard Worker             return format;
2824*8975f5c5SAndroid Build Coastguard Worker         }
2825*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_FLOAT:
2826*8975f5c5SAndroid Build Coastguard Worker         {
2827*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_FLOAT, GL_FALSE, 2, false);
2828*8975f5c5SAndroid Build Coastguard Worker             return format;
2829*8975f5c5SAndroid Build Coastguard Worker         }
2830*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_FLOAT:
2831*8975f5c5SAndroid Build Coastguard Worker         {
2832*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_FLOAT, GL_FALSE, 3, false);
2833*8975f5c5SAndroid Build Coastguard Worker             return format;
2834*8975f5c5SAndroid Build Coastguard Worker         }
2835*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_FLOAT:
2836*8975f5c5SAndroid Build Coastguard Worker         {
2837*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_FLOAT, GL_FALSE, 4, false);
2838*8975f5c5SAndroid Build Coastguard Worker             return format;
2839*8975f5c5SAndroid Build Coastguard Worker         }
2840*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_SSCALED:
2841*8975f5c5SAndroid Build Coastguard Worker         {
2842*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, false);
2843*8975f5c5SAndroid Build Coastguard Worker             return format;
2844*8975f5c5SAndroid Build Coastguard Worker         }
2845*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_USCALED:
2846*8975f5c5SAndroid Build Coastguard Worker         {
2847*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, false);
2848*8975f5c5SAndroid Build Coastguard Worker             return format;
2849*8975f5c5SAndroid Build Coastguard Worker         }
2850*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_SNORM:
2851*8975f5c5SAndroid Build Coastguard Worker         {
2852*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_TRUE, 4, false);
2853*8975f5c5SAndroid Build Coastguard Worker             return format;
2854*8975f5c5SAndroid Build Coastguard Worker         }
2855*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_UNORM:
2856*8975f5c5SAndroid Build Coastguard Worker         {
2857*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 4, false);
2858*8975f5c5SAndroid Build Coastguard Worker             return format;
2859*8975f5c5SAndroid Build Coastguard Worker         }
2860*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_SINT:
2861*8975f5c5SAndroid Build Coastguard Worker         {
2862*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, true);
2863*8975f5c5SAndroid Build Coastguard Worker             return format;
2864*8975f5c5SAndroid Build Coastguard Worker         }
2865*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_UINT:
2866*8975f5c5SAndroid Build Coastguard Worker         {
2867*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, true);
2868*8975f5c5SAndroid Build Coastguard Worker             return format;
2869*8975f5c5SAndroid Build Coastguard Worker         }
2870*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_SSCALED_VERTEX:
2871*8975f5c5SAndroid Build Coastguard Worker         {
2872*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_FALSE, 4, false);
2873*8975f5c5SAndroid Build Coastguard Worker             return format;
2874*8975f5c5SAndroid Build Coastguard Worker         }
2875*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_USCALED_VERTEX:
2876*8975f5c5SAndroid Build Coastguard Worker         {
2877*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_FALSE, 4, false);
2878*8975f5c5SAndroid Build Coastguard Worker             return format;
2879*8975f5c5SAndroid Build Coastguard Worker         }
2880*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_SNORM_VERTEX:
2881*8975f5c5SAndroid Build Coastguard Worker         {
2882*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_TRUE, 4, false);
2883*8975f5c5SAndroid Build Coastguard Worker             return format;
2884*8975f5c5SAndroid Build Coastguard Worker         }
2885*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_UNORM_VERTEX:
2886*8975f5c5SAndroid Build Coastguard Worker         {
2887*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_TRUE, 4, false);
2888*8975f5c5SAndroid Build Coastguard Worker             return format;
2889*8975f5c5SAndroid Build Coastguard Worker         }
2890*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_SINT_VERTEX:
2891*8975f5c5SAndroid Build Coastguard Worker         {
2892*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_FALSE, 4, true);
2893*8975f5c5SAndroid Build Coastguard Worker             return format;
2894*8975f5c5SAndroid Build Coastguard Worker         }
2895*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_UINT_VERTEX:
2896*8975f5c5SAndroid Build Coastguard Worker         {
2897*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_FALSE, 4, true);
2898*8975f5c5SAndroid Build Coastguard Worker             return format;
2899*8975f5c5SAndroid Build Coastguard Worker         }
2900*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_SSCALED_VERTEX:
2901*8975f5c5SAndroid Build Coastguard Worker         {
2902*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_FALSE, 4, false);
2903*8975f5c5SAndroid Build Coastguard Worker             return format;
2904*8975f5c5SAndroid Build Coastguard Worker         }
2905*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_USCALED_VERTEX:
2906*8975f5c5SAndroid Build Coastguard Worker         {
2907*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_FALSE, 4, false);
2908*8975f5c5SAndroid Build Coastguard Worker             return format;
2909*8975f5c5SAndroid Build Coastguard Worker         }
2910*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_SNORM_VERTEX:
2911*8975f5c5SAndroid Build Coastguard Worker         {
2912*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_TRUE, 4, false);
2913*8975f5c5SAndroid Build Coastguard Worker             return format;
2914*8975f5c5SAndroid Build Coastguard Worker         }
2915*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_UNORM_VERTEX:
2916*8975f5c5SAndroid Build Coastguard Worker         {
2917*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_TRUE, 4, false);
2918*8975f5c5SAndroid Build Coastguard Worker             return format;
2919*8975f5c5SAndroid Build Coastguard Worker         }
2920*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_SINT_VERTEX:
2921*8975f5c5SAndroid Build Coastguard Worker         {
2922*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_FALSE, 4, true);
2923*8975f5c5SAndroid Build Coastguard Worker             return format;
2924*8975f5c5SAndroid Build Coastguard Worker         }
2925*8975f5c5SAndroid Build Coastguard Worker         default:
2926*8975f5c5SAndroid Build Coastguard Worker         {
2927*8975f5c5SAndroid Build Coastguard Worker             static const VertexFormat format(GL_NONE, GL_FALSE, 0, false);
2928*8975f5c5SAndroid Build Coastguard Worker             return format;
2929*8975f5c5SAndroid Build Coastguard Worker         }
2930*8975f5c5SAndroid Build Coastguard Worker     }
2931*8975f5c5SAndroid Build Coastguard Worker }
2932*8975f5c5SAndroid Build Coastguard Worker 
GetVertexFormatSize(angle::FormatID vertexFormatID)2933*8975f5c5SAndroid Build Coastguard Worker size_t GetVertexFormatSize(angle::FormatID vertexFormatID)
2934*8975f5c5SAndroid Build Coastguard Worker {
2935*8975f5c5SAndroid Build Coastguard Worker     switch (vertexFormatID)
2936*8975f5c5SAndroid Build Coastguard Worker     {
2937*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_SSCALED:
2938*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_SNORM:
2939*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_USCALED:
2940*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_UNORM:
2941*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_SINT:
2942*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_UINT:
2943*8975f5c5SAndroid Build Coastguard Worker             return 1;
2944*8975f5c5SAndroid Build Coastguard Worker 
2945*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_SSCALED:
2946*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_SNORM:
2947*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_USCALED:
2948*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_UNORM:
2949*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_SINT:
2950*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_UINT:
2951*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_SSCALED:
2952*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_SNORM:
2953*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_USCALED:
2954*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_UNORM:
2955*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_SINT:
2956*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_UINT:
2957*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_FLOAT:
2958*8975f5c5SAndroid Build Coastguard Worker             return 2;
2959*8975f5c5SAndroid Build Coastguard Worker 
2960*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_SSCALED:
2961*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_SNORM:
2962*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_USCALED:
2963*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_UNORM:
2964*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_SINT:
2965*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_UINT:
2966*8975f5c5SAndroid Build Coastguard Worker             return 3;
2967*8975f5c5SAndroid Build Coastguard Worker 
2968*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_SSCALED:
2969*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_SNORM:
2970*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_USCALED:
2971*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_UNORM:
2972*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_SINT:
2973*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_UINT:
2974*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_SSCALED:
2975*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_SNORM:
2976*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_USCALED:
2977*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_UNORM:
2978*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_SINT:
2979*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_UINT:
2980*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_SSCALED:
2981*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_SNORM:
2982*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_USCALED:
2983*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_UNORM:
2984*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_SINT:
2985*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_UINT:
2986*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_FLOAT:
2987*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_FIXED:
2988*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_FLOAT:
2989*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_SSCALED:
2990*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_USCALED:
2991*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_SNORM:
2992*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_UNORM:
2993*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_SINT:
2994*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_UINT:
2995*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_SSCALED_VERTEX:
2996*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_USCALED_VERTEX:
2997*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_SINT_VERTEX:
2998*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_UINT_VERTEX:
2999*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_SNORM_VERTEX:
3000*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::A2R10G10B10_UNORM_VERTEX:
3001*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_SSCALED_VERTEX:
3002*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_USCALED_VERTEX:
3003*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_SINT_VERTEX:
3004*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_UINT_VERTEX:
3005*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_SNORM_VERTEX:
3006*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::X2R10G10B10_UNORM_VERTEX:
3007*8975f5c5SAndroid Build Coastguard Worker             return 4;
3008*8975f5c5SAndroid Build Coastguard Worker 
3009*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_SSCALED:
3010*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_SNORM:
3011*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_USCALED:
3012*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_UNORM:
3013*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_SINT:
3014*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_UINT:
3015*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_FLOAT:
3016*8975f5c5SAndroid Build Coastguard Worker             return 6;
3017*8975f5c5SAndroid Build Coastguard Worker 
3018*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_SSCALED:
3019*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_SNORM:
3020*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_USCALED:
3021*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_UNORM:
3022*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_SINT:
3023*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_UINT:
3024*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_SSCALED:
3025*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_SNORM:
3026*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_USCALED:
3027*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_UNORM:
3028*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_SINT:
3029*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_UINT:
3030*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_FLOAT:
3031*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_FIXED:
3032*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_FLOAT:
3033*8975f5c5SAndroid Build Coastguard Worker             return 8;
3034*8975f5c5SAndroid Build Coastguard Worker 
3035*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_SSCALED:
3036*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_SNORM:
3037*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_USCALED:
3038*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_UNORM:
3039*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_SINT:
3040*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_UINT:
3041*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_FIXED:
3042*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_FLOAT:
3043*8975f5c5SAndroid Build Coastguard Worker             return 12;
3044*8975f5c5SAndroid Build Coastguard Worker 
3045*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_SSCALED:
3046*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_SNORM:
3047*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_USCALED:
3048*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_UNORM:
3049*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_SINT:
3050*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_UINT:
3051*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_FIXED:
3052*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_FLOAT:
3053*8975f5c5SAndroid Build Coastguard Worker             return 16;
3054*8975f5c5SAndroid Build Coastguard Worker 
3055*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::NONE:
3056*8975f5c5SAndroid Build Coastguard Worker         default:
3057*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
3058*8975f5c5SAndroid Build Coastguard Worker             return 0;
3059*8975f5c5SAndroid Build Coastguard Worker     }
3060*8975f5c5SAndroid Build Coastguard Worker }
3061*8975f5c5SAndroid Build Coastguard Worker 
ConvertFormatSignedness(const angle::Format & format)3062*8975f5c5SAndroid Build Coastguard Worker angle::FormatID ConvertFormatSignedness(const angle::Format &format)
3063*8975f5c5SAndroid Build Coastguard Worker {
3064*8975f5c5SAndroid Build Coastguard Worker     switch (format.id)
3065*8975f5c5SAndroid Build Coastguard Worker     {
3066*8975f5c5SAndroid Build Coastguard Worker         // 1 byte signed to unsigned
3067*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_SINT:
3068*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8_UINT;
3069*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_SNORM:
3070*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8_UNORM;
3071*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_SSCALED:
3072*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8_USCALED;
3073*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_SINT:
3074*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8_UINT;
3075*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_SNORM:
3076*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8_UNORM;
3077*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_SSCALED:
3078*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8_USCALED;
3079*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_SINT:
3080*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8_UINT;
3081*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_SNORM:
3082*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8_UNORM;
3083*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_SSCALED:
3084*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8_USCALED;
3085*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_SINT:
3086*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8A8_UINT;
3087*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_SNORM:
3088*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8A8_UNORM;
3089*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_SSCALED:
3090*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8A8_USCALED;
3091*8975f5c5SAndroid Build Coastguard Worker         // 1 byte unsigned to signed
3092*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_UINT:
3093*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8_SINT;
3094*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_UNORM:
3095*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8_SNORM;
3096*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8_USCALED:
3097*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8_SSCALED;
3098*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_UINT:
3099*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8_SINT;
3100*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_UNORM:
3101*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8_SNORM;
3102*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8_USCALED:
3103*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8_SSCALED;
3104*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_UINT:
3105*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8_SINT;
3106*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_UNORM:
3107*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8_SNORM;
3108*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8_USCALED:
3109*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8_SSCALED;
3110*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_UINT:
3111*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8A8_SINT;
3112*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_UNORM:
3113*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8A8_SNORM;
3114*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R8G8B8A8_USCALED:
3115*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R8G8B8A8_SSCALED;
3116*8975f5c5SAndroid Build Coastguard Worker         // 2 byte signed to unsigned
3117*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_SINT:
3118*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16_UINT;
3119*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_SNORM:
3120*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16_UNORM;
3121*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_SSCALED:
3122*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16_USCALED;
3123*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_SINT:
3124*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16_UINT;
3125*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_SNORM:
3126*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16_UNORM;
3127*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_SSCALED:
3128*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16_USCALED;
3129*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_SINT:
3130*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16_UINT;
3131*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_SNORM:
3132*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16_UNORM;
3133*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_SSCALED:
3134*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16_USCALED;
3135*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_SINT:
3136*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16A16_UINT;
3137*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_SNORM:
3138*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16A16_UNORM;
3139*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_SSCALED:
3140*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16A16_USCALED;
3141*8975f5c5SAndroid Build Coastguard Worker         // 2 byte unsigned to signed
3142*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_UINT:
3143*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16_SINT;
3144*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_UNORM:
3145*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16_SNORM;
3146*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16_USCALED:
3147*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16_SSCALED;
3148*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_UINT:
3149*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16_SINT;
3150*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_UNORM:
3151*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16_SNORM;
3152*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16_USCALED:
3153*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16_SSCALED;
3154*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_UINT:
3155*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16_SINT;
3156*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_UNORM:
3157*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16_SNORM;
3158*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16_USCALED:
3159*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16_SSCALED;
3160*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_UINT:
3161*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16A16_SINT;
3162*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_UNORM:
3163*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16A16_SNORM;
3164*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R16G16B16A16_USCALED:
3165*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R16G16B16A16_SSCALED;
3166*8975f5c5SAndroid Build Coastguard Worker         // 4 byte signed to unsigned
3167*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_SINT:
3168*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32_UINT;
3169*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_SNORM:
3170*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32_UNORM;
3171*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_SSCALED:
3172*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32_USCALED;
3173*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_SINT:
3174*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32_UINT;
3175*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_SNORM:
3176*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32_UNORM;
3177*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_SSCALED:
3178*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32_USCALED;
3179*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_SINT:
3180*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32_UINT;
3181*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_SNORM:
3182*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32_UNORM;
3183*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_SSCALED:
3184*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32_USCALED;
3185*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_SINT:
3186*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32A32_UINT;
3187*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_SNORM:
3188*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32A32_UNORM;
3189*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_SSCALED:
3190*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32A32_USCALED;
3191*8975f5c5SAndroid Build Coastguard Worker         // 4 byte unsigned to signed
3192*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_UINT:
3193*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32_SINT;
3194*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_UNORM:
3195*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32_SNORM;
3196*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32_USCALED:
3197*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32_SSCALED;
3198*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_UINT:
3199*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32_SINT;
3200*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_UNORM:
3201*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32_SNORM;
3202*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32_USCALED:
3203*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32_SSCALED;
3204*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_UINT:
3205*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32_SINT;
3206*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_UNORM:
3207*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32_SNORM;
3208*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32_USCALED:
3209*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32_SSCALED;
3210*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_UINT:
3211*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32A32_SINT;
3212*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_UNORM:
3213*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32A32_SNORM;
3214*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R32G32B32A32_USCALED:
3215*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R32G32B32A32_SSCALED;
3216*8975f5c5SAndroid Build Coastguard Worker         // 1010102 signed to unsigned
3217*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_SINT:
3218*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R10G10B10A2_UINT;
3219*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_SSCALED:
3220*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R10G10B10A2_USCALED;
3221*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_SNORM:
3222*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R10G10B10A2_UNORM;
3223*8975f5c5SAndroid Build Coastguard Worker         // 1010102 unsigned to signed
3224*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_UINT:
3225*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R10G10B10A2_SINT;
3226*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_USCALED:
3227*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R10G10B10A2_SSCALED;
3228*8975f5c5SAndroid Build Coastguard Worker         case angle::FormatID::R10G10B10A2_UNORM:
3229*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::R10G10B10A2_SNORM;
3230*8975f5c5SAndroid Build Coastguard Worker         default:
3231*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
3232*8975f5c5SAndroid Build Coastguard Worker             return angle::FormatID::NONE;
3233*8975f5c5SAndroid Build Coastguard Worker     }
3234*8975f5c5SAndroid Build Coastguard Worker }
3235*8975f5c5SAndroid Build Coastguard Worker 
ValidES3InternalFormat(GLenum internalFormat)3236*8975f5c5SAndroid Build Coastguard Worker bool ValidES3InternalFormat(GLenum internalFormat)
3237*8975f5c5SAndroid Build Coastguard Worker {
3238*8975f5c5SAndroid Build Coastguard Worker     const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
3239*8975f5c5SAndroid Build Coastguard Worker     return internalFormat != GL_NONE && formatMap.find(internalFormat) != formatMap.end();
3240*8975f5c5SAndroid Build Coastguard Worker }
3241*8975f5c5SAndroid Build Coastguard Worker 
VertexFormat(GLenum typeIn,GLboolean normalizedIn,GLuint componentsIn,bool pureIntegerIn)3242*8975f5c5SAndroid Build Coastguard Worker VertexFormat::VertexFormat(GLenum typeIn,
3243*8975f5c5SAndroid Build Coastguard Worker                            GLboolean normalizedIn,
3244*8975f5c5SAndroid Build Coastguard Worker                            GLuint componentsIn,
3245*8975f5c5SAndroid Build Coastguard Worker                            bool pureIntegerIn)
3246*8975f5c5SAndroid Build Coastguard Worker     : type(typeIn), normalized(normalizedIn), components(componentsIn), pureInteger(pureIntegerIn)
3247*8975f5c5SAndroid Build Coastguard Worker {
3248*8975f5c5SAndroid Build Coastguard Worker     // float -> !normalized
3249*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!(type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_FIXED) ||
3250*8975f5c5SAndroid Build Coastguard Worker            normalized == GL_FALSE);
3251*8975f5c5SAndroid Build Coastguard Worker }
3252*8975f5c5SAndroid Build Coastguard Worker }  // namespace gl
3253