xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/vulkan/vk_caps_utils.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2018 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 // vk_utils:
7 //    Helper functions for the Vulkan Caps.
8 //
9 
10 #ifndef LIBANGLE_RENDERER_VULKAN_VK_CAPS_UTILS_H_
11 #define LIBANGLE_RENDERER_VULKAN_VK_CAPS_UTILS_H_
12 
13 #include "common/vulkan/vk_headers.h"
14 #include "libANGLE/Config.h"
15 
16 namespace gl
17 {
18 struct Limitations;
19 struct Extensions;
20 class TextureCapsMap;
21 struct Caps;
22 struct TextureCaps;
23 struct InternalFormat;
24 }  // namespace gl
25 
26 namespace rx
27 {
28 struct FeaturesVk;
29 
30 class DisplayVk;
31 
32 namespace egl_vk
33 {
34 constexpr GLenum kConfigDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8, GL_DEPTH_COMPONENT24,
35                                                  GL_DEPTH_COMPONENT16};
36 
37 // Permutes over all combinations of color format, depth stencil format and sample count and
38 // generates a basic config which is passed to DisplayVk::checkConfigSupport.
39 egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
40                                size_t colorFormatsCount,
41                                const GLenum *depthStencilFormats,
42                                size_t depthStencilFormatCount,
43                                DisplayVk *display);
44 
45 template <size_t ColorFormatCount, size_t DepthStencilFormatCount>
GenerateConfigs(const GLenum (& colorFormats)[ColorFormatCount],const GLenum (& depthStencilFormats)[DepthStencilFormatCount],DisplayVk * display)46 egl::ConfigSet GenerateConfigs(const GLenum (&colorFormats)[ColorFormatCount],
47                                const GLenum (&depthStencilFormats)[DepthStencilFormatCount],
48                                DisplayVk *display)
49 {
50     return GenerateConfigs(colorFormats, ColorFormatCount, depthStencilFormats,
51                            DepthStencilFormatCount, display);
52 }
53 
GetConfigCaveat(GLenum format)54 static ANGLE_INLINE EGLenum GetConfigCaveat(GLenum format)
55 {
56     // Default EGL config sorting rule will result in rgb10a2 having higher precedence than rgb8
57     // By marking `rgb10a2` as a slow config we switch the order. This ensures that we dont
58     // return rgb10a2 at the top of the config list
59 
60     switch (format)
61     {
62         // For now we only mark rgb10a2 as a slow config
63         case GL_RGB10_A2_EXT:
64             return EGL_SLOW_CONFIG;
65         default:
66             return EGL_NONE;
67     }
68 }
69 
70 }  // namespace egl_vk
71 
72 namespace vk
73 {
74 // Checks support for extensions required for GLES 3.2. If any of those extensions is missing, the
75 // context version should be capped to GLES 3.1 by default.
76 bool CanSupportGLES32(const gl::Extensions &nativeExtensions);
77 
78 // Functions that determine support for a feature or extension, used both to advertise support for
79 // an extension, and to determine if a context version can be supported.
80 bool CanSupportTransformFeedbackExtension(
81     const VkPhysicalDeviceTransformFeedbackFeaturesEXT &xfbFeatures);
82 bool CanSupportTransformFeedbackEmulation(const VkPhysicalDeviceFeatures &features);
83 }  // namespace vk
84 
85 }  // namespace rx
86 
87 #endif
88