• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "volk.h"
14 
15 #include "libANGLE/Config.h"
16 
17 namespace gl
18 {
19 struct Limitations;
20 struct Extensions;
21 class TextureCapsMap;
22 struct Caps;
23 struct TextureCaps;
24 struct InternalFormat;
25 }  // namespace gl
26 
27 namespace rx
28 {
29 struct FeaturesVk;
30 
31 class DisplayVk;
32 
33 namespace egl_vk
34 {
35 constexpr GLenum kConfigDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8, GL_DEPTH_COMPONENT24,
36                                                  GL_DEPTH_COMPONENT16};
37 
38 // Permutes over all combinations of color format, depth stencil format and sample count and
39 // generates a basic config which is passed to DisplayVk::checkConfigSupport.
40 egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
41                                size_t colorFormatsCount,
42                                const GLenum *depthStencilFormats,
43                                size_t depthStencilFormatCount,
44                                DisplayVk *display);
45 
46 template <size_t ColorFormatCount, size_t DepthStencilFormatCount>
GenerateConfigs(const GLenum (& colorFormats)[ColorFormatCount],const GLenum (& depthStencilFormats)[DepthStencilFormatCount],DisplayVk * display)47 egl::ConfigSet GenerateConfigs(const GLenum (&colorFormats)[ColorFormatCount],
48                                const GLenum (&depthStencilFormats)[DepthStencilFormatCount],
49                                DisplayVk *display)
50 {
51     return GenerateConfigs(colorFormats, ColorFormatCount, depthStencilFormats,
52                            DepthStencilFormatCount, display);
53 }
54 
GetConfigCaveat(GLenum format)55 static ANGLE_INLINE EGLenum GetConfigCaveat(GLenum format)
56 {
57     // Default EGL config sorting rule will result in rgb10a2 having higher precedence than rgb8
58     // By marking `rgb10a2` as a slow config we switch the order. This ensures that we dont
59     // return rgb10a2 at the top of the config list
60 
61     switch (format)
62     {
63         // For now we only mark rgb10a2 as a slow config
64         case GL_RGB10_A2_EXT:
65             return EGL_SLOW_CONFIG;
66         default:
67             return EGL_NONE;
68     }
69 }
70 
71 }  // namespace egl_vk
72 
73 namespace vk
74 {
75 // Functions that determine support for a feature or extension, used both to advertise support for
76 // an extension, and to determine if a context version can be supported.
77 bool CanSupportGPUShader5EXT(const VkPhysicalDeviceFeatures &features);
78 }  // namespace vk
79 
80 }  // namespace rx
81 
82 #endif
83