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