• 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 #ifndef LIBANGLE_CAPS_H_
8 #define LIBANGLE_CAPS_H_
9 
10 #include "angle_gl.h"
11 #include "libANGLE/Version.h"
12 #include "libANGLE/angletypes.h"
13 #include "libANGLE/renderer/Format.h"
14 
15 #include <array>
16 #include <map>
17 #include <set>
18 #include <string>
19 #include <vector>
20 
21 namespace gl
22 {
23 
24 struct Extensions;
25 
26 struct TextureCaps
27 {
28     TextureCaps();
29     TextureCaps(const TextureCaps &other);
30     ~TextureCaps();
31 
32     // Supports for basic texturing: glTexImage, glTexSubImage, etc
33     bool texturable = false;
34 
35     // Support for linear or anisotropic filtering
36     bool filterable = false;
37 
38     // Support for being used as a framebuffer attachment, i.e. glFramebufferTexture2D
39     bool textureAttachment = false;
40 
41     // Support for being used as a renderbuffer format, i.e. glFramebufferRenderbuffer
42     bool renderbuffer = false;
43 
44     // Set of supported sample counts, only guaranteed to be valid in ES3.
45     SupportedSampleSet sampleCounts;
46 
47     // Get the maximum number of samples supported
48     GLuint getMaxSamples() const;
49 
50     // Get the number of supported samples that is at least as many as requested.  Returns 0 if
51     // there are no sample counts available
52     GLuint getNearestSamples(GLuint requestedSamples) const;
53 };
54 
55 TextureCaps GenerateMinimumTextureCaps(GLenum internalFormat,
56                                        const Version &clientVersion,
57                                        const Extensions &extensions);
58 
59 class TextureCapsMap final : angle::NonCopyable
60 {
61   public:
62     TextureCapsMap();
63     ~TextureCapsMap();
64 
65     // These methods are deprecated. Please use angle::Format for new features.
66     void insert(GLenum internalFormat, const TextureCaps &caps);
67     const TextureCaps &get(GLenum internalFormat) const;
68 
69     void clear();
70 
71     // Prefer using angle::Format methods.
72     const TextureCaps &get(angle::FormatID formatID) const;
73     void set(angle::FormatID formatID, const TextureCaps &caps);
74 
75   private:
76     TextureCaps &get(angle::FormatID formatID);
77 
78     // Indexed by angle::FormatID
79     std::array<TextureCaps, angle::kNumANGLEFormats> mFormatData;
80 };
81 
82 void InitMinimumTextureCapsMap(const Version &clientVersion,
83                                const Extensions &extensions,
84                                TextureCapsMap *capsMap);
85 
86 // Returns true if all the formats required to support GL_CHROMIUM_compressed_texture_etc are
87 // present. Does not determine if they are natively supported without decompression.
88 bool DetermineCompressedTextureETCSupport(const TextureCapsMap &textureCaps);
89 
90 struct Extensions
91 {
92     Extensions();
93     Extensions(const Extensions &other);
94 
95     // Generate a vector of supported extension strings
96     std::vector<std::string> getStrings() const;
97 
98     // Set all texture related extension support based on the supported textures.
99     // Determines support for:
100     // GL_OES_packed_depth_stencil
101     // GL_OES_rgb8_rgba8
102     // GL_EXT_texture_format_BGRA8888
103     // GL_EXT_color_buffer_half_float,
104     // GL_OES_texture_half_float, GL_OES_texture_half_float_linear
105     // GL_OES_texture_float, GL_OES_texture_float_linear
106     // GL_EXT_texture_rg
107     // GL_EXT_texture_compression_dxt1, GL_ANGLE_texture_compression_dxt3,
108     // GL_ANGLE_texture_compression_dxt5
109     // GL_KHR_texture_compression_astc_ldr, GL_OES_texture_compression_astc.
110     //     NOTE: GL_KHR_texture_compression_astc_hdr must be enabled separately. Support for the
111     //           HDR profile cannot be determined from the format enums alone.
112     // GL_OES_compressed_ETC1_RGB8_texture
113     // GL_EXT_sRGB
114     // GL_ANGLE_depth_texture, GL_OES_depth32
115     // GL_EXT_color_buffer_float
116     // GL_EXT_texture_norm16
117     // GL_EXT_texture_compression_bptc
118     void setTextureExtensionSupport(const TextureCapsMap &textureCaps);
119 
120     // indicate if any depth texture extension is available
depthTextureAnyExtensions121     bool depthTextureAny() const { return (depthTextureANGLE || depthTextureOES); }
122 
123     // ES2 Extension support
124 
125     // GL_OES_element_index_uint
126     bool elementIndexUint = false;
127 
128     // GL_OES_packed_depth_stencil
129     bool packedDepthStencil = false;
130 
131     // GL_OES_get_program_binary
132     bool getProgramBinary = false;
133 
134     // GL_OES_rgb8_rgba8
135     // Implies that TextureCaps for GL_RGB8 and GL_RGBA8 exist
136     bool rgb8rgba8 = false;
137 
138     // GL_EXT_texture_format_BGRA8888
139     // Implies that TextureCaps for GL_BGRA8 exist
140     bool textureFormatBGRA8888 = false;
141 
142     // GL_EXT_read_format_bgra
143     bool readFormatBGRA = false;
144 
145     // GL_NV_pixel_buffer_object
146     bool pixelBufferObject = false;
147 
148     // GL_OES_mapbuffer and GL_EXT_map_buffer_range
149     bool mapBuffer      = false;
150     bool mapBufferRange = false;
151 
152     // GL_EXT_color_buffer_half_float
153     // Together with GL_OES_texture_half_float in a GLES 2.0 context, implies that half-float
154     // textures are renderable.
155     bool colorBufferHalfFloat = false;
156 
157     // GL_OES_texture_half_float and GL_OES_texture_half_float_linear
158     // Implies that TextureCaps for GL_RGB16F, GL_RGBA16F, GL_ALPHA32F_EXT, GL_LUMINANCE32F_EXT and
159     // GL_LUMINANCE_ALPHA32F_EXT exist
160     bool textureHalfFloat       = false;
161     bool textureHalfFloatLinear = false;
162 
163     // GL_OES_texture_float and GL_OES_texture_float_linear
164     // Implies that TextureCaps for GL_RGB32F, GL_RGBA32F, GL_ALPHA16F_EXT, GL_LUMINANCE16F_EXT and
165     // GL_LUMINANCE_ALPHA16F_EXT exist
166     bool textureFloat       = false;
167     bool textureFloatLinear = false;
168 
169     // GL_EXT_texture_rg
170     // Implies that TextureCaps for GL_R8, GL_RG8 (and floating point R/RG texture formats if
171     // floating point extensions are also present) exist
172     bool textureRG = false;
173 
174     // GL_EXT_texture_compression_dxt1, GL_ANGLE_texture_compression_dxt3 and
175     // GL_ANGLE_texture_compression_dxt5 Implies that TextureCaps exist for
176     // GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
177     // GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE and GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE
178     bool textureCompressionDXT1 = false;
179     bool textureCompressionDXT3 = false;
180     bool textureCompressionDXT5 = false;
181 
182     // GL_EXT_texture_compression_s3tc_srgb
183     // Implies that TextureCaps exist for GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
184     // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, and
185     // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
186     bool textureCompressionS3TCsRGB = false;
187 
188     // GL_KHR_texture_compression_astc_ldr
189     bool textureCompressionASTCLDRKHR = false;
190 
191     // GL_KHR_texture_compression_astc_hdr
192     bool textureCompressionASTCHDRKHR = false;
193 
194     // GL_OES_texture_compression_astc
195     bool textureCompressionASTCOES = false;
196 
197     // GL_EXT_texture_compression_bptc
198     bool textureCompressionBPTC = false;
199 
200     // GL_OES_compressed_ETC1_RGB8_texture
201     // Implies that TextureCaps for GL_ETC1_RGB8_OES exist
202     bool compressedETC1RGB8Texture = false;
203 
204     // OES_compressed_ETC2_RGB8_texture
205     bool compressedETC2RGB8Texture = false;
206 
207     // OES_compressed_ETC2_sRGB8_texture
208     bool compressedETC2sRGB8Texture = false;
209 
210     // OES_compressed_ETC2_punchthroughA_RGBA8_texture
211     bool compressedETC2PunchthroughARGB8Texture = false;
212 
213     // OES_compressed_ETC2_punchthroughA_sRGB8_alpha_texture
214     bool compressedETC2PunchthroughAsRGB8AlphaTexture = false;
215 
216     // OES_compressed_ETC2_RGBA8_texture
217     bool compressedETC2RGBA8Texture = false;
218 
219     // OES_compressed_ETC2_sRGB8_alpha8_texture
220     bool compressedETC2sRGB8Alpha8Texture = false;
221 
222     // OES_compressed_EAC_R11_unsigned_texture
223     bool compressedEACR11UnsignedTexture = false;
224 
225     // OES_compressed_EAC_R11_signed_texture
226     bool compressedEACR11SignedTexture = false;
227 
228     // OES_compressed_EAC_RG11_unsigned_texture
229     bool compressedEACRG11UnsignedTexture = false;
230 
231     // OES_compressed_EAC_RG11_signed_texture
232     bool compressedEACRG11SignedTexture = false;
233 
234     // GL_CHROMIUM_compressed_texture_etc
235     // ONLY exposed if ETC texture formats are natively supported without decompression
236     // Backends should enable this extension explicitly. It is not enabled with
237     // setTextureExtensionSupport, use DetermineCompressedTextureETCSupport to check if all of the
238     // individual formats required to support this extension are available.
239     bool compressedTextureETC = false;
240 
241     // GL_EXT_sRGB
242     // Implies that TextureCaps for GL_SRGB8_ALPHA8 and GL_SRGB8 exist
243     // TODO: Don't advertise this extension in ES3
244     bool sRGB = false;
245 
246     // GL_ANGLE_depth_texture
247     bool depthTextureANGLE = false;
248 
249     // OES_depth_texture
250     bool depthTextureOES = false;
251 
252     // GL_OES_depth24
253     // Allows DEPTH_COMPONENT24_OES as a valid Renderbuffer format.
254     bool depth24OES = false;
255 
256     // GL_OES_depth32
257     // Allows DEPTH_COMPONENT32_OES as a valid Renderbuffer format.
258     bool depth32 = false;
259 
260     // GL_OES_texture_3D
261     bool texture3DOES = false;
262 
263     // GL_EXT_texture_storage
264     bool textureStorage = false;
265 
266     // GL_OES_texture_npot
267     bool textureNPOT = false;
268 
269     // GL_EXT_draw_buffers
270     bool drawBuffers = false;
271 
272     // GL_EXT_texture_filter_anisotropic
273     bool textureFilterAnisotropic = false;
274     GLfloat maxTextureAnisotropy  = 0.0f;
275 
276     // GL_EXT_occlusion_query_boolean
277     bool occlusionQueryBoolean = false;
278 
279     // GL_NV_fence
280     bool fence = false;
281 
282     // GL_EXT_disjoint_timer_query
283     bool disjointTimerQuery            = false;
284     GLuint queryCounterBitsTimeElapsed = 0;
285     GLuint queryCounterBitsTimestamp   = 0;
286 
287     // GL_EXT_robustness
288     bool robustness = false;
289 
290     // GL_KHR_robust_buffer_access_behavior
291     bool robustBufferAccessBehavior = false;
292 
293     // GL_EXT_blend_minmax
294     bool blendMinMax = false;
295 
296     // GL_ANGLE_framebuffer_blit
297     bool framebufferBlit = false;
298 
299     // GL_ANGLE_framebuffer_multisample
300     bool framebufferMultisample = false;
301 
302     // GL_ANGLE_instanced_arrays
303     bool instancedArraysANGLE = false;
304     // GL_EXT_instanced_arrays
305     bool instancedArraysEXT = false;
306     // Any version of the instanced arrays extension
instancedArraysAnyExtensions307     bool instancedArraysAny() const { return (instancedArraysANGLE || instancedArraysEXT); }
308 
309     // GL_ANGLE_pack_reverse_row_order
310     bool packReverseRowOrder = false;
311 
312     // GL_OES_standard_derivatives
313     bool standardDerivatives = false;
314 
315     // GL_EXT_shader_texture_lod
316     bool shaderTextureLOD = false;
317 
318     // GL_EXT_frag_depth
319     bool fragDepth = false;
320 
321     // OVR_multiview
322     bool multiview  = false;
323     GLuint maxViews = 1;
324 
325     // OVR_multiview2
326     bool multiview2 = false;
327 
328     // GL_ANGLE_texture_usage
329     bool textureUsage = false;
330 
331     // GL_ANGLE_translated_shader_source
332     bool translatedShaderSource = false;
333 
334     // GL_OES_fbo_render_mipmap
335     bool fboRenderMipmap = false;
336 
337     // GL_EXT_discard_framebuffer
338     bool discardFramebuffer = false;
339 
340     // EXT_debug_marker
341     bool debugMarker = false;
342 
343     // GL_OES_EGL_image
344     bool eglImage = false;
345 
346     // GL_OES_EGL_image_external
347     bool eglImageExternal = false;
348 
349     // GL_OES_EGL_image_external_essl3
350     bool eglImageExternalEssl3 = false;
351 
352     // GL_OES_EGL_sync
353     bool eglSync = false;
354 
355     // GL_EXT_memory_object
356     bool memoryObject = false;
357 
358     // GL_EXT_memory_object_fd
359     bool memoryObjectFd = false;
360 
361     // GL_EXT_semaphore
362     bool semaphore = false;
363 
364     // GL_EXT_semaphore_fd
365     bool semaphoreFd = false;
366 
367     // NV_EGL_stream_consumer_external
368     bool eglStreamConsumerExternal = false;
369 
370     // EXT_unpack_subimage
371     bool unpackSubimage = false;
372 
373     // NV_pack_subimage
374     bool packSubimage = false;
375 
376     // GL_OES_vertex_half_float
377     bool vertexHalfFloat = false;
378 
379     // GL_OES_vertex_array_object
380     bool vertexArrayObject = false;
381 
382     // GL_KHR_debug
383     bool debug                     = false;
384     GLuint maxDebugMessageLength   = 0;
385     GLuint maxDebugLoggedMessages  = 0;
386     GLuint maxDebugGroupStackDepth = 0;
387     GLuint maxLabelLength          = 0;
388 
389     // KHR_no_error
390     bool noError = false;
391 
392     // GL_ANGLE_lossy_etc_decode
393     bool lossyETCDecode = false;
394 
395     // GL_CHROMIUM_bind_uniform_location
396     bool bindUniformLocation = false;
397 
398     // GL_CHROMIUM_sync_query
399     bool syncQuery = false;
400 
401     // GL_CHROMIUM_copy_texture
402     bool copyTexture = false;
403 
404     // GL_CHROMIUM_copy_compressed_texture
405     bool copyCompressedTexture = false;
406 
407     // GL_ANGLE_copy_texture_3d
408     bool copyTexture3d = false;
409 
410     // GL_ANGLE_webgl_compatibility
411     bool webglCompatibility = false;
412 
413     // GL_ANGLE_request_extension
414     bool requestExtension = false;
415 
416     // GL_CHROMIUM_bind_generates_resource
417     bool bindGeneratesResource = false;
418 
419     // GL_ANGLE_robust_client_memory
420     bool robustClientMemory = false;
421 
422     // GL_OES_texture_border_clamp
423     bool textureBorderClamp = false;
424 
425     // GL_EXT_texture_sRGB_decode
426     bool textureSRGBDecode = false;
427 
428     // GL_EXT_sRGB_write_control
429     bool sRGBWriteControl = false;
430 
431     // GL_CHROMIUM_color_buffer_float_rgb
432     bool colorBufferFloatRGB = false;
433 
434     // GL_CHROMIUM_color_buffer_float_rgba
435     bool colorBufferFloatRGBA = false;
436 
437     // ES3 Extension support
438 
439     // GL_EXT_color_buffer_float
440     bool colorBufferFloat = false;
441 
442     // GL_EXT_multisample_compatibility.
443     // written against ES 3.1 but can apply to earlier versions.
444     bool multisampleCompatibility = false;
445 
446     // GL_CHROMIUM_framebuffer_mixed_samples
447     bool framebufferMixedSamples = false;
448 
449     // GL_EXT_texture_norm16
450     // written against ES 3.1 but can apply to ES 3.0 as well.
451     bool textureNorm16 = false;
452 
453     // GL_CHROMIUM_path_rendering
454     bool pathRendering = false;
455 
456     // GL_OES_surfaceless_context
457     bool surfacelessContext = false;
458 
459     // GL_ANGLE_client_arrays
460     bool clientArrays = false;
461 
462     // GL_ANGLE_robust_resource_initialization
463     bool robustResourceInitialization = false;
464 
465     // GL_ANGLE_program_cache_control
466     bool programCacheControl = false;
467 
468     // GL_ANGLE_texture_rectangle
469     bool textureRectangle = false;
470 
471     // GL_EXT_geometry_shader
472     bool geometryShader = false;
473 
474     // GLES1 emulation: GLES1 extensions
475     // GL_OES_point_size_array
476     bool pointSizeArray = false;
477 
478     // GL_OES_texture_cube_map
479     bool textureCubeMap = false;
480 
481     // GL_OES_point_sprite
482     bool pointSprite = false;
483 
484     // GL_OES_draw_texture
485     bool drawTexture = false;
486 
487     // EGL_ANGLE_explicit_context GL subextensions
488     // GL_ANGLE_explicit_context_gles1
489     bool explicitContextGles1 = false;
490     // GL_ANGLE_explicit_context
491     bool explicitContext = false;
492 
493     // GL_KHR_parallel_shader_compile
494     bool parallelShaderCompile = false;
495 
496     // GL_OES_texture_storage_multisample_2d_array
497     bool textureStorageMultisample2DArray = false;
498 
499     // GL_ANGLE_multiview_multisample
500     bool multiviewMultisample = false;
501 
502     // GL_EXT_blend_func_extended
503     bool blendFuncExtended          = false;
504     GLuint maxDualSourceDrawBuffers = 0;
505 
506     // GL_EXT_float_blend
507     bool floatBlend = false;
508 
509     // GL_ANGLE_memory_size
510     bool memorySize = false;
511 
512     // GL_ANGLE_texture_multisample
513     bool textureMultisample = false;
514 
515     // GL_ANGLE_multi_draw
516     bool multiDraw = false;
517 
518     // GL_ANGLE_provoking_vertex
519     bool provokingVertex = false;
520 
521     // GL_CHROMIUM_lose_context
522     bool loseContextCHROMIUM = false;
523 
524     // GL_ANGLE_texture_external_update
525     bool textureExternalUpdateANGLE = false;
526 
527     // GL_ANGLE_base_vertex_base_instance
528     bool baseVertexBaseInstance = false;
529 };
530 
531 struct ExtensionInfo
532 {
533     // If this extension can be enabled with glRequestExtension (GL_ANGLE_request_extension)
534     bool Requestable = false;
535 
536     // Pointer to a boolean member of the Extensions struct
537     typedef bool(Extensions::*ExtensionBool);
538     ExtensionBool ExtensionsMember = nullptr;
539 };
540 
541 using ExtensionInfoMap = std::map<std::string, ExtensionInfo>;
542 const ExtensionInfoMap &GetExtensionInfoMap();
543 
544 struct Limitations
545 {
546     Limitations();
547 
548     // Renderer doesn't support gl_FrontFacing in fragment shaders
549     bool noFrontFacingSupport = false;
550 
551     // Renderer doesn't support GL_SAMPLE_ALPHA_TO_COVERAGE
552     bool noSampleAlphaToCoverageSupport = false;
553 
554     // In glVertexAttribDivisorANGLE, attribute zero must have a zero divisor
555     bool attributeZeroRequiresZeroDivisorInEXT = false;
556 
557     // Unable to support different values for front and back faces for stencil refs and masks
558     bool noSeparateStencilRefsAndMasks = false;
559 
560     // Renderer doesn't support non-constant indexing loops in fragment shader
561     bool shadersRequireIndexedLoopValidation = false;
562 
563     // Renderer doesn't support Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA
564     // and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR blend functions.
565     bool noSimultaneousConstantColorAndAlphaBlendFunc = false;
566 
567     // D3D9 does not support flexible varying register packing.
568     bool noFlexibleVaryingPacking = false;
569 
570     // D3D does not support having multiple transform feedback outputs go to the same buffer.
571     bool noDoubleBoundTransformFeedbackBuffers = false;
572 
573     // D3D does not support vertex attribute aliasing
574     bool noVertexAttributeAliasing = false;
575 };
576 
577 struct TypePrecision
578 {
579     TypePrecision();
580     TypePrecision(const TypePrecision &other);
581 
582     void setIEEEFloat();
583     void setTwosComplementInt(unsigned int bits);
584     void setSimulatedFloat(unsigned int range, unsigned int precision);
585     void setSimulatedInt(unsigned int range);
586 
587     void get(GLint *returnRange, GLint *returnPrecision) const;
588 
589     std::array<GLint, 2> range = {0, 0};
590     GLint precision            = 0;
591 };
592 
593 struct Caps
594 {
595     Caps();
596     Caps(const Caps &other);
597     ~Caps();
598 
599     // ES 3.1 (April 29, 2015) 20.39: implementation dependent values
600     GLuint64 maxElementIndex       = 0;
601     GLuint max3DTextureSize        = 0;
602     GLuint max2DTextureSize        = 0;
603     GLuint maxRectangleTextureSize = 0;
604     GLuint maxArrayTextureLayers   = 0;
605     GLfloat maxLODBias             = 0.0f;
606     GLuint maxCubeMapTextureSize   = 0;
607     GLuint maxRenderbufferSize     = 0;
608     GLfloat minAliasedPointSize    = 1.0f;
609     GLfloat maxAliasedPointSize    = 1.0f;
610     GLfloat minAliasedLineWidth    = 0.0f;
611     GLfloat maxAliasedLineWidth    = 0.0f;
612 
613     // ES 3.1 (April 29, 2015) 20.40: implementation dependent values (cont.)
614     GLuint maxDrawBuffers         = 0;
615     GLuint maxFramebufferWidth    = 0;
616     GLuint maxFramebufferHeight   = 0;
617     GLuint maxFramebufferSamples  = 0;
618     GLuint maxColorAttachments    = 0;
619     GLuint maxViewportWidth       = 0;
620     GLuint maxViewportHeight      = 0;
621     GLuint maxSampleMaskWords     = 0;
622     GLuint maxColorTextureSamples = 0;
623     GLuint maxDepthTextureSamples = 0;
624     GLuint maxIntegerSamples      = 0;
625     GLuint64 maxServerWaitTimeout = 0;
626 
627     // ES 3.1 (April 29, 2015) Table 20.41: Implementation dependent values (cont.)
628     GLint maxVertexAttribRelativeOffset = 0;
629     GLuint maxVertexAttribBindings      = 0;
630     GLint maxVertexAttribStride         = 0;
631     GLuint maxElementsIndices           = 0;
632     GLuint maxElementsVertices          = 0;
633     std::vector<GLenum> compressedTextureFormats;
634     std::vector<GLenum> programBinaryFormats;
635     std::vector<GLenum> shaderBinaryFormats;
636     TypePrecision vertexHighpFloat;
637     TypePrecision vertexMediumpFloat;
638     TypePrecision vertexLowpFloat;
639     TypePrecision vertexHighpInt;
640     TypePrecision vertexMediumpInt;
641     TypePrecision vertexLowpInt;
642     TypePrecision fragmentHighpFloat;
643     TypePrecision fragmentMediumpFloat;
644     TypePrecision fragmentLowpFloat;
645     TypePrecision fragmentHighpInt;
646     TypePrecision fragmentMediumpInt;
647     TypePrecision fragmentLowpInt;
648 
649     // Implementation dependent limits required on all shader types.
650     // TODO(jiawei.shao@intel.com): organize all such limits into ShaderMap.
651     // ES 3.1 (April 29, 2015) Table 20.43: Implementation dependent Vertex shader limits
652     // ES 3.1 (April 29, 2015) Table 20.44: Implementation dependent Fragment shader limits
653     // ES 3.1 (April 29, 2015) Table 20.45: implementation dependent compute shader limits
654     // GL_EXT_geometry_shader (May 31, 2016) Table 20.43gs: Implementation dependent geometry shader
655     // limits
656     // GL_EXT_geometry_shader (May 31, 2016) Table 20.46: Implementation dependent aggregate shader
657     // limits
658     ShaderMap<GLuint> maxShaderUniformBlocks        = {};
659     ShaderMap<GLuint> maxShaderTextureImageUnits    = {};
660     ShaderMap<GLuint> maxShaderStorageBlocks        = {};
661     ShaderMap<GLuint> maxShaderUniformComponents    = {};
662     ShaderMap<GLuint> maxShaderAtomicCounterBuffers = {};
663     ShaderMap<GLuint> maxShaderAtomicCounters       = {};
664     ShaderMap<GLuint> maxShaderImageUniforms        = {};
665     // Note that we can query MAX_COMPUTE_UNIFORM_COMPONENTS and MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT
666     // by GetIntegerv, but we can only use GetInteger64v on MAX_VERTEX_UNIFORM_COMPONENTS and
667     // MAX_FRAGMENT_UNIFORM_COMPONENTS. Currently we use GLuint64 to store all these values so that
668     // we can put them together into one ShaderMap.
669     ShaderMap<GLuint64> maxCombinedShaderUniformComponents = {};
670 
671     // ES 3.1 (April 29, 2015) Table 20.43: Implementation dependent Vertex shader limits
672     GLuint maxVertexAttributes       = 0;
673     GLuint maxVertexUniformVectors   = 0;
674     GLuint maxVertexOutputComponents = 0;
675 
676     // ES 3.1 (April 29, 2015) Table 20.44: Implementation dependent Fragment shader limits
677     GLuint maxFragmentUniformVectors     = 0;
678     GLuint maxFragmentInputComponents    = 0;
679     GLint minProgramTextureGatherOffset  = 0;
680     GLuint maxProgramTextureGatherOffset = 0;
681     GLint minProgramTexelOffset          = 0;
682     GLint maxProgramTexelOffset          = 0;
683 
684     // ES 3.1 (April 29, 2015) Table 20.45: implementation dependent compute shader limits
685     std::array<GLuint, 3> maxComputeWorkGroupCount = {0, 0, 0};
686     std::array<GLuint, 3> maxComputeWorkGroupSize  = {0, 0, 0};
687     GLuint maxComputeWorkGroupInvocations          = 0;
688     GLuint maxComputeSharedMemorySize              = 0;
689 
690     // ES 3.1 (April 29, 2015) Table 20.46: implementation dependent aggregate shader limits
691     GLuint maxUniformBufferBindings         = 0;
692     GLuint64 maxUniformBlockSize            = 0;
693     GLuint uniformBufferOffsetAlignment     = 0;
694     GLuint maxCombinedUniformBlocks         = 0;
695     GLuint maxVaryingComponents             = 0;
696     GLuint maxVaryingVectors                = 0;
697     GLuint maxCombinedTextureImageUnits     = 0;
698     GLuint maxCombinedShaderOutputResources = 0;
699 
700     // ES 3.1 (April 29, 2015) Table 20.47: implementation dependent aggregate shader limits (cont.)
701     GLuint maxUniformLocations                = 0;
702     GLuint maxAtomicCounterBufferBindings     = 0;
703     GLuint maxAtomicCounterBufferSize         = 0;
704     GLuint maxCombinedAtomicCounterBuffers    = 0;
705     GLuint maxCombinedAtomicCounters          = 0;
706     GLuint maxImageUnits                      = 0;
707     GLuint maxCombinedImageUniforms           = 0;
708     GLuint maxShaderStorageBufferBindings     = 0;
709     GLuint64 maxShaderStorageBlockSize        = 0;
710     GLuint maxCombinedShaderStorageBlocks     = 0;
711     GLuint shaderStorageBufferOffsetAlignment = 0;
712 
713     // ES 3.1 (April 29, 2015) Table 20.48: implementation dependent transform feedback limits
714     GLuint maxTransformFeedbackInterleavedComponents = 0;
715     GLuint maxTransformFeedbackSeparateAttributes    = 0;
716     GLuint maxTransformFeedbackSeparateComponents    = 0;
717 
718     // ES 3.1 (April 29, 2015) Table 20.49: Framebuffer Dependent Values
719     GLuint maxSamples = 0;
720 
721     // GL_EXT_geometry_shader (May 31, 2016) Table 20.40: Implementation-Dependent Values (cont.)
722     GLuint maxFramebufferLayers = 0;
723     GLuint layerProvokingVertex = 0;
724 
725     // GL_EXT_geometry_shader (May 31, 2016) Table 20.43gs: Implementation dependent geometry shader
726     // limits
727     GLuint maxGeometryInputComponents       = 0;
728     GLuint maxGeometryOutputComponents      = 0;
729     GLuint maxGeometryOutputVertices        = 0;
730     GLuint maxGeometryTotalOutputComponents = 0;
731     GLuint maxGeometryShaderInvocations     = 0;
732 
733     GLuint subPixelBits = 4;
734 
735     // GLES1 emulation: Caps for ES 1.1. Taken from Table 6.20 / 6.22 in the OpenGL ES 1.1 spec.
736     GLuint maxMultitextureUnits                 = 0;
737     GLuint maxClipPlanes                        = 0;
738     GLuint maxLights                            = 0;
739     static constexpr int GlobalMatrixStackDepth = 16;
740     GLuint maxModelviewMatrixStackDepth         = 0;
741     GLuint maxProjectionMatrixStackDepth        = 0;
742     GLuint maxTextureMatrixStackDepth           = 0;
743     GLfloat minSmoothPointSize                  = 0.0f;
744     GLfloat maxSmoothPointSize                  = 0.0f;
745     GLfloat minSmoothLineWidth                  = 0.0f;
746     GLfloat maxSmoothLineWidth                  = 0.0f;
747 };
748 
749 Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensions);
750 }  // namespace gl
751 
752 namespace egl
753 {
754 
755 struct Caps
756 {
757     Caps();
758 
759     // Support for NPOT surfaces
760     bool textureNPOT;
761 };
762 
763 struct DisplayExtensions
764 {
765     DisplayExtensions();
766 
767     // Generate a vector of supported extension strings
768     std::vector<std::string> getStrings() const;
769 
770     // EGL_EXT_create_context_robustness
771     bool createContextRobustness = false;
772 
773     // EGL_ANGLE_d3d_share_handle_client_buffer
774     bool d3dShareHandleClientBuffer = false;
775 
776     // EGL_ANGLE_d3d_texture_client_buffer
777     bool d3dTextureClientBuffer = false;
778 
779     // EGL_ANGLE_surface_d3d_texture_2d_share_handle
780     bool surfaceD3DTexture2DShareHandle = false;
781 
782     // EGL_ANGLE_query_surface_pointer
783     bool querySurfacePointer = false;
784 
785     // EGL_ANGLE_window_fixed_size
786     bool windowFixedSize = false;
787 
788     // EGL_ANGLE_keyed_mutex
789     bool keyedMutex = false;
790 
791     // EGL_ANGLE_surface_orientation
792     bool surfaceOrientation = false;
793 
794     // EGL_NV_post_sub_buffer
795     bool postSubBuffer = false;
796 
797     // EGL_KHR_create_context
798     bool createContext = false;
799 
800     // EGL_EXT_device_query
801     bool deviceQuery = false;
802 
803     // EGL_KHR_image
804     bool image = false;
805 
806     // EGL_KHR_image_base
807     bool imageBase = false;
808 
809     // EGL_KHR_image_pixmap
810     bool imagePixmap = false;
811 
812     // EGL_KHR_gl_texture_2D_image
813     bool glTexture2DImage = false;
814 
815     // EGL_KHR_gl_texture_cubemap_image
816     bool glTextureCubemapImage = false;
817 
818     // EGL_KHR_gl_texture_3D_image
819     bool glTexture3DImage = false;
820 
821     // EGL_KHR_gl_renderbuffer_image
822     bool glRenderbufferImage = false;
823 
824     // EGL_KHR_get_all_proc_addresses
825     bool getAllProcAddresses = false;
826 
827     // EGL_ANGLE_flexible_surface_compatibility
828     bool flexibleSurfaceCompatibility = false;
829 
830     // EGL_ANGLE_direct_composition
831     bool directComposition = false;
832 
833     // EGL_ANGLE_windows_ui_composition
834     bool windowsUIComposition = false;
835 
836     // KHR_create_context_no_error
837     bool createContextNoError = false;
838 
839     // EGL_KHR_stream
840     bool stream = false;
841 
842     // EGL_KHR_stream_consumer_gltexture
843     bool streamConsumerGLTexture = false;
844 
845     // EGL_NV_stream_consumer_gltexture_yuv
846     bool streamConsumerGLTextureYUV = false;
847 
848     // EGL_ANGLE_stream_producer_d3d_texture
849     bool streamProducerD3DTexture = false;
850 
851     // EGL_KHR_fence_sync
852     bool fenceSync = false;
853 
854     // EGL_KHR_wait_sync
855     bool waitSync = false;
856 
857     // EGL_ANGLE_create_context_webgl_compatibility
858     bool createContextWebGLCompatibility = false;
859 
860     // EGL_CHROMIUM_create_context_bind_generates_resource
861     bool createContextBindGeneratesResource = false;
862 
863     // EGL_CHROMIUM_get_sync_values
864     bool getSyncValues = false;
865 
866     // EGL_KHR_swap_buffers_with_damage
867     bool swapBuffersWithDamage = false;
868 
869     // EGL_EXT_pixel_format_float
870     bool pixelFormatFloat = false;
871 
872     // EGL_KHR_surfaceless_context
873     bool surfacelessContext = false;
874 
875     // EGL_ANGLE_display_texture_share_group
876     bool displayTextureShareGroup = false;
877 
878     // EGL_ANGLE_create_context_client_arrays
879     bool createContextClientArrays = false;
880 
881     // EGL_ANGLE_program_cache_control
882     bool programCacheControl = false;
883 
884     // EGL_ANGLE_robust_resource_initialization
885     bool robustResourceInitialization = false;
886 
887     // EGL_ANGLE_iosurface_client_buffer
888     bool iosurfaceClientBuffer = false;
889 
890     // EGL_ANGLE_create_context_extensions_enabled
891     bool createContextExtensionsEnabled = false;
892 
893     // EGL_ANDROID_presentation_time
894     bool presentationTime = false;
895 
896     // EGL_ANDROID_blob_cache
897     bool blobCache = false;
898 
899     // EGL_ANDROID_image_native_buffer
900     bool imageNativeBuffer = false;
901 
902     // EGL_ANDROID_get_frame_timestamps
903     bool getFrameTimestamps = false;
904 
905     // EGL_ANDROID_recordable
906     bool recordable = false;
907 
908     // EGL_ANGLE_power_preference
909     bool powerPreference = false;
910 
911     // EGL_ANGLE_image_d3d11_texture
912     bool imageD3D11Texture = false;
913 
914     // EGL_ANDROID_get_native_client_buffer
915     bool getNativeClientBufferANDROID = false;
916 
917     // EGL_ANDROID_native_fence_sync
918     bool nativeFenceSyncANDROID = false;
919 
920     // EGL_ANGLE_create_context_backwards_compatible
921     bool createContextBackwardsCompatible = false;
922 };
923 
924 struct DeviceExtensions
925 {
926     DeviceExtensions();
927 
928     // Generate a vector of supported extension strings
929     std::vector<std::string> getStrings() const;
930 
931     // EGL_ANGLE_device_d3d
932     bool deviceD3D = false;
933 };
934 
935 struct ClientExtensions
936 {
937     ClientExtensions();
938     ClientExtensions(const ClientExtensions &other);
939 
940     // Generate a vector of supported extension strings
941     std::vector<std::string> getStrings() const;
942 
943     // EGL_EXT_client_extensions
944     bool clientExtensions = false;
945 
946     // EGL_EXT_platform_base
947     bool platformBase = false;
948 
949     // EGL_EXT_platform_device
950     bool platformDevice = false;
951 
952     // EGL_ANGLE_platform_angle
953     bool platformANGLE = false;
954 
955     // EGL_ANGLE_platform_angle_d3d
956     bool platformANGLED3D = false;
957 
958     // EGL_ANGLE_platform_angle_opengl
959     bool platformANGLEOpenGL = false;
960 
961     // EGL_ANGLE_platform_angle_null
962     bool platformANGLENULL = false;
963 
964     // EGL_ANGLE_platform_angle_vulkan
965     bool platformANGLEVulkan = false;
966 
967     // EGL_ANGLE_platform_angle_context_virtualization
968     bool platformANGLEContextVirtualization = false;
969 
970     // EGL_ANGLE_device_creation
971     bool deviceCreation = false;
972 
973     // EGL_ANGLE_device_creation_d3d11
974     bool deviceCreationD3D11 = false;
975 
976     // EGL_ANGLE_x11_visual
977     bool x11Visual = false;
978 
979     // EGL_ANGLE_experimental_present_path
980     bool experimentalPresentPath = false;
981 
982     // EGL_KHR_client_get_all_proc_addresses
983     bool clientGetAllProcAddresses = false;
984 
985     // EGL_KHR_debug
986     bool debug = false;
987 
988     // EGL_ANGLE_explicit_context
989     bool explicitContext = false;
990 
991     // EGL_ANGLE_feature_control
992     bool featureControlANGLE = false;
993 };
994 
995 }  // namespace egl
996 
997 #endif  // LIBANGLE_CAPS_H_
998