• 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_texture_sRGB_override
496     bool textureSRGBOverride = false;
497 
498     // GL_EXT_sRGB_write_control
499     bool sRGBWriteControl = false;
500 
501     // GL_CHROMIUM_color_buffer_float_rgb
502     bool colorBufferFloatRGB = false;
503 
504     // GL_CHROMIUM_color_buffer_float_rgba
505     bool colorBufferFloatRGBA = false;
506 
507     // GL_EXT_EGL_image_array
508     bool eglImageArray = false;
509 
510     // ES3 Extension support
511 
512     // GL_EXT_color_buffer_float
513     bool colorBufferFloat = false;
514 
515     // GL_EXT_multisample_compatibility.
516     // written against ES 3.1 but can apply to earlier versions.
517     bool multisampleCompatibility = false;
518 
519     // GL_CHROMIUM_framebuffer_mixed_samples
520     bool framebufferMixedSamples = false;
521 
522     // GL_EXT_texture_norm16
523     // written against ES 3.1 but can apply to ES 3.0 as well.
524     bool textureNorm16 = false;
525 
526     // GL_OES_surfaceless_context
527     bool surfacelessContextOES = false;
528 
529     // GL_ANGLE_client_arrays
530     bool clientArrays = false;
531 
532     // GL_ANGLE_robust_resource_initialization
533     bool robustResourceInitialization = false;
534 
535     // GL_ANGLE_program_cache_control
536     bool programCacheControl = false;
537 
538     // GL_ANGLE_texture_rectangle
539     bool textureRectangle = false;
540 
541     // GL_EXT_geometry_shader
542     bool geometryShader = false;
543 
544     // GLES1 emulation: GLES1 extensions
545     // GL_OES_point_size_array
546     bool pointSizeArrayOES = false;
547 
548     // GL_OES_texture_cube_map
549     bool textureCubeMapOES = false;
550 
551     // GL_OES_point_sprite
552     bool pointSpriteOES = false;
553 
554     // GL_OES_draw_texture
555     bool drawTextureOES = false;
556 
557     // EGL_ANGLE_explicit_context GL subextensions
558     // GL_ANGLE_explicit_context_gles1
559     bool explicitContextGles1 = false;
560     // GL_ANGLE_explicit_context
561     bool explicitContext = false;
562 
563     // GL_KHR_parallel_shader_compile
564     bool parallelShaderCompile = false;
565 
566     // GL_OES_texture_storage_multisample_2d_array
567     bool textureStorageMultisample2DArrayOES = false;
568 
569     // GL_ANGLE_multiview_multisample
570     bool multiviewMultisample = false;
571 
572     // GL_EXT_blend_func_extended
573     bool blendFuncExtended          = false;
574     GLuint maxDualSourceDrawBuffers = 0;
575 
576     // GL_EXT_float_blend
577     bool floatBlend = false;
578 
579     // GL_ANGLE_memory_size
580     bool memorySize = false;
581 
582     // GL_ANGLE_texture_multisample
583     bool textureMultisample = false;
584 
585     // GL_ANGLE_multi_draw
586     bool multiDraw = false;
587 
588     // GL_ANGLE_provoking_vertex
589     bool provokingVertex = false;
590 
591     // GL_CHROMIUM_texture_filtering_hint
592     bool textureFilteringCHROMIUM = false;
593 
594     // GL_CHROMIUM_lose_context
595     bool loseContextCHROMIUM = false;
596 
597     // GL_ANGLE_texture_external_update
598     bool textureExternalUpdateANGLE = false;
599 
600     // GL_ANGLE_base_vertex_base_instance
601     bool baseVertexBaseInstance = false;
602 
603     // GL_ANGLE_get_image
604     bool getImageANGLE = false;
605 
606     // GL_OES_draw_elements_base_vertex
607     bool drawElementsBaseVertexOES = false;
608     // GL_EXT_draw_elements_base_vertex
609     bool drawElementsBaseVertexEXT = false;
610     // Any version of the base vertex extension
drawElementsBaseVertexAnyExtensions611     bool drawElementsBaseVertexAny() const
612     {
613         return (drawElementsBaseVertexOES || drawElementsBaseVertexEXT);
614     }
615 
616     // GL_EXT_shader_non_constant_global_initializers
617     bool shaderNonConstGlobalInitializersEXT = false;
618 
619     // GL_EXT_gpu_shader5
620     bool gpuShader5EXT = false;
621     // WEBGL_video_texture
622     bool webglVideoTexture = false;
623 
624     // GL_APPLE_clip_distance
625     bool clipDistanceAPPLE = false;
626 
627     // GL_OES_texture_cube_map_array
628     bool textureCubeMapArrayOES = false;
629     // GL_EXT_texture_cube_map_array
630     bool textureCubeMapArrayEXT = false;
631     // Any version of the texture cube map array extension
textureCubeMapArrayAnyExtensions632     bool textureCubeMapArrayAny() const
633     {
634         return (textureCubeMapArrayOES || textureCubeMapArrayEXT);
635     }
636 };
637 
638 // Pointer to a boolean memeber of the Extensions struct
639 using ExtensionBool = bool Extensions::*;
640 
641 struct ExtensionInfo
642 {
643     // If this extension can be enabled or disabled  with glRequestExtension
644     // (GL_ANGLE_request_extension)
645     bool Requestable = false;
646     bool Disablable  = false;
647 
648     // Pointer to a boolean member of the Extensions struct
649     ExtensionBool ExtensionsMember = nullptr;
650 };
651 
652 using ExtensionInfoMap = std::map<std::string, ExtensionInfo>;
653 const ExtensionInfoMap &GetExtensionInfoMap();
654 
655 struct Limitations
656 {
657     Limitations();
658 
659     // Renderer doesn't support gl_FrontFacing in fragment shaders
660     bool noFrontFacingSupport = false;
661 
662     // Renderer doesn't support GL_SAMPLE_ALPHA_TO_COVERAGE
663     bool noSampleAlphaToCoverageSupport = false;
664 
665     // In glVertexAttribDivisorANGLE, attribute zero must have a zero divisor
666     bool attributeZeroRequiresZeroDivisorInEXT = false;
667 
668     // Unable to support different values for front and back faces for stencil refs and masks
669     bool noSeparateStencilRefsAndMasks = false;
670 
671     // Renderer doesn't support non-constant indexing loops in fragment shader
672     bool shadersRequireIndexedLoopValidation = false;
673 
674     // Renderer doesn't support Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA
675     // and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR blend functions.
676     bool noSimultaneousConstantColorAndAlphaBlendFunc = false;
677 
678     // D3D9 does not support flexible varying register packing.
679     bool noFlexibleVaryingPacking = false;
680 
681     // D3D does not support having multiple transform feedback outputs go to the same buffer.
682     bool noDoubleBoundTransformFeedbackBuffers = false;
683 
684     // D3D does not support vertex attribute aliasing
685     bool noVertexAttributeAliasing = false;
686 };
687 
688 struct TypePrecision
689 {
690     TypePrecision();
691     TypePrecision(const TypePrecision &other);
692 
693     void setIEEEFloat();
694     void setTwosComplementInt(unsigned int bits);
695     void setSimulatedFloat(unsigned int range, unsigned int precision);
696     void setSimulatedInt(unsigned int range);
697 
698     void get(GLint *returnRange, GLint *returnPrecision) const;
699 
700     std::array<GLint, 2> range = {0, 0};
701     GLint precision            = 0;
702 };
703 
704 struct Caps
705 {
706     Caps();
707     Caps(const Caps &other);
708     ~Caps();
709 
710     // If the values could be got by using GetIntegeri_v, they should
711     // be GLint instead of GLuint and call LimitToInt() to ensure
712     // they will not overflow.
713 
714     // ES 3.1 (April 29, 2015) 20.39: implementation dependent values
715     GLint64 maxElementIndex       = 0;
716     GLint max3DTextureSize        = 0;
717     GLint max2DTextureSize        = 0;
718     GLint maxRectangleTextureSize = 0;
719     GLint maxArrayTextureLayers   = 0;
720     GLfloat maxLODBias            = 0.0f;
721     GLint maxCubeMapTextureSize   = 0;
722     GLint maxRenderbufferSize     = 0;
723     GLfloat minAliasedPointSize   = 1.0f;
724     GLfloat maxAliasedPointSize   = 1.0f;
725     GLfloat minAliasedLineWidth   = 0.0f;
726     GLfloat maxAliasedLineWidth   = 0.0f;
727 
728     // ES 3.1 (April 29, 2015) 20.40: implementation dependent values (cont.)
729     GLint maxDrawBuffers         = 0;
730     GLint maxFramebufferWidth    = 0;
731     GLint maxFramebufferHeight   = 0;
732     GLint maxFramebufferSamples  = 0;
733     GLint maxColorAttachments    = 0;
734     GLint maxViewportWidth       = 0;
735     GLint maxViewportHeight      = 0;
736     GLint maxSampleMaskWords     = 0;
737     GLint maxColorTextureSamples = 0;
738     GLint maxDepthTextureSamples = 0;
739     GLint maxIntegerSamples      = 0;
740     GLint64 maxServerWaitTimeout = 0;
741 
742     // ES 3.1 (April 29, 2015) Table 20.41: Implementation dependent values (cont.)
743     GLint maxVertexAttribRelativeOffset = 0;
744     GLint maxVertexAttribBindings       = 0;
745     GLint maxVertexAttribStride         = 0;
746     GLint maxElementsIndices            = 0;
747     GLint maxElementsVertices           = 0;
748     std::vector<GLenum> compressedTextureFormats;
749     std::vector<GLenum> programBinaryFormats;
750     std::vector<GLenum> shaderBinaryFormats;
751     TypePrecision vertexHighpFloat;
752     TypePrecision vertexMediumpFloat;
753     TypePrecision vertexLowpFloat;
754     TypePrecision vertexHighpInt;
755     TypePrecision vertexMediumpInt;
756     TypePrecision vertexLowpInt;
757     TypePrecision fragmentHighpFloat;
758     TypePrecision fragmentMediumpFloat;
759     TypePrecision fragmentLowpFloat;
760     TypePrecision fragmentHighpInt;
761     TypePrecision fragmentMediumpInt;
762     TypePrecision fragmentLowpInt;
763 
764     // Implementation dependent limits required on all shader types.
765     // TODO(jiawei.shao@intel.com): organize all such limits into ShaderMap.
766     // ES 3.1 (April 29, 2015) Table 20.43: Implementation dependent Vertex shader limits
767     // ES 3.1 (April 29, 2015) Table 20.44: Implementation dependent Fragment shader limits
768     // ES 3.1 (April 29, 2015) Table 20.45: implementation dependent compute shader limits
769     // GL_EXT_geometry_shader (May 31, 2016) Table 20.43gs: Implementation dependent geometry shader
770     // limits
771     // GL_EXT_geometry_shader (May 31, 2016) Table 20.46: Implementation dependent aggregate shader
772     // limits
773     ShaderMap<GLint> maxShaderUniformBlocks        = {};
774     ShaderMap<GLint> maxShaderTextureImageUnits    = {};
775     ShaderMap<GLint> maxShaderStorageBlocks        = {};
776     ShaderMap<GLint> maxShaderUniformComponents    = {};
777     ShaderMap<GLint> maxShaderAtomicCounterBuffers = {};
778     ShaderMap<GLint> maxShaderAtomicCounters       = {};
779     ShaderMap<GLint> maxShaderImageUniforms        = {};
780     // Note that we can query MAX_COMPUTE_UNIFORM_COMPONENTS and MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT
781     // by GetIntegerv, but we can only use GetInteger64v on MAX_VERTEX_UNIFORM_COMPONENTS and
782     // MAX_FRAGMENT_UNIFORM_COMPONENTS. Currently we use GLuint64 to store all these values so that
783     // we can put them together into one ShaderMap.
784     ShaderMap<GLint64> maxCombinedShaderUniformComponents = {};
785 
786     // ES 3.1 (April 29, 2015) Table 20.43: Implementation dependent Vertex shader limits
787     GLint maxVertexAttributes       = 0;
788     GLint maxVertexUniformVectors   = 0;
789     GLint maxVertexOutputComponents = 0;
790 
791     // ES 3.1 (April 29, 2015) Table 20.44: Implementation dependent Fragment shader limits
792     GLint maxFragmentUniformVectors     = 0;
793     GLint maxFragmentInputComponents    = 0;
794     GLint minProgramTextureGatherOffset = 0;
795     GLint maxProgramTextureGatherOffset = 0;
796     GLint minProgramTexelOffset         = 0;
797     GLint maxProgramTexelOffset         = 0;
798 
799     // ES 3.1 (April 29, 2015) Table 20.45: implementation dependent compute shader limits
800     std::array<GLint, 3> maxComputeWorkGroupCount = {0, 0, 0};
801     std::array<GLint, 3> maxComputeWorkGroupSize  = {0, 0, 0};
802     GLint maxComputeWorkGroupInvocations          = 0;
803     GLint maxComputeSharedMemorySize              = 0;
804 
805     // ES 3.1 (April 29, 2015) Table 20.46: implementation dependent aggregate shader limits
806     GLint maxUniformBufferBindings         = 0;
807     GLint64 maxUniformBlockSize            = 0;
808     GLint uniformBufferOffsetAlignment     = 0;
809     GLint maxCombinedUniformBlocks         = 0;
810     GLint maxVaryingComponents             = 0;
811     GLint maxVaryingVectors                = 0;
812     GLint maxCombinedTextureImageUnits     = 0;
813     GLint maxCombinedShaderOutputResources = 0;
814 
815     // ES 3.1 (April 29, 2015) Table 20.47: implementation dependent aggregate shader limits (cont.)
816     GLint maxUniformLocations                = 0;
817     GLint maxAtomicCounterBufferBindings     = 0;
818     GLint maxAtomicCounterBufferSize         = 0;
819     GLint maxCombinedAtomicCounterBuffers    = 0;
820     GLint maxCombinedAtomicCounters          = 0;
821     GLint maxImageUnits                      = 0;
822     GLint maxCombinedImageUniforms           = 0;
823     GLint maxShaderStorageBufferBindings     = 0;
824     GLint64 maxShaderStorageBlockSize        = 0;
825     GLint maxCombinedShaderStorageBlocks     = 0;
826     GLint shaderStorageBufferOffsetAlignment = 0;
827 
828     // ES 3.1 (April 29, 2015) Table 20.48: implementation dependent transform feedback limits
829     GLint maxTransformFeedbackInterleavedComponents = 0;
830     GLint maxTransformFeedbackSeparateAttributes    = 0;
831     GLint maxTransformFeedbackSeparateComponents    = 0;
832 
833     // ES 3.1 (April 29, 2015) Table 20.49: Framebuffer Dependent Values
834     GLint maxSamples = 0;
835 
836     // GL_EXT_geometry_shader (May 31, 2016) Table 20.40: Implementation-Dependent Values (cont.)
837     GLint maxFramebufferLayers = 0;
838     GLint layerProvokingVertex = 0;
839 
840     // GL_EXT_geometry_shader (May 31, 2016) Table 20.43gs: Implementation dependent geometry shader
841     // limits
842     GLint maxGeometryInputComponents       = 0;
843     GLint maxGeometryOutputComponents      = 0;
844     GLint maxGeometryOutputVertices        = 0;
845     GLint maxGeometryTotalOutputComponents = 0;
846     GLint maxGeometryShaderInvocations     = 0;
847 
848     GLuint subPixelBits = 4;
849 
850     // GL_APPLE_clip_distance/GL_EXT_clip_cull_distance
851     GLuint maxClipDistances = 0;
852 
853     // GLES1 emulation: Caps for ES 1.1. Taken from Table 6.20 / 6.22 in the OpenGL ES 1.1 spec.
854     GLuint maxMultitextureUnits                 = 0;
855     GLuint maxClipPlanes                        = 0;
856     GLuint maxLights                            = 0;
857     static constexpr int GlobalMatrixStackDepth = 16;
858     GLuint maxModelviewMatrixStackDepth         = 0;
859     GLuint maxProjectionMatrixStackDepth        = 0;
860     GLuint maxTextureMatrixStackDepth           = 0;
861     GLfloat minSmoothPointSize                  = 0.0f;
862     GLfloat maxSmoothPointSize                  = 0.0f;
863     GLfloat minSmoothLineWidth                  = 0.0f;
864     GLfloat maxSmoothLineWidth                  = 0.0f;
865 };
866 
867 Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensions);
868 }  // namespace gl
869 
870 namespace egl
871 {
872 
873 struct Caps
874 {
875     Caps();
876 
877     // Support for NPOT surfaces
878     bool textureNPOT;
879 };
880 
881 struct DisplayExtensions
882 {
883     DisplayExtensions();
884 
885     // Generate a vector of supported extension strings
886     std::vector<std::string> getStrings() const;
887 
888     // EGL_EXT_create_context_robustness
889     bool createContextRobustness = false;
890 
891     // EGL_ANGLE_d3d_share_handle_client_buffer
892     bool d3dShareHandleClientBuffer = false;
893 
894     // EGL_ANGLE_d3d_texture_client_buffer
895     bool d3dTextureClientBuffer = false;
896 
897     // EGL_ANGLE_surface_d3d_texture_2d_share_handle
898     bool surfaceD3DTexture2DShareHandle = false;
899 
900     // EGL_ANGLE_query_surface_pointer
901     bool querySurfacePointer = false;
902 
903     // EGL_ANGLE_window_fixed_size
904     bool windowFixedSize = false;
905 
906     // EGL_ANGLE_keyed_mutex
907     bool keyedMutex = false;
908 
909     // EGL_ANGLE_surface_orientation
910     bool surfaceOrientation = false;
911 
912     // EGL_NV_post_sub_buffer
913     bool postSubBuffer = false;
914 
915     // EGL_KHR_create_context
916     bool createContext = false;
917 
918     // EGL_EXT_device_query
919     bool deviceQuery = false;
920 
921     // EGL_KHR_image
922     bool image = false;
923 
924     // EGL_KHR_image_base
925     bool imageBase = false;
926 
927     // EGL_KHR_image_pixmap
928     bool imagePixmap = false;
929 
930     // EGL_KHR_gl_texture_2D_image
931     bool glTexture2DImage = false;
932 
933     // EGL_KHR_gl_texture_cubemap_image
934     bool glTextureCubemapImage = false;
935 
936     // EGL_KHR_gl_texture_3D_image
937     bool glTexture3DImage = false;
938 
939     // EGL_KHR_gl_renderbuffer_image
940     bool glRenderbufferImage = false;
941 
942     // EGL_KHR_get_all_proc_addresses
943     bool getAllProcAddresses = false;
944 
945     // EGL_ANGLE_flexible_surface_compatibility
946     bool flexibleSurfaceCompatibility = false;
947 
948     // EGL_ANGLE_direct_composition
949     bool directComposition = false;
950 
951     // EGL_ANGLE_windows_ui_composition
952     bool windowsUIComposition = false;
953 
954     // KHR_create_context_no_error
955     bool createContextNoError = false;
956 
957     // EGL_KHR_stream
958     bool stream = false;
959 
960     // EGL_KHR_stream_consumer_gltexture
961     bool streamConsumerGLTexture = false;
962 
963     // EGL_NV_stream_consumer_gltexture_yuv
964     bool streamConsumerGLTextureYUV = false;
965 
966     // EGL_ANGLE_stream_producer_d3d_texture
967     bool streamProducerD3DTexture = false;
968 
969     // EGL_KHR_fence_sync
970     bool fenceSync = false;
971 
972     // EGL_KHR_wait_sync
973     bool waitSync = false;
974 
975     // EGL_ANGLE_create_context_webgl_compatibility
976     bool createContextWebGLCompatibility = false;
977 
978     // EGL_CHROMIUM_create_context_bind_generates_resource
979     bool createContextBindGeneratesResource = false;
980 
981     // EGL_CHROMIUM_sync_control
982     bool syncControlCHROMIUM = false;
983 
984     // EGL_ANGLE_sync_control_rate
985     bool syncControlRateANGLE = false;
986 
987     // EGL_KHR_swap_buffers_with_damage
988     bool swapBuffersWithDamage = false;
989 
990     // EGL_EXT_pixel_format_float
991     bool pixelFormatFloat = false;
992 
993     // EGL_KHR_surfaceless_context
994     bool surfacelessContext = false;
995 
996     // EGL_ANGLE_display_texture_share_group
997     bool displayTextureShareGroup = false;
998 
999     // EGL_ANGLE_create_context_client_arrays
1000     bool createContextClientArrays = false;
1001 
1002     // EGL_ANGLE_program_cache_control
1003     bool programCacheControl = false;
1004 
1005     // EGL_ANGLE_robust_resource_initialization
1006     bool robustResourceInitialization = false;
1007 
1008     // EGL_ANGLE_iosurface_client_buffer
1009     bool iosurfaceClientBuffer = false;
1010 
1011     // EGL_ANGLE_create_context_extensions_enabled
1012     bool createContextExtensionsEnabled = false;
1013 
1014     // EGL_ANDROID_presentation_time
1015     bool presentationTime = false;
1016 
1017     // EGL_ANDROID_blob_cache
1018     bool blobCache = false;
1019 
1020     // EGL_ANDROID_image_native_buffer
1021     bool imageNativeBuffer = false;
1022 
1023     // EGL_ANDROID_get_frame_timestamps
1024     bool getFrameTimestamps = false;
1025 
1026     // EGL_ANDROID_recordable
1027     bool recordable = false;
1028 
1029     // EGL_ANGLE_power_preference
1030     bool powerPreference = false;
1031 
1032     // EGL_ANGLE_image_d3d11_texture
1033     bool imageD3D11Texture = false;
1034 
1035     // EGL_ANDROID_get_native_client_buffer
1036     bool getNativeClientBufferANDROID = false;
1037 
1038     // EGL_ANDROID_native_fence_sync
1039     bool nativeFenceSyncANDROID = false;
1040 
1041     // EGL_ANGLE_create_context_backwards_compatible
1042     bool createContextBackwardsCompatible = false;
1043 
1044     // EGL_KHR_no_config_context
1045     bool noConfigContext = false;
1046 
1047     // EGL_IMG_context_priority
1048     bool contextPriority = false;
1049 
1050     // EGL_ANGLE_ggp_stream_descriptor
1051     bool ggpStreamDescriptor = false;
1052 
1053     // EGL_ANGLE_swap_with_frame_token
1054     bool swapWithFrameToken = false;
1055 
1056     // EGL_KHR_gl_colorspace
1057     bool glColorspace = false;
1058 
1059     // EGL_EXT_gl_colorspace_display_p3_linear
1060     bool glColorspaceDisplayP3Linear = false;
1061 
1062     // EGL_EXT_gl_colorspace_display_p3
1063     bool glColorspaceDisplayP3 = false;
1064 
1065     // EGL_EXT_gl_colorspace_scrgb
1066     bool glColorspaceScrgb = false;
1067 
1068     // EGL_EXT_gl_colorspace_scrgb_linear
1069     bool glColorspaceScrgbLinear = false;
1070 
1071     // EGL_EXT_gl_colorspace_display_p3_passthrough
1072     bool glColorspaceDisplayP3Passthrough = false;
1073 
1074     // EGL_ANDROID_framebuffer_target
1075     bool framebufferTargetANDROID = false;
1076 
1077     // EGL_EXT_image_gl_colorspace
1078     bool imageGlColorspace = false;
1079 
1080     // EGL_EXT_image_dma_buf_import
1081     bool imageDmaBufImportEXT = false;
1082 
1083     // EGL_EXT_image_dma_buf_import_modifiers
1084     bool imageDmaBufImportModifiersEXT = false;
1085 };
1086 
1087 struct DeviceExtensions
1088 {
1089     DeviceExtensions();
1090 
1091     // Generate a vector of supported extension strings
1092     std::vector<std::string> getStrings() const;
1093 
1094     // EGL_ANGLE_device_d3d
1095     bool deviceD3D = false;
1096 
1097     // EGL_ANGLE_device_cgl
1098     bool deviceCGL = false;
1099 
1100     // EGL_ANGLE_device_eagl
1101     bool deviceEAGL = false;
1102 };
1103 
1104 struct ClientExtensions
1105 {
1106     ClientExtensions();
1107     ClientExtensions(const ClientExtensions &other);
1108 
1109     // Generate a vector of supported extension strings
1110     std::vector<std::string> getStrings() const;
1111 
1112     // EGL_EXT_client_extensions
1113     bool clientExtensions = false;
1114 
1115     // EGL_EXT_platform_base
1116     bool platformBase = false;
1117 
1118     // EGL_EXT_platform_device
1119     bool platformDevice = false;
1120 
1121     // EGL_ANGLE_platform_angle
1122     bool platformANGLE = false;
1123 
1124     // EGL_ANGLE_platform_angle_d3d
1125     bool platformANGLED3D = false;
1126 
1127     // EGL_ANGLE_platform_angle_d3d11on12
1128     bool platformANGLED3D11ON12 = false;
1129 
1130     // EGL_ANGLE_platform_angle_opengl
1131     bool platformANGLEOpenGL = false;
1132 
1133     // EGL_ANGLE_platform_angle_null
1134     bool platformANGLENULL = false;
1135 
1136     // EGL_ANGLE_platform_angle_vulkan
1137     bool platformANGLEVulkan = false;
1138 
1139     // EGL_ANGLE_platform_angle_metal
1140     bool platformANGLEMetal = false;
1141 
1142     // EGL_ANGLE_platform_angle_context_virtualization
1143     bool platformANGLEContextVirtualization = false;
1144 
1145     // EGL_ANGLE_device_creation
1146     bool deviceCreation = false;
1147 
1148     // EGL_ANGLE_device_creation_d3d11
1149     bool deviceCreationD3D11 = false;
1150 
1151     // EGL_ANGLE_x11_visual
1152     bool x11Visual = false;
1153 
1154     // EGL_ANGLE_experimental_present_path
1155     bool experimentalPresentPath = false;
1156 
1157     // EGL_KHR_client_get_all_proc_addresses
1158     bool clientGetAllProcAddresses = false;
1159 
1160     // EGL_KHR_debug
1161     bool debug = false;
1162 
1163     // EGL_ANGLE_explicit_context
1164     bool explicitContext = false;
1165 
1166     // EGL_ANGLE_feature_control
1167     bool featureControlANGLE = false;
1168 
1169     // EGL_ANGLE_platform_angle_device_type_swiftshader
1170     bool platformANGLEDeviceTypeSwiftShader = false;
1171 
1172     // EGL_ANGLE_platform_angle_device_type_egl_angle
1173     bool platformANGLEDeviceTypeEGLANGLE = false;
1174 };
1175 
1176 }  // namespace egl
1177 
1178 #endif  // LIBANGLE_CAPS_H_
1179