• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 #include "libANGLE/Caps.h"
8 
9 #include "anglebase/no_destructor.h"
10 #include "common/angleutils.h"
11 #include "common/debug.h"
12 
13 #include "libANGLE/formatutils.h"
14 
15 #include "angle_gl.h"
16 
17 #include <algorithm>
18 #include <sstream>
19 
InsertExtensionString(const std::string & extension,bool supported,std::vector<std::string> * extensionVector)20 static void InsertExtensionString(const std::string &extension,
21                                   bool supported,
22                                   std::vector<std::string> *extensionVector)
23 {
24     if (supported)
25     {
26         extensionVector->push_back(extension);
27     }
28 }
29 
30 namespace gl
31 {
32 
33 TextureCaps::TextureCaps() = default;
34 
35 TextureCaps::TextureCaps(const TextureCaps &other) = default;
36 
37 TextureCaps &TextureCaps::operator=(const TextureCaps &other) = default;
38 
39 TextureCaps::~TextureCaps() = default;
40 
getMaxSamples() const41 GLuint TextureCaps::getMaxSamples() const
42 {
43     return !sampleCounts.empty() ? *sampleCounts.rbegin() : 0;
44 }
45 
getNearestSamples(GLuint requestedSamples) const46 GLuint TextureCaps::getNearestSamples(GLuint requestedSamples) const
47 {
48     if (requestedSamples == 0)
49     {
50         return 0;
51     }
52 
53     for (SupportedSampleSet::const_iterator i = sampleCounts.begin(); i != sampleCounts.end(); i++)
54     {
55         GLuint samples = *i;
56         if (samples >= requestedSamples)
57         {
58             return samples;
59         }
60     }
61 
62     return 0;
63 }
64 
GenerateMinimumTextureCaps(GLenum sizedInternalFormat,const Version & clientVersion,const Extensions & extensions)65 TextureCaps GenerateMinimumTextureCaps(GLenum sizedInternalFormat,
66                                        const Version &clientVersion,
67                                        const Extensions &extensions)
68 {
69     TextureCaps caps;
70 
71     const InternalFormat &internalFormatInfo = GetSizedInternalFormatInfo(sizedInternalFormat);
72     caps.texturable        = internalFormatInfo.textureSupport(clientVersion, extensions);
73     caps.filterable        = internalFormatInfo.filterSupport(clientVersion, extensions);
74     caps.textureAttachment = internalFormatInfo.textureAttachmentSupport(clientVersion, extensions);
75     caps.renderbuffer      = internalFormatInfo.renderbufferSupport(clientVersion, extensions);
76     caps.blendable         = internalFormatInfo.blendSupport(clientVersion, extensions);
77 
78     caps.sampleCounts.insert(0);
79     if (internalFormatInfo.isRequiredRenderbufferFormat(clientVersion))
80     {
81         if ((clientVersion.major >= 3 && clientVersion.minor >= 1) ||
82             (clientVersion.major >= 3 && !internalFormatInfo.isInt()))
83         {
84             caps.sampleCounts.insert(4);
85         }
86     }
87 
88     return caps;
89 }
90 
TextureCapsMap()91 TextureCapsMap::TextureCapsMap() {}
92 
~TextureCapsMap()93 TextureCapsMap::~TextureCapsMap() {}
94 
insert(GLenum internalFormat,const TextureCaps & caps)95 void TextureCapsMap::insert(GLenum internalFormat, const TextureCaps &caps)
96 {
97     angle::FormatID formatID = angle::Format::InternalFormatToID(internalFormat);
98     get(formatID)            = caps;
99 }
100 
clear()101 void TextureCapsMap::clear()
102 {
103     mFormatData.fill(TextureCaps());
104 }
105 
get(GLenum internalFormat) const106 const TextureCaps &TextureCapsMap::get(GLenum internalFormat) const
107 {
108     angle::FormatID formatID = angle::Format::InternalFormatToID(internalFormat);
109     return get(formatID);
110 }
111 
get(angle::FormatID formatID) const112 const TextureCaps &TextureCapsMap::get(angle::FormatID formatID) const
113 {
114     return mFormatData[formatID];
115 }
116 
get(angle::FormatID formatID)117 TextureCaps &TextureCapsMap::get(angle::FormatID formatID)
118 {
119     return mFormatData[formatID];
120 }
121 
set(angle::FormatID formatID,const TextureCaps & caps)122 void TextureCapsMap::set(angle::FormatID formatID, const TextureCaps &caps)
123 {
124     get(formatID) = caps;
125 }
126 
InitMinimumTextureCapsMap(const Version & clientVersion,const Extensions & extensions,TextureCapsMap * capsMap)127 void InitMinimumTextureCapsMap(const Version &clientVersion,
128                                const Extensions &extensions,
129                                TextureCapsMap *capsMap)
130 {
131     for (GLenum internalFormat : GetAllSizedInternalFormats())
132     {
133         capsMap->insert(internalFormat,
134                         GenerateMinimumTextureCaps(internalFormat, clientVersion, extensions));
135     }
136 }
137 
138 Extensions::Extensions() = default;
139 
140 Extensions::Extensions(const Extensions &other) = default;
141 
142 Extensions &Extensions::operator=(const Extensions &other) = default;
143 
getStrings() const144 std::vector<std::string> Extensions::getStrings() const
145 {
146     std::vector<std::string> extensionStrings;
147 
148     for (const auto &extensionInfo : GetExtensionInfoMap())
149     {
150         if (this->*(extensionInfo.second.ExtensionsMember))
151         {
152             extensionStrings.push_back(extensionInfo.first);
153         }
154     }
155 
156     return extensionStrings;
157 }
158 
159 Limitations::Limitations()                         = default;
160 Limitations::Limitations(const Limitations &other) = default;
161 
162 Limitations &Limitations::operator=(const Limitations &other) = default;
163 
GetFormatSupportBase(const TextureCapsMap & textureCaps,const GLenum * requiredFormats,size_t requiredFormatsSize,bool requiresTexturing,bool requiresFiltering,bool requiresAttachingTexture,bool requiresRenderbufferSupport,bool requiresBlending)164 static bool GetFormatSupportBase(const TextureCapsMap &textureCaps,
165                                  const GLenum *requiredFormats,
166                                  size_t requiredFormatsSize,
167                                  bool requiresTexturing,
168                                  bool requiresFiltering,
169                                  bool requiresAttachingTexture,
170                                  bool requiresRenderbufferSupport,
171                                  bool requiresBlending)
172 {
173     for (size_t i = 0; i < requiredFormatsSize; i++)
174     {
175         const TextureCaps &cap = textureCaps.get(requiredFormats[i]);
176         if (requiresTexturing && !cap.texturable)
177         {
178             return false;
179         }
180 
181         if (requiresFiltering && !cap.filterable)
182         {
183             return false;
184         }
185 
186         if (requiresAttachingTexture && !cap.textureAttachment)
187         {
188             return false;
189         }
190 
191         if (requiresRenderbufferSupport && !cap.renderbuffer)
192         {
193             return false;
194         }
195 
196         if (requiresBlending && !cap.blendable)
197         {
198             return false;
199         }
200     }
201 
202     return true;
203 }
204 
205 template <size_t N>
GetFormatSupport(const TextureCapsMap & textureCaps,const GLenum (& requiredFormats)[N],bool requiresTexturing,bool requiresFiltering,bool requiresAttachingTexture,bool requiresRenderbufferSupport,bool requiresBlending)206 static bool GetFormatSupport(const TextureCapsMap &textureCaps,
207                              const GLenum (&requiredFormats)[N],
208                              bool requiresTexturing,
209                              bool requiresFiltering,
210                              bool requiresAttachingTexture,
211                              bool requiresRenderbufferSupport,
212                              bool requiresBlending)
213 {
214     return GetFormatSupportBase(textureCaps, requiredFormats, N, requiresTexturing,
215                                 requiresFiltering, requiresAttachingTexture,
216                                 requiresRenderbufferSupport, requiresBlending);
217 }
218 
219 // Check for GL_OES_packed_depth_stencil support
DeterminePackedDepthStencilSupport(const TextureCapsMap & textureCaps)220 static bool DeterminePackedDepthStencilSupport(const TextureCapsMap &textureCaps)
221 {
222     constexpr GLenum requiredFormats[] = {
223         GL_DEPTH24_STENCIL8,
224     };
225 
226     return GetFormatSupport(textureCaps, requiredFormats, false, false, true, true, false);
227 }
228 
229 // Checks for GL_NV_read_depth support
DetermineReadDepthSupport(const TextureCapsMap & textureCaps)230 static bool DetermineReadDepthSupport(const TextureCapsMap &textureCaps)
231 {
232     constexpr GLenum requiredFormats[] = {
233         GL_DEPTH_COMPONENT16,
234     };
235 
236     return GetFormatSupport(textureCaps, requiredFormats, true, false, true, false, false);
237 }
238 
239 // Checks for GL_NV_read_stencil support
DetermineReadStencilSupport(const TextureCapsMap & textureCaps)240 static bool DetermineReadStencilSupport(const TextureCapsMap &textureCaps)
241 {
242     constexpr GLenum requiredFormats[] = {
243         GL_STENCIL_INDEX8,
244     };
245 
246     return GetFormatSupport(textureCaps, requiredFormats, false, false, true, false, false);
247 }
248 
249 // Checks for GL_NV_depth_buffer_float2 support
DetermineDepthBufferFloat2Support(const TextureCapsMap & textureCaps)250 static bool DetermineDepthBufferFloat2Support(const TextureCapsMap &textureCaps)
251 {
252     constexpr GLenum requiredFormats[] = {
253         GL_DEPTH_COMPONENT32F,
254         GL_DEPTH32F_STENCIL8,
255     };
256 
257     return GetFormatSupport(textureCaps, requiredFormats, true, false, true, false, false);
258 }
259 
260 // Checks for GL_OES_rgb8_rgba8 support
DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap & textureCaps)261 static bool DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap &textureCaps)
262 {
263     constexpr GLenum requiredFormats[] = {
264         GL_RGB8,
265         GL_RGBA8,
266     };
267 
268     return GetFormatSupport(textureCaps, requiredFormats, false, false, false, true, false);
269 }
270 
271 // Checks for GL_EXT_texture_format_BGRA8888 support
DetermineBGRA8TextureSupport(const TextureCapsMap & textureCaps)272 static bool DetermineBGRA8TextureSupport(const TextureCapsMap &textureCaps)
273 {
274     constexpr GLenum requiredFormats[] = {
275         GL_BGRA8_EXT,
276     };
277 
278     return GetFormatSupport(textureCaps, requiredFormats, true, true, true, true, false);
279 }
280 
281 // Checks for GL_EXT_read_format_bgra support
DetermineBGRAReadFormatSupport(const TextureCapsMap & textureCaps)282 static bool DetermineBGRAReadFormatSupport(const TextureCapsMap &textureCaps)
283 {
284     constexpr GLenum requiredFormats[] = {
285         GL_BGRA8_EXT,
286         // TODO(http://anglebug.com/4302): GL_EXT_read_format_bgra specifies 2 more types, which are
287         // currently ignored. The equivalent formats would be: GL_BGRA4_ANGLEX, GL_BGR5_A1_ANGLEX
288     };
289 
290     return GetFormatSupport(textureCaps, requiredFormats, true, false, true, true, false);
291 }
292 
293 // Checks for GL_OES_color_buffer_half_float support
DetermineColorBufferHalfFloatSupport(const TextureCapsMap & textureCaps)294 static bool DetermineColorBufferHalfFloatSupport(const TextureCapsMap &textureCaps)
295 {
296     // EXT_color_buffer_half_float issue #2 states that an implementation doesn't need to support
297     // rendering to any of the formats but is expected to be able to render to at least one. WebGL
298     // requires that at least RGBA16F is renderable so we make the same requirement.
299     constexpr GLenum requiredFormats[] = {
300         GL_RGBA16F,
301     };
302 
303     return GetFormatSupport(textureCaps, requiredFormats, false, false, true, true, false);
304 }
305 
306 // Checks for GL_OES_texture_half_float support
DetermineHalfFloatTextureSupport(const TextureCapsMap & textureCaps)307 static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps)
308 {
309     constexpr GLenum requiredFormats[] = {
310         GL_RGBA16F, GL_RGB16F, GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE16F_EXT, GL_ALPHA16F_EXT,
311     };
312 
313     return GetFormatSupport(textureCaps, requiredFormats, true, false, false, false, false);
314 }
315 
316 // Checks for GL_OES_texture_half_float_linear support
DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap & textureCaps,bool checkLegacyFormats)317 static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &textureCaps,
318                                                       bool checkLegacyFormats)
319 {
320     constexpr GLenum requiredFormats[] = {GL_RGBA16F, GL_RGB16F};
321     // If GL_OES_texture_half_float is present, this extension must also support legacy formats
322     // introduced by that extension
323     constexpr GLenum requiredFormatsES2[] = {GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE16F_EXT,
324                                              GL_ALPHA16F_EXT};
325 
326     if (checkLegacyFormats &&
327         !GetFormatSupport(textureCaps, requiredFormatsES2, false, true, false, false, false))
328     {
329         return false;
330     }
331 
332     return GetFormatSupport(textureCaps, requiredFormats, false, true, false, false, false);
333 }
334 
335 // Checks for GL_OES_texture_float support
DetermineFloatTextureSupport(const TextureCapsMap & textureCaps)336 static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps)
337 {
338     constexpr GLenum requiredFormats[] = {
339         GL_RGBA32F, GL_RGB32F, GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE32F_EXT, GL_ALPHA32F_EXT,
340     };
341 
342     return GetFormatSupport(textureCaps, requiredFormats, true, false, false, false, false);
343 }
344 
345 // Checks for GL_OES_texture_float_linear support
DetermineFloatTextureFilteringSupport(const TextureCapsMap & textureCaps,bool checkLegacyFormats)346 static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureCaps,
347                                                   bool checkLegacyFormats)
348 {
349     constexpr GLenum requiredFormats[] = {
350         GL_RGBA32F,
351         GL_RGB32F,
352     };
353     // If GL_OES_texture_float is present, this extension must also support legacy formats
354     // introduced by that extension
355     constexpr GLenum requiredFormatsES2[] = {
356         GL_LUMINANCE_ALPHA32F_EXT,
357         GL_LUMINANCE32F_EXT,
358         GL_ALPHA32F_EXT,
359     };
360 
361     if (checkLegacyFormats &&
362         !GetFormatSupport(textureCaps, requiredFormatsES2, false, true, false, false, false))
363     {
364         return false;
365     }
366 
367     return GetFormatSupport(textureCaps, requiredFormats, false, true, false, false, false);
368 }
369 
370 // Checks for GL_EXT_texture_rg support
DetermineRGTextureSupport(const TextureCapsMap & textureCaps,bool checkHalfFloatFormats,bool checkFloatFormats)371 static bool DetermineRGTextureSupport(const TextureCapsMap &textureCaps,
372                                       bool checkHalfFloatFormats,
373                                       bool checkFloatFormats)
374 {
375     constexpr GLenum requiredFormats[] = {
376         GL_R8,
377         GL_RG8,
378     };
379     constexpr GLenum requiredHalfFloatFormats[] = {
380         GL_R16F,
381         GL_RG16F,
382     };
383     constexpr GLenum requiredFloatFormats[] = {
384         GL_R32F,
385         GL_RG32F,
386     };
387 
388     if (checkHalfFloatFormats &&
389         !GetFormatSupport(textureCaps, requiredHalfFloatFormats, true, false, false, false, false))
390     {
391         return false;
392     }
393 
394     if (checkFloatFormats &&
395         !GetFormatSupport(textureCaps, requiredFloatFormats, true, false, false, false, false))
396     {
397         return false;
398     }
399 
400     return GetFormatSupport(textureCaps, requiredFormats, true, true, true, true, false);
401 }
402 
DetermineTextureFormat2101010Support(const TextureCapsMap & textureCaps)403 static bool DetermineTextureFormat2101010Support(const TextureCapsMap &textureCaps)
404 {
405     // GL_EXT_texture_type_2_10_10_10_REV specifies both RGBA and RGB support whereas desktop GL
406     // only specifies RGBA support, so check both RGBA and RGB before marking as supported.
407     constexpr GLenum requiredFormats[] = {
408         GL_RGB10_A2,
409         GL_RGB10_UNORM_ANGLEX,
410     };
411 
412     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
413 }
414 
415 // Check for GL_EXT_texture_compression_dxt1 support
DetermineDXT1TextureSupport(const TextureCapsMap & textureCaps)416 static bool DetermineDXT1TextureSupport(const TextureCapsMap &textureCaps)
417 {
418     constexpr GLenum requiredFormats[] = {
419         GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
420         GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
421     };
422 
423     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
424 }
425 
426 // Check for GL_ANGLE_texture_compression_dxt3 support
DetermineDXT3TextureSupport(const TextureCapsMap & textureCaps)427 static bool DetermineDXT3TextureSupport(const TextureCapsMap &textureCaps)
428 {
429     constexpr GLenum requiredFormats[] = {
430         GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,
431     };
432 
433     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
434 }
435 
436 // Check for GL_ANGLE_texture_compression_dxt5 support
DetermineDXT5TextureSupport(const TextureCapsMap & textureCaps)437 static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps)
438 {
439     constexpr GLenum requiredFormats[] = {
440         GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,
441     };
442 
443     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
444 }
445 
446 // Check for GL_EXT_texture_compression_s3tc_srgb support
DetermineS3TCsRGBTextureSupport(const TextureCapsMap & textureCaps)447 static bool DetermineS3TCsRGBTextureSupport(const TextureCapsMap &textureCaps)
448 {
449     constexpr GLenum requiredFormats[] = {
450         GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
451         GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
452         GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
453         GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
454     };
455 
456     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
457 }
458 
459 // Check for GL_KHR_texture_compression_astc_ldr support
DetermineASTCLDRTextureSupport(const TextureCapsMap & textureCaps)460 static bool DetermineASTCLDRTextureSupport(const TextureCapsMap &textureCaps)
461 {
462     constexpr GLenum requiredFormats[] = {
463         GL_COMPRESSED_RGBA_ASTC_4x4_KHR,           GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
464         GL_COMPRESSED_RGBA_ASTC_5x5_KHR,           GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
465         GL_COMPRESSED_RGBA_ASTC_6x6_KHR,           GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
466         GL_COMPRESSED_RGBA_ASTC_8x6_KHR,           GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
467         GL_COMPRESSED_RGBA_ASTC_10x5_KHR,          GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
468         GL_COMPRESSED_RGBA_ASTC_10x8_KHR,          GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
469         GL_COMPRESSED_RGBA_ASTC_12x10_KHR,         GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
470         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,   GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
471         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,   GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
472         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,   GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
473         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,   GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
474         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
475         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
476         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
477     };
478 
479     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
480 }
481 
482 // Check for GL_OES_texture_compression_astc support
DetermineASTCOESTExtureSupport(const TextureCapsMap & textureCaps)483 static bool DetermineASTCOESTExtureSupport(const TextureCapsMap &textureCaps)
484 {
485     if (!DetermineASTCLDRTextureSupport(textureCaps))
486     {
487         return false;
488     }
489 
490     // The OES version of the extension also requires the 3D ASTC formats
491     constexpr GLenum requiredFormats[] = {
492         GL_COMPRESSED_RGBA_ASTC_3x3x3_OES,         GL_COMPRESSED_RGBA_ASTC_4x3x3_OES,
493         GL_COMPRESSED_RGBA_ASTC_4x4x3_OES,         GL_COMPRESSED_RGBA_ASTC_4x4x4_OES,
494         GL_COMPRESSED_RGBA_ASTC_5x4x4_OES,         GL_COMPRESSED_RGBA_ASTC_5x5x4_OES,
495         GL_COMPRESSED_RGBA_ASTC_5x5x5_OES,         GL_COMPRESSED_RGBA_ASTC_6x5x5_OES,
496         GL_COMPRESSED_RGBA_ASTC_6x6x5_OES,         GL_COMPRESSED_RGBA_ASTC_6x6x6_OES,
497         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES,
498         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES,
499         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES,
500         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES,
501         GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES,
502     };
503 
504     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
505 }
506 
507 // Check for GL_ETC1_RGB8_OES support
DetermineETC1RGB8TextureSupport(const TextureCapsMap & textureCaps)508 static bool DetermineETC1RGB8TextureSupport(const TextureCapsMap &textureCaps)
509 {
510     constexpr GLenum requiredFormats[] = {
511         GL_ETC1_RGB8_OES,
512     };
513 
514     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
515 }
516 
517 // Check for OES_compressed_ETC2_RGB8_texture support
DetermineETC2RGB8TextureSupport(const TextureCapsMap & textureCaps)518 static bool DetermineETC2RGB8TextureSupport(const TextureCapsMap &textureCaps)
519 {
520     constexpr GLenum requiredFormats[] = {
521         GL_COMPRESSED_RGB8_ETC2,
522     };
523 
524     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
525 }
526 
527 // Check for OES_compressed_ETC2_sRGB8_texture support
DetermineETC2sRGB8TextureSupport(const TextureCapsMap & textureCaps)528 static bool DetermineETC2sRGB8TextureSupport(const TextureCapsMap &textureCaps)
529 {
530     constexpr GLenum requiredFormats[] = {
531         GL_COMPRESSED_SRGB8_ETC2,
532     };
533 
534     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
535 }
536 
537 // Check for OES_compressed_ETC2_punchthroughA_RGBA8_texture support
DetermineETC2PunchthroughARGB8TextureSupport(const TextureCapsMap & textureCaps)538 static bool DetermineETC2PunchthroughARGB8TextureSupport(const TextureCapsMap &textureCaps)
539 {
540     constexpr GLenum requiredFormats[] = {
541         GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
542     };
543 
544     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
545 }
546 
547 // Check for OES_compressed_ETC2_punchthroughA_sRGB8_alpha_texture support
DetermineETC2PunchthroughAsRGB8AlphaTextureSupport(const TextureCapsMap & textureCaps)548 static bool DetermineETC2PunchthroughAsRGB8AlphaTextureSupport(const TextureCapsMap &textureCaps)
549 {
550     constexpr GLenum requiredFormats[] = {
551         GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
552     };
553 
554     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
555 }
556 
557 // Check for OES_compressed_ETC2_RGBA8_texture support
DetermineETC2RGBA8TextureSupport(const TextureCapsMap & textureCaps)558 static bool DetermineETC2RGBA8TextureSupport(const TextureCapsMap &textureCaps)
559 {
560     constexpr GLenum requiredFormats[] = {
561         GL_COMPRESSED_RGBA8_ETC2_EAC,
562     };
563 
564     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
565 }
566 
567 // Check for OES_compressed_ETC2_sRGB8_alpha8_texture support
DetermineETC2sRGB8Alpha8TextureSupport(const TextureCapsMap & textureCaps)568 static bool DetermineETC2sRGB8Alpha8TextureSupport(const TextureCapsMap &textureCaps)
569 {
570     constexpr GLenum requiredFormats[] = {
571         GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
572     };
573 
574     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
575 }
576 
577 // Check for OES_compressed_EAC_R11_unsigned_texture support
DetermineEACR11UnsignedTextureSupport(const TextureCapsMap & textureCaps)578 static bool DetermineEACR11UnsignedTextureSupport(const TextureCapsMap &textureCaps)
579 {
580     constexpr GLenum requiredFormats[] = {
581         GL_COMPRESSED_R11_EAC,
582     };
583 
584     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
585 }
586 
587 // Check for OES_compressed_EAC_R11_signed_texture support
DetermineEACR11SignedTextureSupport(const TextureCapsMap & textureCaps)588 static bool DetermineEACR11SignedTextureSupport(const TextureCapsMap &textureCaps)
589 {
590     constexpr GLenum requiredFormats[] = {
591         GL_COMPRESSED_SIGNED_R11_EAC,
592     };
593 
594     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
595 }
596 
597 // Check for OES_compressed_EAC_RG11_unsigned_texture support
DetermineEACRG11UnsignedTextureSupport(const TextureCapsMap & textureCaps)598 static bool DetermineEACRG11UnsignedTextureSupport(const TextureCapsMap &textureCaps)
599 {
600     constexpr GLenum requiredFormats[] = {
601         GL_COMPRESSED_RG11_EAC,
602     };
603 
604     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
605 }
606 
607 // Check for OES_compressed_EAC_RG11_signed_texture support
DetermineEACRG11SignedTextureSupport(const TextureCapsMap & textureCaps)608 static bool DetermineEACRG11SignedTextureSupport(const TextureCapsMap &textureCaps)
609 {
610     constexpr GLenum requiredFormats[] = {
611         GL_COMPRESSED_SIGNED_RG11_EAC,
612     };
613 
614     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
615 }
616 
617 // Check for GL_EXT_sRGB support
DetermineSRGBTextureSupport(const TextureCapsMap & textureCaps)618 static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps)
619 {
620     constexpr GLenum requiredFilterFormats[] = {
621         GL_SRGB8,
622         GL_SRGB8_ALPHA8,
623     };
624 
625     constexpr GLenum requiredRenderFormats[] = {
626         GL_SRGB8_ALPHA8,
627     };
628 
629     return GetFormatSupport(textureCaps, requiredFilterFormats, true, true, false, false, false) &&
630            GetFormatSupport(textureCaps, requiredRenderFormats, true, false, true, true, false);
631 }
632 
633 // Check for GL_EXT_texture_sRGB_R8 support
DetermineSRGBR8TextureSupport(const TextureCapsMap & textureCaps)634 static bool DetermineSRGBR8TextureSupport(const TextureCapsMap &textureCaps)
635 {
636     constexpr GLenum requiredFilterFormats[] = {GL_SR8_EXT};
637 
638     return GetFormatSupport(textureCaps, requiredFilterFormats, true, true, false, false, false);
639 }
640 
641 // Check for GL_EXT_texture_sRGB_RG8 support
DetermineSRGBRG8TextureSupport(const TextureCapsMap & textureCaps)642 static bool DetermineSRGBRG8TextureSupport(const TextureCapsMap &textureCaps)
643 {
644     constexpr GLenum requiredFilterFormats[] = {GL_SRG8_EXT};
645 
646     return GetFormatSupport(textureCaps, requiredFilterFormats, true, true, false, false, false);
647 }
648 
649 // Check for GL_ANGLE_depth_texture support
DetermineDepthTextureANGLESupport(const TextureCapsMap & textureCaps)650 static bool DetermineDepthTextureANGLESupport(const TextureCapsMap &textureCaps)
651 {
652     constexpr GLenum requiredFormats[] = {
653         GL_DEPTH_COMPONENT16,
654 #if !defined(ANGLE_PLATFORM_IOS) && \
655     (!defined(ANGLE_PLATFORM_MACCATALYST) || !defined(ANGLE_CPU_ARM64))
656         // anglebug.com/6082
657         // TODO(dino): Temporarily Removing the need for GL_DEPTH_COMPONENT32_OES
658         // because it is not supported on iOS.
659         // TODO(dino): I think this needs to be a runtime check when running an iOS app on Mac.
660         GL_DEPTH_COMPONENT32_OES,
661 #endif
662         GL_DEPTH24_STENCIL8_OES,
663     };
664 
665     return GetFormatSupport(textureCaps, requiredFormats, true, false, true, false, false);
666 }
667 
668 // Check for GL_OES_depth_texture support
DetermineDepthTextureOESSupport(const TextureCapsMap & textureCaps)669 static bool DetermineDepthTextureOESSupport(const TextureCapsMap &textureCaps)
670 {
671     constexpr GLenum requiredFormats[] = {
672         GL_DEPTH_COMPONENT16,
673 #if !defined(ANGLE_PLATFORM_IOS) && \
674     (!defined(ANGLE_PLATFORM_MACCATALYST) || !defined(ANGLE_CPU_ARM64))
675         // anglebug.com/6082
676         // TODO(dino): Temporarily Removing the need for GL_DEPTH_COMPONENT32_OES
677         // because it is not supported on iOS.
678         // TODO(dino): I think this needs to be a runtime check when running an iOS app on Mac.
679         GL_DEPTH_COMPONENT32_OES,
680 #endif
681     };
682 
683     return GetFormatSupport(textureCaps, requiredFormats, true, false, true, true, false);
684 }
685 
686 // Check for GL_OES_depth24
DetermineDepth24OESSupport(const TextureCapsMap & textureCaps)687 static bool DetermineDepth24OESSupport(const TextureCapsMap &textureCaps)
688 {
689     constexpr GLenum requiredFormats[] = {
690         GL_DEPTH_COMPONENT24_OES,
691     };
692 
693     return GetFormatSupport(textureCaps, requiredFormats, false, false, false, true, false);
694 }
695 
696 // Check for GL_OES_depth32 support
DetermineDepth32Support(const TextureCapsMap & textureCaps)697 static bool DetermineDepth32Support(const TextureCapsMap &textureCaps)
698 {
699     constexpr GLenum requiredFormats[] = {
700         GL_DEPTH_COMPONENT32_OES,
701     };
702 
703     return GetFormatSupport(textureCaps, requiredFormats, false, false, true, true, false);
704 }
705 
706 // Check for GL_CHROMIUM_color_buffer_float_rgb support
DetermineColorBufferFloatRGBSupport(const TextureCapsMap & textureCaps)707 static bool DetermineColorBufferFloatRGBSupport(const TextureCapsMap &textureCaps)
708 {
709     constexpr GLenum requiredFormats[] = {
710         GL_RGB32F,
711     };
712 
713     return GetFormatSupport(textureCaps, requiredFormats, true, false, true, false, false);
714 }
715 
716 // Check for GL_CHROMIUM_color_buffer_float_rgba support
DetermineColorBufferFloatRGBASupport(const TextureCapsMap & textureCaps)717 static bool DetermineColorBufferFloatRGBASupport(const TextureCapsMap &textureCaps)
718 {
719     constexpr GLenum requiredFormats[] = {
720         GL_RGBA32F,
721     };
722 
723     return GetFormatSupport(textureCaps, requiredFormats, true, false, true, true, false);
724 }
725 
726 // Check for GL_EXT_color_buffer_float support
DetermineColorBufferFloatSupport(const TextureCapsMap & textureCaps)727 static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps)
728 {
729     constexpr GLenum nonBlendableFormats[] = {
730         GL_R32F,
731         GL_RG32F,
732         GL_RGBA32F,
733     };
734 
735     constexpr GLenum blendableFormats[] = {
736         GL_R16F,
737         GL_RG16F,
738         GL_RGBA16F,
739         GL_R11F_G11F_B10F,
740     };
741 
742     return GetFormatSupport(textureCaps, nonBlendableFormats, true, false, true, true, false) &&
743            GetFormatSupport(textureCaps, blendableFormats, true, false, true, true, true);
744 }
745 
746 // Check for GL_EXT_float_blend support
DetermineFloatBlendSupport(const TextureCapsMap & textureCaps)747 static bool DetermineFloatBlendSupport(const TextureCapsMap &textureCaps)
748 {
749     constexpr GLenum requiredFormats[] = {
750         GL_R32F,
751         GL_RG32F,
752         GL_RGBA32F,
753     };
754 
755     return GetFormatSupport(textureCaps, requiredFormats, true, false, true, true, true);
756 }
757 
758 // Check for GL_EXT_texture_norm16 support
DetermineTextureNorm16Support(const TextureCapsMap & textureCaps)759 static bool DetermineTextureNorm16Support(const TextureCapsMap &textureCaps)
760 {
761     constexpr GLenum requiredFilterFormats[] = {
762         GL_R16_EXT,       GL_RG16_EXT,       GL_RGB16_EXT,       GL_RGBA16_EXT,
763         GL_R16_SNORM_EXT, GL_RG16_SNORM_EXT, GL_RGB16_SNORM_EXT, GL_RGBA16_SNORM_EXT,
764     };
765 
766     constexpr GLenum requiredRenderFormats[] = {
767         GL_R16_EXT,
768         GL_RG16_EXT,
769         GL_RGBA16_EXT,
770     };
771 
772     return GetFormatSupport(textureCaps, requiredFilterFormats, true, true, false, false, false) &&
773            GetFormatSupport(textureCaps, requiredRenderFormats, true, false, true, true, false);
774 }
775 
776 // Check for EXT_texture_compression_rgtc support
DetermineRGTCTextureSupport(const TextureCapsMap & textureCaps)777 static bool DetermineRGTCTextureSupport(const TextureCapsMap &textureCaps)
778 {
779     constexpr GLenum requiredFormats[] = {
780         GL_COMPRESSED_RED_RGTC1_EXT, GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
781         GL_COMPRESSED_RED_GREEN_RGTC2_EXT, GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT};
782 
783     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
784 }
785 
786 // Check for EXT_texture_compression_bptc support
DetermineBPTCTextureSupport(const TextureCapsMap & textureCaps)787 static bool DetermineBPTCTextureSupport(const TextureCapsMap &textureCaps)
788 {
789     constexpr GLenum requiredFormats[] = {
790         GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
791         GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT};
792 
793     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
794 }
795 
796 // Check for GL_IMG_texture_compression_pvrtc support
DeterminePVRTCTextureSupport(const TextureCapsMap & textureCaps)797 static bool DeterminePVRTCTextureSupport(const TextureCapsMap &textureCaps)
798 {
799     constexpr GLenum requiredFormats[] = {
800         GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
801         GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG};
802 
803     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
804 }
805 
806 // Check for GL_EXT_pvrtc_sRGB support
DeterminePVRTCsRGBTextureSupport(const TextureCapsMap & textureCaps)807 static bool DeterminePVRTCsRGBTextureSupport(const TextureCapsMap &textureCaps)
808 {
809     constexpr GLenum requiredFormats[] = {
810         GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT, GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT,
811         GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT, GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT};
812 
813     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
814 }
815 
DetermineCompressedTextureETCSupport(const TextureCapsMap & textureCaps)816 bool DetermineCompressedTextureETCSupport(const TextureCapsMap &textureCaps)
817 {
818     constexpr GLenum requiredFormats[] = {GL_COMPRESSED_R11_EAC,
819                                           GL_COMPRESSED_SIGNED_R11_EAC,
820                                           GL_COMPRESSED_RG11_EAC,
821                                           GL_COMPRESSED_SIGNED_RG11_EAC,
822                                           GL_COMPRESSED_RGB8_ETC2,
823                                           GL_COMPRESSED_SRGB8_ETC2,
824                                           GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
825                                           GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
826                                           GL_COMPRESSED_RGBA8_ETC2_EAC,
827                                           GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC};
828 
829     return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false, false);
830 }
831 
832 // Checks for GL_OES_texture_stencil8 support
DetermineStencilIndex8Support(const TextureCapsMap & textureCaps)833 static bool DetermineStencilIndex8Support(const TextureCapsMap &textureCaps)
834 {
835     constexpr GLenum requiredFormats[] = {
836         GL_STENCIL_INDEX8,
837     };
838 
839     return GetFormatSupport(textureCaps, requiredFormats, false, false, true, false, false);
840 }
841 
setTextureExtensionSupport(const TextureCapsMap & textureCaps)842 void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
843 {
844     // TODO(ynovikov): rgb8rgba8OES, colorBufferHalfFloat, textureHalfFloat, textureHalfFloatLinear,
845     // textureFloatOES, textureFloatLinearOES, textureRG, sRGB, colorBufferFloatRGB,
846     // colorBufferFloatRGBA and colorBufferFloat were verified. Verify the rest.
847     packedDepthStencilOES = DeterminePackedDepthStencilSupport(textureCaps);
848     rgb8rgba8OES          = DetermineRGB8AndRGBA8TextureSupport(textureCaps);
849     readDepthNV           = DetermineReadDepthSupport(textureCaps);
850     readStencilNV         = DetermineReadStencilSupport(textureCaps);
851     depthBufferFloat2NV   = DetermineDepthBufferFloat2Support(textureCaps);
852     textureFormatBGRA8888 = DetermineBGRA8TextureSupport(textureCaps);
853     readFormatBGRA        = DetermineBGRAReadFormatSupport(textureCaps);
854     textureHalfFloat      = DetermineHalfFloatTextureSupport(textureCaps);
855     textureHalfFloatLinear =
856         DetermineHalfFloatTextureFilteringSupport(textureCaps, textureHalfFloat);
857     textureFloatOES       = DetermineFloatTextureSupport(textureCaps);
858     textureFloatLinearOES = DetermineFloatTextureFilteringSupport(textureCaps, textureFloatOES);
859     textureRG = DetermineRGTextureSupport(textureCaps, textureHalfFloat, textureFloatOES);
860     colorBufferHalfFloat    = textureHalfFloat && DetermineColorBufferHalfFloatSupport(textureCaps);
861     textureFormat2101010REV = DetermineTextureFormat2101010Support(textureCaps);
862     textureCompressionDXT1  = DetermineDXT1TextureSupport(textureCaps);
863     textureCompressionDXT3  = DetermineDXT3TextureSupport(textureCaps);
864     textureCompressionDXT5  = DetermineDXT5TextureSupport(textureCaps);
865     textureCompressionS3TCsRGB    = DetermineS3TCsRGBTextureSupport(textureCaps);
866     textureCompressionASTCLDRKHR  = DetermineASTCLDRTextureSupport(textureCaps);
867     textureCompressionASTCOES     = DetermineASTCOESTExtureSupport(textureCaps);
868     compressedETC1RGB8TextureOES  = DetermineETC1RGB8TextureSupport(textureCaps);
869     compressedETC2RGB8TextureOES  = DetermineETC2RGB8TextureSupport(textureCaps);
870     compressedETC2sRGB8TextureOES = DetermineETC2sRGB8TextureSupport(textureCaps);
871     compressedETC2PunchthroughARGB8TextureOES =
872         DetermineETC2PunchthroughARGB8TextureSupport(textureCaps);
873     compressedETC2PunchthroughAsRGB8AlphaTextureOES =
874         DetermineETC2PunchthroughAsRGB8AlphaTextureSupport(textureCaps);
875     compressedETC2RGBA8TextureOES       = DetermineETC2RGBA8TextureSupport(textureCaps);
876     compressedETC2sRGB8Alpha8TextureOES = DetermineETC2sRGB8Alpha8TextureSupport(textureCaps);
877     compressedEACR11UnsignedTextureOES  = DetermineEACR11UnsignedTextureSupport(textureCaps);
878     compressedEACR11SignedTextureOES    = DetermineEACR11SignedTextureSupport(textureCaps);
879     compressedEACRG11UnsignedTextureOES = DetermineEACRG11UnsignedTextureSupport(textureCaps);
880     compressedEACRG11SignedTextureOES   = DetermineEACRG11SignedTextureSupport(textureCaps);
881     sRGB                                = DetermineSRGBTextureSupport(textureCaps);
882     sRGBR8EXT                           = DetermineSRGBR8TextureSupport(textureCaps);
883     sRGBRG8EXT                          = DetermineSRGBRG8TextureSupport(textureCaps);
884     depthTextureANGLE                   = DetermineDepthTextureANGLESupport(textureCaps);
885     depthTextureOES                     = DetermineDepthTextureOESSupport(textureCaps);
886     depth24OES                          = DetermineDepth24OESSupport(textureCaps);
887     depth32OES                          = DetermineDepth32Support(textureCaps);
888     colorBufferFloatRGB                 = DetermineColorBufferFloatRGBSupport(textureCaps);
889     colorBufferFloatRGBA                = DetermineColorBufferFloatRGBASupport(textureCaps);
890     colorBufferFloat                    = DetermineColorBufferFloatSupport(textureCaps);
891     floatBlend                          = DetermineFloatBlendSupport(textureCaps);
892     textureNorm16                       = DetermineTextureNorm16Support(textureCaps);
893     textureCompressionRGTC              = DetermineRGTCTextureSupport(textureCaps);
894     textureCompressionBPTC              = DetermineBPTCTextureSupport(textureCaps);
895     compressedTexturePVRTC              = DeterminePVRTCTextureSupport(textureCaps);
896     compressedTexturePVRTCsRGB          = DeterminePVRTCsRGBTextureSupport(textureCaps);
897     stencilIndex8                       = DetermineStencilIndex8Support(textureCaps);
898 }
899 
GetExtensionInfoMap()900 const ExtensionInfoMap &GetExtensionInfoMap()
901 {
902     auto buildExtensionInfoMap = []() {
903         auto enableableExtension = [](ExtensionBool member) {
904             ExtensionInfo info;
905             info.Requestable      = true;
906             info.ExtensionsMember = member;
907             return info;
908         };
909 
910         auto enableableDisablableExtension = [&](ExtensionBool member) {
911             ExtensionInfo info = enableableExtension(member);
912             info.Disablable    = true;
913             return info;
914         };
915 
916         auto esOnlyExtension = [](ExtensionBool member) {
917             ExtensionInfo info;
918             info.ExtensionsMember = member;
919             return info;
920         };
921 
922         // clang-format off
923         ExtensionInfoMap map;
924         map["GL_OES_element_index_uint"] = enableableExtension(&Extensions::elementIndexUintOES);
925         map["GL_OES_packed_depth_stencil"] = esOnlyExtension(&Extensions::packedDepthStencilOES);
926         map["GL_OES_get_program_binary"] = enableableExtension(&Extensions::getProgramBinaryOES);
927         map["GL_OES_rgb8_rgba8"] = enableableExtension(&Extensions::rgb8rgba8OES);
928         map["GL_NV_read_depth"] = enableableExtension(&Extensions::readDepthNV);
929         map["GL_NV_read_stencil"] = enableableExtension(&Extensions::readStencilNV);
930         map["GL_NV_depth_buffer_float2"] = enableableExtension(&Extensions::depthBufferFloat2NV);
931         map["GL_EXT_texture_format_BGRA8888"] = enableableExtension(&Extensions::textureFormatBGRA8888);
932         map["GL_EXT_texture_type_2_10_10_10_REV"] = enableableExtension(&Extensions::textureFormat2101010REV);
933         map["GL_EXT_read_format_bgra"] = enableableExtension(&Extensions::readFormatBGRA);
934         map["GL_NV_pixel_buffer_object"] = enableableExtension(&Extensions::pixelBufferObjectNV);
935         map["GL_ARB_sync"] = enableableExtension(&Extensions::glSyncARB);
936         map["GL_OES_mapbuffer"] = enableableExtension(&Extensions::mapBufferOES);
937         map["GL_EXT_map_buffer_range"] = enableableExtension(&Extensions::mapBufferRange);
938         map["GL_EXT_color_buffer_half_float"] = enableableExtension(&Extensions::colorBufferHalfFloat);
939         map["GL_OES_texture_half_float"] = enableableExtension(&Extensions::textureHalfFloat);
940         map["GL_OES_texture_half_float_linear"] = enableableExtension(&Extensions::textureHalfFloatLinear);
941         map["GL_OES_texture_float"] = enableableExtension(&Extensions::textureFloatOES);
942         map["GL_OES_texture_float_linear"] = enableableExtension(&Extensions::textureFloatLinearOES);
943         map["GL_EXT_texture_rg"] = enableableExtension(&Extensions::textureRG);
944         map["GL_EXT_texture_compression_dxt1"] = enableableExtension(&Extensions::textureCompressionDXT1);
945         map["GL_ANGLE_texture_compression_dxt3"] = enableableExtension(&Extensions::textureCompressionDXT3);
946         map["GL_ANGLE_texture_compression_dxt5"] = enableableExtension(&Extensions::textureCompressionDXT5);
947         map["GL_EXT_texture_compression_s3tc_srgb"] = enableableExtension(&Extensions::textureCompressionS3TCsRGB);
948         map["GL_KHR_texture_compression_astc_ldr"] = enableableExtension(&Extensions::textureCompressionASTCLDRKHR);
949         map["GL_KHR_texture_compression_astc_hdr"] = enableableExtension(&Extensions::textureCompressionASTCHDRKHR);
950         map["GL_KHR_texture_compression_astc_sliced_3d"] = enableableExtension(&Extensions::textureCompressionSliced3dASTCKHR);
951         map["GL_OES_texture_compression_astc"] = enableableExtension(&Extensions::textureCompressionASTCOES);
952         map["GL_EXT_texture_compression_bptc"] = enableableExtension(&Extensions::textureCompressionBPTC);
953         map["GL_EXT_texture_compression_rgtc"] = enableableExtension(&Extensions::textureCompressionRGTC);
954         map["GL_OES_compressed_ETC1_RGB8_texture"] = enableableExtension(&Extensions::compressedETC1RGB8TextureOES);
955         map["GL_EXT_compressed_ETC1_RGB8_sub_texture"] = enableableExtension(&Extensions::compressedETC1RGB8SubTexture);
956         map["GL_OES_compressed_ETC2_RGB8_texture"] = enableableExtension(&Extensions::compressedETC2RGB8TextureOES);
957         map["GL_OES_compressed_ETC2_sRGB8_texture"] = enableableExtension(&Extensions::compressedETC2sRGB8TextureOES);
958         map["GL_OES_compressed_ETC2_punchthroughA_RGBA8_texture"] = enableableExtension(&Extensions::compressedETC2PunchthroughARGB8TextureOES);
959         map["GL_OES_compressed_ETC2_punchthroughA_sRGB8_alpha_texture"] = enableableExtension(&Extensions::compressedETC2PunchthroughAsRGB8AlphaTextureOES);
960         map["GL_OES_compressed_ETC2_RGBA8_texture"] = enableableExtension(&Extensions::compressedETC2RGBA8TextureOES);
961         map["GL_OES_compressed_ETC2_sRGB8_alpha8_texture"] = enableableExtension(&Extensions::compressedETC2sRGB8Alpha8TextureOES);
962         map["GL_OES_compressed_EAC_R11_unsigned_texture"] = enableableExtension(&Extensions::compressedEACR11UnsignedTextureOES);
963         map["GL_OES_compressed_EAC_R11_signed_texture"] = enableableExtension(&Extensions::compressedEACR11SignedTextureOES);
964         map["GL_OES_compressed_EAC_RG11_unsigned_texture"] = enableableExtension(&Extensions::compressedEACRG11UnsignedTextureOES);
965         map["GL_OES_compressed_EAC_RG11_signed_texture"] = enableableExtension(&Extensions::compressedEACRG11SignedTextureOES);
966         map["GL_ANGLE_compressed_texture_etc"] = enableableExtension(&Extensions::compressedTextureETC);
967         map["GL_IMG_texture_compression_pvrtc"] = enableableExtension(&Extensions::compressedTexturePVRTC);
968         map["GL_EXT_pvrtc_sRGB"] = enableableExtension(&Extensions::compressedTexturePVRTCsRGB);
969         map["GL_EXT_sRGB"] = enableableExtension(&Extensions::sRGB);
970         map["GL_EXT_texture_sRGB_R8"] = enableableExtension(&Extensions::sRGBR8EXT);
971         map["GL_EXT_texture_sRGB_RG8"] = enableableExtension(&Extensions::sRGBRG8EXT);
972         map["GL_ANGLE_depth_texture"] = esOnlyExtension(&Extensions::depthTextureANGLE);
973         map["GL_OES_depth_texture"] = esOnlyExtension(&Extensions::depthTextureOES);
974         map["GL_OES_depth_texture_cube_map"] = enableableExtension(&Extensions::depthTextureCubeMapOES);
975         map["GL_OES_depth24"] = esOnlyExtension(&Extensions::depth24OES);
976         map["GL_OES_depth32"] = esOnlyExtension(&Extensions::depth32OES);
977         map["GL_OES_texture_3D"] = enableableExtension(&Extensions::texture3DOES);
978         map["GL_EXT_texture_storage"] = enableableExtension(&Extensions::textureStorage);
979         map["GL_OES_texture_npot"] = enableableExtension(&Extensions::textureNPOTOES);
980         map["GL_EXT_draw_buffers"] = enableableExtension(&Extensions::drawBuffers);
981         map["GL_EXT_draw_buffers_indexed"] = enableableExtension(&Extensions::drawBuffersIndexedEXT);
982         map["GL_OES_draw_buffers_indexed"] = enableableExtension(&Extensions::drawBuffersIndexedOES);
983         map["GL_EXT_texture_filter_anisotropic"] = enableableExtension(&Extensions::textureFilterAnisotropic);
984         map["GL_EXT_occlusion_query_boolean"] = enableableExtension(&Extensions::occlusionQueryBoolean);
985         map["GL_NV_fence"] = esOnlyExtension(&Extensions::fenceNV);
986         map["GL_EXT_disjoint_timer_query"] = enableableExtension(&Extensions::disjointTimerQuery);
987         map["GL_EXT_robustness"] = esOnlyExtension(&Extensions::robustness);
988         map["GL_KHR_robust_buffer_access_behavior"] = esOnlyExtension(&Extensions::robustBufferAccessBehavior);
989         map["GL_EXT_blend_minmax"] = enableableExtension(&Extensions::blendMinMax);
990         map["GL_ANGLE_framebuffer_blit"] = enableableExtension(&Extensions::framebufferBlitANGLE);
991         map["GL_NV_framebuffer_blit"] = enableableExtension(&Extensions::framebufferBlitNV);
992         map["GL_ANGLE_framebuffer_multisample"] = enableableExtension(&Extensions::framebufferMultisample);
993         map["GL_EXT_multisampled_render_to_texture"] = enableableExtension(&Extensions::multisampledRenderToTexture);
994         map["GL_EXT_multisampled_render_to_texture2"] = enableableExtension(&Extensions::multisampledRenderToTexture2);
995         map["GL_ANGLE_instanced_arrays"] = enableableExtension(&Extensions::instancedArraysANGLE);
996         map["GL_EXT_instanced_arrays"] = enableableExtension(&Extensions::instancedArraysEXT);
997         map["GL_ANGLE_pack_reverse_row_order"] = enableableExtension(&Extensions::packReverseRowOrder);
998         map["GL_OES_standard_derivatives"] = enableableExtension(&Extensions::standardDerivativesOES);
999         map["GL_EXT_shader_texture_lod"] = enableableExtension(&Extensions::shaderTextureLOD);
1000         map["GL_EXT_frag_depth"] = enableableExtension(&Extensions::fragDepth);
1001         map["GL_OVR_multiview"] = enableableExtension(&Extensions::multiview);
1002         map["GL_OVR_multiview2"] = enableableExtension(&Extensions::multiview2);
1003         map["GL_ANGLE_texture_usage"] = enableableExtension(&Extensions::textureUsage);
1004         map["GL_ANGLE_translated_shader_source"] = esOnlyExtension(&Extensions::translatedShaderSource);
1005         map["GL_OES_fbo_render_mipmap"] = enableableExtension(&Extensions::fboRenderMipmapOES);
1006         map["GL_EXT_discard_framebuffer"] = esOnlyExtension(&Extensions::discardFramebuffer);
1007         map["GL_EXT_debug_label"] = esOnlyExtension(&Extensions::debugLabel);
1008         map["GL_EXT_debug_marker"] = esOnlyExtension(&Extensions::debugMarker);
1009         map["GL_OES_EGL_image"] = enableableExtension(&Extensions::eglImageOES);
1010         map["GL_OES_EGL_image_external"] = enableableExtension(&Extensions::eglImageExternalOES);
1011         map["GL_OES_EGL_image_external_essl3"] = enableableExtension(&Extensions::eglImageExternalEssl3OES);
1012         map["GL_EXT_EGL_image_external_wrap_modes"] = enableableExtension(&Extensions::eglImageExternalWrapModesEXT);
1013         map["GL_OES_EGL_sync"] = esOnlyExtension(&Extensions::eglSyncOES);
1014         map["GL_EXT_memory_object"] = enableableExtension(&Extensions::memoryObject);
1015         map["GL_EXT_memory_object_fd"] = enableableExtension(&Extensions::memoryObjectFd);
1016         map["GL_ANGLE_memory_object_flags"] = enableableExtension(&Extensions::memoryObjectFlagsANGLE);
1017         map["GL_ANGLE_memory_object_fuchsia"] = enableableExtension(&Extensions::memoryObjectFuchsiaANGLE);
1018         map["GL_EXT_semaphore"] = enableableExtension(&Extensions::semaphore);
1019         map["GL_EXT_semaphore_fd"] = enableableExtension(&Extensions::semaphoreFd);
1020         map["GL_NV_EGL_stream_consumer_external"] = enableableExtension(&Extensions::eglStreamConsumerExternalNV);
1021         map["GL_NV_shader_noperspective_interpolation"] = enableableExtension(&Extensions::noperspectiveInterpolationNV);
1022         map["GL_ANGLE_semaphore_fuchsia"] = enableableExtension(&Extensions::semaphoreFuchsiaANGLE);
1023         map["GL_EXT_unpack_subimage"] = enableableExtension(&Extensions::unpackSubimage);
1024         map["GL_NV_pack_subimage"] = enableableExtension(&Extensions::packSubimage);
1025         map["GL_EXT_color_buffer_float"] = enableableExtension(&Extensions::colorBufferFloat);
1026         map["GL_OES_vertex_half_float"] = enableableExtension(&Extensions::vertexHalfFloatOES);
1027         map["GL_OES_vertex_array_object"] = enableableExtension(&Extensions::vertexArrayObjectOES);
1028         map["GL_OES_vertex_type_10_10_10_2"] = enableableExtension(&Extensions::vertexAttribType1010102OES);
1029         map["GL_KHR_debug"] = esOnlyExtension(&Extensions::debug);
1030         map["GL_OES_texture_border_clamp"] = enableableExtension(&Extensions::textureBorderClampOES);
1031         map["GL_EXT_texture_border_clamp"] = enableableExtension(&Extensions::textureBorderClampEXT);
1032         map["GL_KHR_no_error"] = esOnlyExtension(&Extensions::noError);
1033         map["GL_ANGLE_lossy_etc_decode"] = enableableExtension(&Extensions::lossyETCDecode);
1034         map["GL_CHROMIUM_bind_uniform_location"] = esOnlyExtension(&Extensions::bindUniformLocation);
1035         map["GL_CHROMIUM_sync_query"] = enableableExtension(&Extensions::syncQuery);
1036         map["GL_CHROMIUM_copy_texture"] = esOnlyExtension(&Extensions::copyTexture);
1037         map["GL_CHROMIUM_copy_compressed_texture"] = esOnlyExtension(&Extensions::copyCompressedTexture);
1038         map["GL_ANGLE_copy_texture_3d"] = enableableExtension(&Extensions::copyTexture3d);
1039         map["GL_ANGLE_webgl_compatibility"] = esOnlyExtension(&Extensions::webglCompatibility);
1040         map["GL_ANGLE_request_extension"] = esOnlyExtension(&Extensions::requestExtension);
1041         map["GL_CHROMIUM_bind_generates_resource"] = esOnlyExtension(&Extensions::bindGeneratesResource);
1042         map["GL_ANGLE_robust_client_memory"] = esOnlyExtension(&Extensions::robustClientMemory);
1043         map["GL_EXT_texture_sRGB_decode"] = esOnlyExtension(&Extensions::textureSRGBDecode);
1044         map["GL_EXT_texture_format_sRGB_override"] = esOnlyExtension(&Extensions::textureSRGBOverride);
1045         map["GL_EXT_sRGB_write_control"] = esOnlyExtension(&Extensions::sRGBWriteControl);
1046         map["GL_CHROMIUM_color_buffer_float_rgb"] = enableableExtension(&Extensions::colorBufferFloatRGB);
1047         map["GL_CHROMIUM_color_buffer_float_rgba"] = enableableExtension(&Extensions::colorBufferFloatRGBA);
1048         map["GL_EXT_multisample_compatibility"] = esOnlyExtension(&Extensions::multisampleCompatibility);
1049         map["GL_CHROMIUM_framebuffer_mixed_samples"] = esOnlyExtension(&Extensions::framebufferMixedSamples);
1050         map["GL_EXT_texture_norm16"] = enableableExtension(&Extensions::textureNorm16);
1051         map["GL_OES_surfaceless_context"] = esOnlyExtension(&Extensions::surfacelessContextOES);
1052         map["GL_ANGLE_client_arrays"] = esOnlyExtension(&Extensions::clientArrays);
1053         map["GL_ANGLE_robust_resource_initialization"] = esOnlyExtension(&Extensions::robustResourceInitialization);
1054         map["GL_ANGLE_program_cache_control"] = esOnlyExtension(&Extensions::programCacheControl);
1055         map["GL_ANGLE_texture_rectangle"] = enableableDisablableExtension(&Extensions::textureRectangle);
1056         map["GL_EXT_geometry_shader"] = enableableExtension(&Extensions::geometryShaderEXT);
1057         map["GL_OES_geometry_shader"] = enableableExtension(&Extensions::geometryShaderOES);
1058         map["GL_KHR_parallel_shader_compile"] = enableableExtension(&Extensions::parallelShaderCompile);
1059         map["GL_EXT_separate_shader_objects"] = enableableExtension(&Extensions::separateShaderObjects);
1060         map["GL_OES_texture_storage_multisample_2d_array"] = enableableExtension(&Extensions::textureStorageMultisample2DArrayOES);
1061         map["GL_ANGLE_multiview_multisample"] = enableableExtension(&Extensions::multiviewMultisample);
1062         map["GL_KHR_blend_equation_advanced"] = esOnlyExtension(&Extensions::blendEquationAdvancedKHR);
1063         map["GL_EXT_blend_func_extended"] = enableableExtension(&Extensions::blendFuncExtended);
1064         map["GL_EXT_float_blend"] = enableableExtension(&Extensions::floatBlend);
1065         map["GL_ANGLE_texture_multisample"] = enableableExtension(&Extensions::textureMultisample);
1066         map["GL_ANGLE_multi_draw"] = enableableExtension(&Extensions::multiDraw);
1067         map["GL_ANGLE_provoking_vertex"] = enableableExtension(&Extensions::provokingVertex);
1068         map["GL_CHROMIUM_texture_filtering_hint"] = enableableExtension(&Extensions::textureFilteringCHROMIUM);
1069         map["GL_CHROMIUM_lose_context"] = enableableExtension(&Extensions::loseContextCHROMIUM);
1070         map["GL_ANGLE_texture_external_update"] = enableableExtension(&Extensions::textureExternalUpdateANGLE);
1071         map["GL_ANGLE_base_vertex_base_instance"] = enableableExtension(&Extensions::baseVertexBaseInstance);
1072         map["GL_ANGLE_get_image"] = enableableExtension(&Extensions::getImageANGLE);
1073         map["GL_OES_draw_elements_base_vertex"] = enableableExtension(&Extensions::drawElementsBaseVertexOES);
1074         map["GL_EXT_draw_elements_base_vertex"] = enableableExtension(&Extensions::drawElementsBaseVertexEXT);
1075         map["GL_EXT_gpu_shader5"] = enableableExtension(&Extensions::gpuShader5EXT);
1076         map["GL_APPLE_clip_distance"] = enableableExtension(&Extensions::clipDistanceAPPLE);
1077         map["GL_EXT_clip_control"] = enableableExtension(&Extensions::clipControlEXT);
1078         map["GL_EXT_EGL_image_array"] = enableableExtension(&Extensions::eglImageArray);
1079         map["GL_EXT_buffer_storage"] = enableableExtension(&Extensions::bufferStorageEXT);
1080         map["GL_EXT_external_buffer"] = enableableExtension(&Extensions::externalBufferEXT);
1081         map["GL_OES_texture_stencil8"] = enableableExtension(&Extensions::stencilIndex8);
1082         map["GL_OES_sample_shading"] = enableableExtension(&Extensions::sampleShadingOES);
1083         map["GL_OES_shader_multisample_interpolation"] = enableableExtension(&Extensions::multisampleInterpolationOES);
1084         map["GL_OES_shader_image_atomic"] = enableableExtension(&Extensions::shaderImageAtomicOES);
1085         map["GL_OES_sample_variables"] = enableableExtension(&Extensions::sampleVariablesOES);
1086         map["GL_EXT_shader_framebuffer_fetch_non_coherent"] = enableableExtension(&Extensions::shaderFramebufferFetchNonCoherentEXT);
1087         map["GL_NV_robustness_video_memory_purge"] = esOnlyExtension(&Extensions::robustnessVideoMemoryPurgeNV);
1088         map["GL_ANGLE_get_tex_level_parameter"] = enableableExtension(&Extensions::getTexLevelParameterANGLE);
1089         map["GL_EXT_copy_image"] = enableableExtension(&Extensions::copyImageEXT);
1090         map["GL_OES_texture_buffer"] = enableableExtension(&Extensions::textureBufferOES);
1091         map["GL_EXT_texture_buffer"] = enableableExtension(&Extensions::textureBufferEXT);
1092         map["GL_EXT_YUV_target"] = enableableExtension(&Extensions::yuvTargetEXT);
1093         map["GL_OES_shader_io_blocks"] = enableableExtension(&Extensions::shaderIoBlocksOES);
1094         map["GL_EXT_shader_io_blocks"] = enableableExtension(&Extensions::shaderIoBlocksEXT);
1095         map["GL_EXT_clip_cull_distance"] = enableableExtension(&Extensions::clipCullDistanceEXT);
1096         map["GL_ANGLE_get_serialized_context_string"] = esOnlyExtension(&Extensions::getSerializedContextStringANGLE);
1097         map["GL_EXT_primitive_bounding_box"] = esOnlyExtension(&Extensions::primitiveBoundingBoxEXT);
1098         map["GL_ANGLE_relaxed_vertex_attribute_type"] = esOnlyExtension(&Extensions::relaxedVertexAttributeTypeANGLE);
1099         map["GL_ANGLE_yuv_internal_format"] = enableableExtension(&Extensions::yuvInternalFormatANGLE);
1100         // GLES1 extensions
1101         map["GL_OES_point_size_array"] = enableableExtension(&Extensions::pointSizeArrayOES);
1102         map["GL_OES_texture_cube_map"] = enableableExtension(&Extensions::textureCubeMapOES);
1103         map["GL_OES_point_sprite"] = enableableExtension(&Extensions::pointSpriteOES);
1104         map["GL_OES_draw_texture"] = enableableExtension(&Extensions::drawTextureOES);
1105         map["GL_OES_framebuffer_object"] = enableableExtension(&Extensions::framebufferObjectOES);
1106         map["GL_ANGLE_memory_size"] = enableableExtension(&Extensions::memorySize);
1107         map["GL_EXT_shader_non_constant_global_initializers"] = enableableExtension(&Extensions::shaderNonConstGlobalInitializersEXT);
1108         map["GL_WEBGL_video_texture"] = enableableExtension(&Extensions::webglVideoTexture);
1109         map["GL_OES_texture_cube_map_array"] = enableableExtension(&Extensions::textureCubeMapArrayOES);
1110         map["GL_EXT_texture_cube_map_array"] = enableableExtension(&Extensions::textureCubeMapArrayEXT);
1111         map["GL_EXT_shadow_samplers"] = enableableExtension(&Extensions::shadowSamplersEXT);
1112         map["GL_EXT_tessellation_shader"] = enableableExtension(&Extensions::tessellationShaderEXT);
1113         // clang-format on
1114 
1115 #if defined(ANGLE_ENABLE_ASSERTS)
1116         // Verify all extension strings start with GL_
1117         for (const auto &extension : map)
1118         {
1119             ASSERT(extension.first.rfind("GL_", 0) == 0);
1120         }
1121 #endif
1122 
1123         return map;
1124     };
1125 
1126     static const angle::base::NoDestructor<ExtensionInfoMap> extensionInfo(buildExtensionInfoMap());
1127     return *extensionInfo;
1128 }
1129 
1130 TypePrecision::TypePrecision() = default;
1131 
1132 TypePrecision::TypePrecision(const TypePrecision &other) = default;
1133 
1134 TypePrecision &TypePrecision::operator=(const TypePrecision &other) = default;
1135 
setIEEEFloat()1136 void TypePrecision::setIEEEFloat()
1137 {
1138     range     = {{127, 127}};
1139     precision = 23;
1140 }
1141 
setTwosComplementInt(unsigned int bits)1142 void TypePrecision::setTwosComplementInt(unsigned int bits)
1143 {
1144     range     = {{static_cast<GLint>(bits) - 1, static_cast<GLint>(bits) - 2}};
1145     precision = 0;
1146 }
1147 
setSimulatedFloat(unsigned int r,unsigned int p)1148 void TypePrecision::setSimulatedFloat(unsigned int r, unsigned int p)
1149 {
1150     range     = {{static_cast<GLint>(r), static_cast<GLint>(r)}};
1151     precision = static_cast<GLint>(p);
1152 }
1153 
setSimulatedInt(unsigned int r)1154 void TypePrecision::setSimulatedInt(unsigned int r)
1155 {
1156     range     = {{static_cast<GLint>(r), static_cast<GLint>(r)}};
1157     precision = 0;
1158 }
1159 
get(GLint * returnRange,GLint * returnPrecision) const1160 void TypePrecision::get(GLint *returnRange, GLint *returnPrecision) const
1161 {
1162     std::copy(range.begin(), range.end(), returnRange);
1163     *returnPrecision = precision;
1164 }
1165 
1166 Caps::Caps()                  = default;
1167 Caps::Caps(const Caps &other) = default;
1168 Caps::~Caps()                 = default;
1169 Caps &Caps::operator=(const Caps &other) = default;
1170 
GenerateMinimumCaps(const Version & clientVersion,const Extensions & extensions)1171 Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensions)
1172 {
1173     Caps caps;
1174 
1175     // GLES1 emulation (Minimums taken from Table 6.20 / 6.22 (ES 1.1 spec))
1176     if (clientVersion < Version(2, 0))
1177     {
1178         caps.maxMultitextureUnits = 2;
1179         caps.maxLights            = 8;
1180         caps.maxClipPlanes        = 1;
1181 
1182         caps.maxModelviewMatrixStackDepth  = 16;
1183         caps.maxProjectionMatrixStackDepth = 2;
1184         caps.maxTextureMatrixStackDepth    = 2;
1185 
1186         caps.minSmoothPointSize = 1.0f;
1187         caps.maxSmoothPointSize = 1.0f;
1188     }
1189 
1190     if (clientVersion >= Version(2, 0))
1191     {
1192         // Table 6.18
1193         caps.max2DTextureSize      = 64;
1194         caps.maxCubeMapTextureSize = 16;
1195         caps.maxViewportWidth      = caps.max2DTextureSize;
1196         caps.maxViewportHeight     = caps.max2DTextureSize;
1197         caps.minAliasedPointSize   = 1;
1198         caps.maxAliasedPointSize   = 1;
1199         caps.minAliasedLineWidth   = 1;
1200         caps.maxAliasedLineWidth   = 1;
1201 
1202         // Table 6.19
1203         caps.vertexHighpFloat.setSimulatedFloat(62, 16);
1204         caps.vertexMediumpFloat.setSimulatedFloat(14, 10);
1205         caps.vertexLowpFloat.setSimulatedFloat(1, 8);
1206         caps.vertexHighpInt.setSimulatedInt(16);
1207         caps.vertexMediumpInt.setSimulatedInt(10);
1208         caps.vertexLowpInt.setSimulatedInt(8);
1209         caps.fragmentHighpFloat.setSimulatedFloat(62, 16);
1210         caps.fragmentMediumpFloat.setSimulatedFloat(14, 10);
1211         caps.fragmentLowpFloat.setSimulatedFloat(1, 8);
1212         caps.fragmentHighpInt.setSimulatedInt(16);
1213         caps.fragmentMediumpInt.setSimulatedInt(10);
1214         caps.fragmentLowpInt.setSimulatedInt(8);
1215 
1216         // Table 6.20
1217         caps.maxVertexAttributes                              = 8;
1218         caps.maxVertexUniformVectors                          = 128;
1219         caps.maxVaryingVectors                                = 8;
1220         caps.maxCombinedTextureImageUnits                     = 8;
1221         caps.maxShaderTextureImageUnits[ShaderType::Fragment] = 8;
1222         caps.maxFragmentUniformVectors                        = 16;
1223         caps.maxRenderbufferSize                              = 1;
1224 
1225         // Table 3.35
1226         caps.maxSamples = 4;
1227     }
1228 
1229     if (clientVersion >= Version(3, 0))
1230     {
1231         // Table 6.28
1232         caps.maxElementIndex       = (1 << 24) - 1;
1233         caps.max3DTextureSize      = 256;
1234         caps.max2DTextureSize      = 2048;
1235         caps.maxArrayTextureLayers = 256;
1236         caps.maxLODBias            = 2.0f;
1237         caps.maxCubeMapTextureSize = 2048;
1238         caps.maxRenderbufferSize   = 2048;
1239         caps.maxDrawBuffers        = 4;
1240         caps.maxColorAttachments   = 4;
1241         caps.maxViewportWidth      = caps.max2DTextureSize;
1242         caps.maxViewportHeight     = caps.max2DTextureSize;
1243 
1244         // Table 6.29
1245         caps.compressedTextureFormats.push_back(GL_COMPRESSED_R11_EAC);
1246         caps.compressedTextureFormats.push_back(GL_COMPRESSED_SIGNED_R11_EAC);
1247         caps.compressedTextureFormats.push_back(GL_COMPRESSED_RG11_EAC);
1248         caps.compressedTextureFormats.push_back(GL_COMPRESSED_SIGNED_RG11_EAC);
1249         caps.compressedTextureFormats.push_back(GL_COMPRESSED_RGB8_ETC2);
1250         caps.compressedTextureFormats.push_back(GL_COMPRESSED_SRGB8_ETC2);
1251         caps.compressedTextureFormats.push_back(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
1252         caps.compressedTextureFormats.push_back(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
1253         caps.compressedTextureFormats.push_back(GL_COMPRESSED_RGBA8_ETC2_EAC);
1254         caps.compressedTextureFormats.push_back(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
1255         caps.vertexHighpFloat.setIEEEFloat();
1256         caps.vertexHighpInt.setTwosComplementInt(32);
1257         caps.vertexMediumpInt.setTwosComplementInt(16);
1258         caps.vertexLowpInt.setTwosComplementInt(8);
1259         caps.fragmentHighpFloat.setIEEEFloat();
1260         caps.fragmentHighpInt.setSimulatedInt(32);
1261         caps.fragmentMediumpInt.setTwosComplementInt(16);
1262         caps.fragmentLowpInt.setTwosComplementInt(8);
1263         caps.maxServerWaitTimeout = 0;
1264 
1265         // Table 6.31
1266         caps.maxVertexAttributes                            = 16;
1267         caps.maxShaderUniformComponents[ShaderType::Vertex] = 1024;
1268         caps.maxVertexUniformVectors                        = 256;
1269         caps.maxShaderUniformBlocks[ShaderType::Vertex]     = limits::kMinimumShaderUniformBlocks;
1270         caps.maxVertexOutputComponents = limits::kMinimumVertexOutputComponents;
1271         caps.maxShaderTextureImageUnits[ShaderType::Vertex] = 16;
1272 
1273         // Table 6.32
1274         caps.maxShaderUniformComponents[ShaderType::Fragment] = 896;
1275         caps.maxFragmentUniformVectors                        = 224;
1276         caps.maxShaderUniformBlocks[ShaderType::Fragment]     = limits::kMinimumShaderUniformBlocks;
1277         caps.maxFragmentInputComponents                       = 60;
1278         caps.maxShaderTextureImageUnits[ShaderType::Fragment] = 16;
1279         caps.minProgramTexelOffset                            = -8;
1280         caps.maxProgramTexelOffset                            = 7;
1281 
1282         // Table 6.33
1283         caps.maxUniformBufferBindings     = 24;
1284         caps.maxUniformBlockSize          = 16384;
1285         caps.uniformBufferOffsetAlignment = 256;
1286         caps.maxCombinedUniformBlocks     = 24;
1287         caps.maxVaryingComponents         = 60;
1288         caps.maxVaryingVectors            = 15;
1289         caps.maxCombinedTextureImageUnits = 32;
1290 
1291         // Table 6.34
1292         caps.maxTransformFeedbackInterleavedComponents = 64;
1293         caps.maxTransformFeedbackSeparateAttributes    = 4;
1294         caps.maxTransformFeedbackSeparateComponents    = 4;
1295     }
1296 
1297     if (clientVersion >= Version(3, 1))
1298     {
1299         // Table 20.40
1300         caps.maxFramebufferWidth    = 2048;
1301         caps.maxFramebufferHeight   = 2048;
1302         caps.maxFramebufferSamples  = 4;
1303         caps.maxSampleMaskWords     = 1;
1304         caps.maxColorTextureSamples = 1;
1305         caps.maxDepthTextureSamples = 1;
1306         caps.maxIntegerSamples      = 1;
1307 
1308         // Table 20.41
1309         caps.maxVertexAttribRelativeOffset = 2047;
1310         caps.maxVertexAttribBindings       = 16;
1311         caps.maxVertexAttribStride         = 2048;
1312 
1313         // Table 20.43
1314         caps.maxShaderAtomicCounterBuffers[ShaderType::Vertex] = 0;
1315         caps.maxShaderAtomicCounters[ShaderType::Vertex]       = 0;
1316         caps.maxShaderImageUniforms[ShaderType::Vertex]        = 0;
1317         caps.maxShaderStorageBlocks[ShaderType::Vertex]        = 0;
1318 
1319         // Table 20.44
1320         caps.maxShaderUniformComponents[ShaderType::Fragment]    = 1024;
1321         caps.maxFragmentUniformVectors                           = 256;
1322         caps.maxShaderAtomicCounterBuffers[ShaderType::Fragment] = 0;
1323         caps.maxShaderAtomicCounters[ShaderType::Fragment]       = 0;
1324         caps.maxShaderImageUniforms[ShaderType::Fragment]        = 0;
1325         caps.maxShaderStorageBlocks[ShaderType::Fragment]        = 0;
1326         caps.minProgramTextureGatherOffset                       = 0;
1327         caps.maxProgramTextureGatherOffset                       = 0;
1328 
1329         // Table 20.45
1330         caps.maxComputeWorkGroupCount                        = {{65535, 65535, 65535}};
1331         caps.maxComputeWorkGroupSize                         = {{128, 128, 64}};
1332         caps.maxComputeWorkGroupInvocations                  = 12;
1333         caps.maxShaderUniformBlocks[ShaderType::Compute]     = limits::kMinimumShaderUniformBlocks;
1334         caps.maxShaderTextureImageUnits[ShaderType::Compute] = 16;
1335         caps.maxComputeSharedMemorySize                      = 16384;
1336         caps.maxShaderUniformComponents[ShaderType::Compute] = 1024;
1337         caps.maxShaderAtomicCounterBuffers[ShaderType::Compute] = 1;
1338         caps.maxShaderAtomicCounters[ShaderType::Compute]       = 8;
1339         caps.maxShaderImageUniforms[ShaderType::Compute]        = 4;
1340         caps.maxShaderStorageBlocks[ShaderType::Compute]        = 4;
1341 
1342         // Table 20.46
1343         caps.maxUniformBufferBindings         = 36;
1344         caps.maxCombinedTextureImageUnits     = 48;
1345         caps.maxCombinedShaderOutputResources = 4;
1346 
1347         // Table 20.47
1348         caps.maxUniformLocations                = 1024;
1349         caps.maxAtomicCounterBufferBindings     = 1;
1350         caps.maxAtomicCounterBufferSize         = 32;
1351         caps.maxCombinedAtomicCounterBuffers    = 1;
1352         caps.maxCombinedAtomicCounters          = 8;
1353         caps.maxImageUnits                      = 4;
1354         caps.maxCombinedImageUniforms           = 4;
1355         caps.maxShaderStorageBufferBindings     = 4;
1356         caps.maxShaderStorageBlockSize          = 1 << 27;
1357         caps.maxCombinedShaderStorageBlocks     = 4;
1358         caps.shaderStorageBufferOffsetAlignment = 256;
1359     }
1360 
1361     if (extensions.textureRectangle)
1362     {
1363         caps.maxRectangleTextureSize = 64;
1364     }
1365 
1366     if (extensions.geometryShaderAny())
1367     {
1368         // Table 20.40 (GL_EXT_geometry_shader)
1369         caps.maxFramebufferLayers = 256;
1370         caps.layerProvokingVertex = GL_LAST_VERTEX_CONVENTION_EXT;
1371 
1372         // Table 20.43gs (GL_EXT_geometry_shader)
1373         caps.maxShaderUniformComponents[ShaderType::Geometry] = 1024;
1374         caps.maxShaderUniformBlocks[ShaderType::Geometry]     = limits::kMinimumShaderUniformBlocks;
1375         caps.maxGeometryInputComponents                       = 64;
1376         caps.maxGeometryOutputComponents                      = 64;
1377         caps.maxGeometryOutputVertices                        = 256;
1378         caps.maxGeometryTotalOutputComponents                 = 1024;
1379         caps.maxShaderTextureImageUnits[ShaderType::Geometry] = 16;
1380         caps.maxShaderAtomicCounterBuffers[ShaderType::Geometry] = 0;
1381         caps.maxShaderAtomicCounters[ShaderType::Geometry]       = 0;
1382         caps.maxShaderStorageBlocks[ShaderType::Geometry]        = 0;
1383         caps.maxGeometryShaderInvocations                        = 32;
1384 
1385         // Table 20.46 (GL_EXT_geometry_shader)
1386         caps.maxShaderImageUniforms[ShaderType::Geometry] = 0;
1387 
1388         // Table 20.46 (GL_EXT_geometry_shader)
1389         caps.maxUniformBufferBindings     = 48;
1390         caps.maxCombinedUniformBlocks     = 36;
1391         caps.maxCombinedTextureImageUnits = 64;
1392     }
1393 
1394     if (extensions.tessellationShaderEXT)
1395     {
1396         // Table 20.43 "Implementation Dependent Tessellation Shader Limits"
1397         caps.maxTessControlInputComponents                          = 64;
1398         caps.maxTessControlOutputComponents                         = 64;
1399         caps.maxShaderTextureImageUnits[ShaderType::TessControl]    = 16;
1400         caps.maxShaderUniformComponents[ShaderType::TessControl]    = 1024;
1401         caps.maxTessControlTotalOutputComponents                    = 2048;
1402         caps.maxShaderImageUniforms[ShaderType::TessControl]        = 0;
1403         caps.maxShaderAtomicCounters[ShaderType::TessControl]       = 0;
1404         caps.maxShaderAtomicCounterBuffers[ShaderType::TessControl] = 0;
1405 
1406         caps.maxTessPatchComponents = 120;
1407         caps.maxPatchVertices       = 32;
1408         caps.maxTessGenLevel        = 64;
1409 
1410         caps.maxTessEvaluationInputComponents                          = 64;
1411         caps.maxTessEvaluationOutputComponents                         = 64;
1412         caps.maxShaderTextureImageUnits[ShaderType::TessEvaluation]    = 16;
1413         caps.maxShaderUniformComponents[ShaderType::TessEvaluation]    = 1024;
1414         caps.maxShaderImageUniforms[ShaderType::TessEvaluation]        = 0;
1415         caps.maxShaderAtomicCounters[ShaderType::TessEvaluation]       = 0;
1416         caps.maxShaderAtomicCounterBuffers[ShaderType::TessEvaluation] = 0;
1417 
1418         // Table 20.46 "Implementation Dependent Aggregate Shader Limits"
1419         caps.maxUniformBufferBindings     = 72;
1420         caps.maxCombinedUniformBlocks     = 60;
1421         caps.maxCombinedTextureImageUnits = 96;
1422     }
1423 
1424     for (ShaderType shaderType : AllShaderTypes())
1425     {
1426         caps.maxCombinedShaderUniformComponents[shaderType] =
1427             caps.maxShaderUniformBlocks[shaderType] *
1428                 static_cast<GLuint>(caps.maxUniformBlockSize / 4) +
1429             caps.maxShaderUniformComponents[shaderType];
1430     }
1431 
1432     return caps;
1433 }
1434 }  // namespace gl
1435 
1436 namespace egl
1437 {
1438 
1439 Caps::Caps() = default;
1440 
1441 DisplayExtensions::DisplayExtensions() = default;
1442 
getStrings() const1443 std::vector<std::string> DisplayExtensions::getStrings() const
1444 {
1445     std::vector<std::string> extensionStrings;
1446 
1447     // clang-format off
1448     //                   | Extension name                                       | Supported flag                    | Output vector   |
1449     InsertExtensionString("EGL_EXT_create_context_robustness",                   createContextRobustness,            &extensionStrings);
1450     InsertExtensionString("EGL_ANGLE_d3d_share_handle_client_buffer",            d3dShareHandleClientBuffer,         &extensionStrings);
1451     InsertExtensionString("EGL_ANGLE_d3d_texture_client_buffer",                 d3dTextureClientBuffer,             &extensionStrings);
1452     InsertExtensionString("EGL_ANGLE_surface_d3d_texture_2d_share_handle",       surfaceD3DTexture2DShareHandle,     &extensionStrings);
1453     InsertExtensionString("EGL_ANGLE_query_surface_pointer",                     querySurfacePointer,                &extensionStrings);
1454     InsertExtensionString("EGL_ANGLE_window_fixed_size",                         windowFixedSize,                    &extensionStrings);
1455     InsertExtensionString("EGL_ANGLE_keyed_mutex",                               keyedMutex,                         &extensionStrings);
1456     InsertExtensionString("EGL_ANGLE_surface_orientation",                       surfaceOrientation,                 &extensionStrings);
1457     InsertExtensionString("EGL_ANGLE_direct_composition",                        directComposition,                  &extensionStrings);
1458     InsertExtensionString("EGL_ANGLE_windows_ui_composition",                    windowsUIComposition,               &extensionStrings);
1459     InsertExtensionString("EGL_NV_post_sub_buffer",                              postSubBuffer,                      &extensionStrings);
1460     InsertExtensionString("EGL_KHR_create_context",                              createContext,                      &extensionStrings);
1461     InsertExtensionString("EGL_KHR_image",                                       image,                              &extensionStrings);
1462     InsertExtensionString("EGL_KHR_image_base",                                  imageBase,                          &extensionStrings);
1463     InsertExtensionString("EGL_KHR_image_pixmap",                                imagePixmap,                        &extensionStrings);
1464     InsertExtensionString("EGL_EXT_image_gl_colorspace",                         imageGlColorspace,                  &extensionStrings);
1465     InsertExtensionString("EGL_KHR_gl_colorspace",                               glColorspace,                       &extensionStrings);
1466     InsertExtensionString("EGL_EXT_gl_colorspace_scrgb",                         glColorspaceScrgb,                  &extensionStrings);
1467     InsertExtensionString("EGL_EXT_gl_colorspace_scrgb_linear",                  glColorspaceScrgbLinear,            &extensionStrings);
1468     InsertExtensionString("EGL_EXT_gl_colorspace_display_p3",                    glColorspaceDisplayP3,              &extensionStrings);
1469     InsertExtensionString("EGL_EXT_gl_colorspace_display_p3_linear",             glColorspaceDisplayP3Linear,        &extensionStrings);
1470     InsertExtensionString("EGL_EXT_gl_colorspace_display_p3_passthrough",        glColorspaceDisplayP3Passthrough,   &extensionStrings);
1471     InsertExtensionString("EGL_KHR_gl_texture_2D_image",                         glTexture2DImage,                   &extensionStrings);
1472     InsertExtensionString("EGL_KHR_gl_texture_cubemap_image",                    glTextureCubemapImage,              &extensionStrings);
1473     InsertExtensionString("EGL_KHR_gl_texture_3D_image",                         glTexture3DImage,                   &extensionStrings);
1474     InsertExtensionString("EGL_KHR_gl_renderbuffer_image",                       glRenderbufferImage,                &extensionStrings);
1475     InsertExtensionString("EGL_KHR_get_all_proc_addresses",                      getAllProcAddresses,                &extensionStrings);
1476     InsertExtensionString("EGL_KHR_stream",                                      stream,                             &extensionStrings);
1477     InsertExtensionString("EGL_KHR_stream_consumer_gltexture",                   streamConsumerGLTexture,            &extensionStrings);
1478     InsertExtensionString("EGL_NV_stream_consumer_gltexture_yuv",                streamConsumerGLTextureYUV,         &extensionStrings);
1479     InsertExtensionString("EGL_KHR_fence_sync",                                  fenceSync,                          &extensionStrings);
1480     InsertExtensionString("EGL_KHR_wait_sync",                                   waitSync,                           &extensionStrings);
1481     InsertExtensionString("EGL_ANGLE_flexible_surface_compatibility",            flexibleSurfaceCompatibility,       &extensionStrings);
1482     InsertExtensionString("EGL_ANGLE_stream_producer_d3d_texture",               streamProducerD3DTexture,           &extensionStrings);
1483     InsertExtensionString("EGL_ANGLE_create_context_webgl_compatibility",        createContextWebGLCompatibility,    &extensionStrings);
1484     InsertExtensionString("EGL_CHROMIUM_create_context_bind_generates_resource", createContextBindGeneratesResource, &extensionStrings);
1485     InsertExtensionString("EGL_CHROMIUM_sync_control",                           syncControlCHROMIUM,                &extensionStrings);
1486     InsertExtensionString("EGL_ANGLE_sync_control_rate",                         syncControlRateANGLE,               &extensionStrings);
1487     InsertExtensionString("EGL_KHR_swap_buffers_with_damage",                    swapBuffersWithDamage,              &extensionStrings);
1488     InsertExtensionString("EGL_EXT_pixel_format_float",                          pixelFormatFloat,                   &extensionStrings);
1489     InsertExtensionString("EGL_KHR_surfaceless_context",                         surfacelessContext,                 &extensionStrings);
1490     InsertExtensionString("EGL_ANGLE_display_texture_share_group",               displayTextureShareGroup,           &extensionStrings);
1491     InsertExtensionString("EGL_ANGLE_display_semaphore_share_group",             displaySemaphoreShareGroup,         &extensionStrings);
1492     InsertExtensionString("EGL_ANGLE_create_context_client_arrays",              createContextClientArrays,          &extensionStrings);
1493     InsertExtensionString("EGL_ANGLE_program_cache_control",                     programCacheControl,                &extensionStrings);
1494     InsertExtensionString("EGL_ANGLE_robust_resource_initialization",            robustResourceInitialization,       &extensionStrings);
1495     InsertExtensionString("EGL_ANGLE_iosurface_client_buffer",                   iosurfaceClientBuffer,              &extensionStrings);
1496     InsertExtensionString("EGL_ANGLE_metal_texture_client_buffer",               mtlTextureClientBuffer,             &extensionStrings);
1497     InsertExtensionString("EGL_ANGLE_create_context_extensions_enabled",         createContextExtensionsEnabled,     &extensionStrings);
1498     InsertExtensionString("EGL_ANDROID_presentation_time",                       presentationTime,                   &extensionStrings);
1499     InsertExtensionString("EGL_ANDROID_blob_cache",                              blobCache,                          &extensionStrings);
1500     InsertExtensionString("EGL_ANDROID_framebuffer_target",                      framebufferTargetANDROID,           &extensionStrings);
1501     InsertExtensionString("EGL_ANDROID_image_native_buffer",                     imageNativeBuffer,                  &extensionStrings);
1502     InsertExtensionString("EGL_ANDROID_get_frame_timestamps",                    getFrameTimestamps,                 &extensionStrings);
1503     InsertExtensionString("EGL_ANDROID_recordable",                              recordable,                         &extensionStrings);
1504     InsertExtensionString("EGL_ANGLE_power_preference",                          powerPreference,                    &extensionStrings);
1505     InsertExtensionString("EGL_ANGLE_image_d3d11_texture",                       imageD3D11Texture,                  &extensionStrings);
1506     InsertExtensionString("EGL_ANDROID_create_native_client_buffer",             createNativeClientBufferANDROID,    &extensionStrings);
1507     InsertExtensionString("EGL_ANDROID_get_native_client_buffer",                getNativeClientBufferANDROID,       &extensionStrings);
1508     InsertExtensionString("EGL_ANDROID_native_fence_sync",                       nativeFenceSyncANDROID,             &extensionStrings);
1509     InsertExtensionString("EGL_ANGLE_create_context_backwards_compatible",       createContextBackwardsCompatible,   &extensionStrings);
1510     InsertExtensionString("EGL_KHR_no_config_context",                           noConfigContext,                    &extensionStrings);
1511     InsertExtensionString("EGL_IMG_context_priority",                            contextPriority,                    &extensionStrings);
1512     InsertExtensionString("EGL_KHR_create_context_no_error",                     createContextNoError,               &extensionStrings);
1513     InsertExtensionString("EGL_EXT_image_dma_buf_import",                        imageDmaBufImportEXT,               &extensionStrings);
1514     InsertExtensionString("EGL_EXT_image_dma_buf_import_modifiers",              imageDmaBufImportModifiersEXT,      &extensionStrings);
1515     InsertExtensionString("EGL_NOK_texture_from_pixmap",                         textureFromPixmapNOK,               &extensionStrings);
1516     InsertExtensionString("EGL_NV_robustness_video_memory_purge",                robustnessVideoMemoryPurgeNV,       &extensionStrings);
1517     InsertExtensionString("EGL_KHR_reusable_sync",                               reusableSyncKHR,                    &extensionStrings);
1518     InsertExtensionString("EGL_ANGLE_external_context_and_surface",              externalContextAndSurface,          &extensionStrings);
1519     InsertExtensionString("EGL_EXT_buffer_age",                                  bufferAgeEXT,                       &extensionStrings);
1520     InsertExtensionString("EGL_KHR_mutable_render_buffer",                       mutableRenderBufferKHR,             &extensionStrings);
1521     InsertExtensionString("EGL_EXT_protected_content",                           protectedContentEXT,                &extensionStrings);
1522     // clang-format on
1523 
1524     return extensionStrings;
1525 }
1526 
1527 DeviceExtensions::DeviceExtensions() = default;
1528 
getStrings() const1529 std::vector<std::string> DeviceExtensions::getStrings() const
1530 {
1531     std::vector<std::string> extensionStrings;
1532 
1533     // clang-format off
1534     //                   | Extension name                                 | Supported flag                | Output vector   |
1535     InsertExtensionString("EGL_ANGLE_device_d3d",                          deviceD3D,                      &extensionStrings);
1536     InsertExtensionString("EGL_ANGLE_device_cgl",                          deviceCGL,                      &extensionStrings);
1537     InsertExtensionString("EGL_ANGLE_device_eagl",                         deviceEAGL,                     &extensionStrings);
1538     InsertExtensionString("EGL_ANGLE_device_metal",                        deviceMetal,                    &extensionStrings);
1539 
1540     // clang-format on
1541 
1542     return extensionStrings;
1543 }
1544 
1545 ClientExtensions::ClientExtensions()                              = default;
1546 ClientExtensions::ClientExtensions(const ClientExtensions &other) = default;
1547 
getStrings() const1548 std::vector<std::string> ClientExtensions::getStrings() const
1549 {
1550     std::vector<std::string> extensionStrings;
1551 
1552     // clang-format off
1553     //                   | Extension name                                    | Supported flag                   | Output vector   |
1554     InsertExtensionString("EGL_EXT_client_extensions",                        clientExtensions,                   &extensionStrings);
1555     InsertExtensionString("EGL_EXT_device_query",                             deviceQueryEXT,                        &extensionStrings);
1556     InsertExtensionString("EGL_EXT_platform_base",                            platformBase,                       &extensionStrings);
1557     InsertExtensionString("EGL_EXT_platform_device",                          platformDevice,                     &extensionStrings);
1558     InsertExtensionString("EGL_ANGLE_platform_angle",                         platformANGLE,                      &extensionStrings);
1559     InsertExtensionString("EGL_ANGLE_platform_angle_d3d",                     platformANGLED3D,                   &extensionStrings);
1560     InsertExtensionString("EGL_ANGLE_platform_angle_d3d11on12",               platformANGLED3D11ON12,             &extensionStrings);
1561     InsertExtensionString("EGL_ANGLE_platform_angle_device_type_egl_angle",   platformANGLEDeviceTypeEGLANGLE,    &extensionStrings);
1562     InsertExtensionString("EGL_ANGLE_platform_angle_device_type_swiftshader", platformANGLEDeviceTypeSwiftShader, &extensionStrings);
1563     InsertExtensionString("EGL_ANGLE_platform_angle_opengl",                  platformANGLEOpenGL,                &extensionStrings);
1564     InsertExtensionString("EGL_ANGLE_platform_angle_null",                    platformANGLENULL,                  &extensionStrings);
1565     InsertExtensionString("EGL_ANGLE_platform_angle_vulkan",                  platformANGLEVulkan,                &extensionStrings);
1566     InsertExtensionString("EGL_ANGLE_platform_angle_metal",                   platformANGLEMetal,                 &extensionStrings);
1567     InsertExtensionString("EGL_ANGLE_platform_angle_context_virtualization",  platformANGLEContextVirtualization, &extensionStrings);
1568     InsertExtensionString("EGL_ANGLE_platform_device_context_volatile_eagl",  platformANGLEDeviceContextVolatileEagl, &extensionStrings);
1569     InsertExtensionString("EGL_ANGLE_platform_device_context_volatile_cgl",   platformANGLEDeviceContextVolatileCgl, &extensionStrings);
1570     InsertExtensionString("EGL_ANGLE_device_creation",                        deviceCreation,                     &extensionStrings);
1571     InsertExtensionString("EGL_ANGLE_device_creation_d3d11",                  deviceCreationD3D11,                &extensionStrings);
1572     InsertExtensionString("EGL_ANGLE_x11_visual",                             x11Visual,                          &extensionStrings);
1573     InsertExtensionString("EGL_ANGLE_experimental_present_path",              experimentalPresentPath,            &extensionStrings);
1574     InsertExtensionString("EGL_KHR_client_get_all_proc_addresses",            clientGetAllProcAddresses,          &extensionStrings);
1575     InsertExtensionString("EGL_KHR_debug",                                    debug,                              &extensionStrings);
1576     InsertExtensionString("EGL_ANGLE_feature_control",                        featureControlANGLE,                &extensionStrings);
1577     // clang-format on
1578 
1579     return extensionStrings;
1580 }
1581 
1582 }  // namespace egl
1583