| Flutter Impeller |

capabilities_vk.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_CAPABILITIES_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_CAPABILITIES_VK_H_
7
8 #include <cstdint>
9 #include <map>
10 #include <set>
11 #include <string>
12 #include <vector>
13
14 #include "impeller/base/backend_cast.h"
15 #include "impeller/renderer/backend/vulkan/vk.h"
16 #include "impeller/renderer/capabilities.h"
17
18 namespace impeller {
19
20 class ContextVK;
21
22 enum class OptionalDeviceExtensionVK : uint32_t {
23 // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_pipeline_creation_feedback.html
24 kEXTPipelineCreationFeedback,
25 kARMRasterizationOrderAttachmentAccess,
26 kEXTRasterizationOrderAttachmentAccess,
27 kLast,
28 };
29
30 //------------------------------------------------------------------------------
31 /// @brief The Vulkan layers and extensions wrangler.
32 ///
33 class CapabilitiesVK final : public Capabilities,
34 public BackendCast<CapabilitiesVK, Capabilities> {
35 public:
36 explicit CapabilitiesVK(bool enable_validations);
37
38 ~CapabilitiesVK();
39
40 bool IsValid() const;
41
42 bool AreValidationsEnabled() const;
43
44 bool HasOptionalDeviceExtension(OptionalDeviceExtensionVK extension) const;
45
46 std::optional<std::vector<std::string>> GetEnabledLayers() const;
47
48 std::optional<std::vector<std::string>> GetEnabledInstanceExtensions() const;
49
50 std::optional<std::vector<std::string>> GetEnabledDeviceExtensions(
51 const vk::PhysicalDevice& physical_device) const;
52
53 std::optional<vk::PhysicalDeviceFeatures> GetEnabledDeviceFeatures(
54 const vk::PhysicalDevice& physical_device) const;
55
56 [[nodiscard]] bool SetPhysicalDevice(
57 const vk::PhysicalDevice& physical_device);
58
59 const vk::PhysicalDeviceProperties& GetPhysicalDeviceProperties() const;
60
61 void SetOffscreenFormat(PixelFormat pixel_format) const;
62
63 // |Capabilities|
64 bool SupportsOffscreenMSAA() const override;
65
66 // |Capabilities|
67 bool SupportsImplicitResolvingMSAA() const override;
68
69 // |Capabilities|
70 bool SupportsSSBO() const override;
71
72 // |Capabilities|
73 bool SupportsBufferToTextureBlits() const override;
74
75 // |Capabilities|
76 bool SupportsTextureToTextureBlits() const override;
77
78 // |Capabilities|
79 bool SupportsFramebufferFetch() const override;
80
81 // |Capabilities|
82 bool SupportsCompute() const override;
83
84 // |Capabilities|
85 bool SupportsComputeSubgroups() const override;
86
87 // |Capabilities|
88 bool SupportsReadFromResolve() const override;
89
90 // |Capabilities|
91 bool SupportsDecalSamplerAddressMode() const override;
92
93 // |Capabilities|
94 bool SupportsDeviceTransientTextures() const override;
95
96 // |Capabilities|
97 PixelFormat GetDefaultColorFormat() const override;
98
99 // |Capabilities|
100 PixelFormat GetDefaultStencilFormat() const override;
101
102 // |Capabilities|
103 PixelFormat GetDefaultDepthStencilFormat() const override;
104
105 private:
106 bool validations_enabled_ = false;
107 std::map<std::string, std::set<std::string>> exts_;
108 std::set<OptionalDeviceExtensionVK> optional_device_extensions_;
109 mutable PixelFormat default_color_format_ = PixelFormat::kUnknown;
110 PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
111 PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
112 vk::PhysicalDeviceProperties device_properties_;
113 bool supports_compute_subgroups_ = false;
114 bool supports_device_transient_textures_ = false;
115 bool supports_framebuffer_fetch_ = false;
116 bool is_valid_ = false;
117
118 bool HasExtension(const std::string& ext) const;
119
120 bool HasLayer(const std::string& layer) const;
121
122 CapabilitiesVK(const CapabilitiesVK&) = delete;
123
124 CapabilitiesVK& operator=(const CapabilitiesVK&) = delete;
125 };
126
127 } // namespace impeller
128
129 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_CAPABILITIES_VK_H_
impeller::OptionalDeviceExtensionVK
OptionalDeviceExtensionVK
Definition: capabilities_vk.h:22
impeller::CapabilitiesVK::SupportsDecalSamplerAddressMode
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
Definition: capabilities_vk.cc:471
impeller::CapabilitiesVK::SetOffscreenFormat
void SetOffscreenFormat(PixelFormat pixel_format) const
Definition: capabilities_vk.cc:342
impeller::CapabilitiesVK::GetEnabledInstanceExtensions
std::optional< std::vector< std::string > > GetEnabledInstanceExtensions() const
Definition: capabilities_vk.cc:79
impeller::CapabilitiesVK::IsValid
bool IsValid() const
Definition: capabilities_vk.cc:58
impeller::CapabilitiesVK::SupportsOffscreenMSAA
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
Definition: capabilities_vk.cc:425
impeller::CapabilitiesVK::SupportsFramebufferFetch
bool SupportsFramebufferFetch() const override
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
Definition: capabilities_vk.cc:450
impeller::OptionalDeviceExtensionVK::kLast
@ kLast
impeller::CapabilitiesVK::GetDefaultStencilFormat
PixelFormat GetDefaultStencilFormat() const override
Returns a supported PixelFormat for textures that store stencil information. May include a depth chan...
Definition: capabilities_vk.cc:486
impeller::CapabilitiesVK::GetEnabledLayers
std::optional< std::vector< std::string > > GetEnabledLayers() const
Definition: capabilities_vk.cc:66
impeller::OptionalDeviceExtensionVK::kEXTPipelineCreationFeedback
@ kEXTPipelineCreationFeedback
impeller::OptionalDeviceExtensionVK::kARMRasterizationOrderAttachmentAccess
@ kARMRasterizationOrderAttachmentAccess
impeller::CapabilitiesVK::SupportsTextureToTextureBlits
bool SupportsTextureToTextureBlits() const override
Whether the context backend supports blitting from one texture region to another texture region (via ...
Definition: capabilities_vk.cc:445
impeller::CapabilitiesVK::SupportsComputeSubgroups
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
Definition: capabilities_vk.cc:461
impeller::CapabilitiesVK::HasOptionalDeviceExtension
bool HasOptionalDeviceExtension(OptionalDeviceExtensionVK extension) const
Definition: capabilities_vk.cc:500
impeller::CapabilitiesVK::SupportsReadFromResolve
bool SupportsReadFromResolve() const override
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
Definition: capabilities_vk.cc:467
vk.h
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:94
impeller::CapabilitiesVK::SetPhysicalDevice
bool SetPhysicalDevice(const vk::PhysicalDevice &physical_device)
Definition: capabilities_vk.cc:346
impeller::Capabilities
Definition: capabilities.h:15
impeller::CapabilitiesVK::~CapabilitiesVK
~CapabilitiesVK()
impeller::CapabilitiesVK::GetDefaultColorFormat
PixelFormat GetDefaultColorFormat() const override
Returns a supported PixelFormat for textures that store 4-channel colors (red/green/blue/alpha).
Definition: capabilities_vk.cc:481
impeller::OptionalDeviceExtensionVK::kEXTRasterizationOrderAttachmentAccess
@ kEXTRasterizationOrderAttachmentAccess
backend_cast.h
impeller::CapabilitiesVK::GetEnabledDeviceFeatures
std::optional< vk::PhysicalDeviceFeatures > GetEnabledDeviceFeatures(const vk::PhysicalDevice &physical_device) const
Definition: capabilities_vk.cc:291
impeller::CapabilitiesVK::CapabilitiesVK
CapabilitiesVK(bool enable_validations)
Definition: capabilities_vk.cc:18
impeller::CapabilitiesVK::GetDefaultDepthStencilFormat
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
Definition: capabilities_vk.cc:491
capabilities.h
impeller::CapabilitiesVK::SupportsBufferToTextureBlits
bool SupportsBufferToTextureBlits() const override
Whether the context backend supports blitting from a given DeviceBuffer view to a texture region (via...
Definition: capabilities_vk.cc:440
impeller::CapabilitiesVK::SupportsCompute
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
Definition: capabilities_vk.cc:455
impeller::CapabilitiesVK
The Vulkan layers and extensions wrangler.
Definition: capabilities_vk.h:33
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::BackendCast
Definition: backend_cast.h:13
impeller::CapabilitiesVK::SupportsDeviceTransientTextures
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
Definition: capabilities_vk.cc:476
impeller::CapabilitiesVK::GetPhysicalDeviceProperties
const vk::PhysicalDeviceProperties & GetPhysicalDeviceProperties() const
Definition: capabilities_vk.cc:496
impeller::CapabilitiesVK::SupportsSSBO
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
Definition: capabilities_vk.cc:435
impeller::CapabilitiesVK::AreValidationsEnabled
bool AreValidationsEnabled() const
Definition: capabilities_vk.cc:62
impeller::CapabilitiesVK::GetEnabledDeviceExtensions
std::optional< std::vector< std::string > > GetEnabledDeviceExtensions(const vk::PhysicalDevice &physical_device) const
Definition: capabilities_vk.cc:197
impeller::CapabilitiesVK::SupportsImplicitResolvingMSAA
bool SupportsImplicitResolvingMSAA() const override
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
Definition: capabilities_vk.cc:430
impeller
Definition: aiks_context.cc:10