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 // Functions that determine support for a feature or extension, used both to advertise support for
75 // an extension, and to determine if a context version can be supported.
76 bool CanSupportGPUShader5EXT(const VkPhysicalDeviceFeatures &features);
77 }  // namespace vk
78 
79 }  // namespace rx
80 
81 #endif
82