| 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 #pragma once
6
7 #include <map>
8 #include <set>
9 #include <string>
10 #include <vector>
11
12 #include "flutter/fml/macros.h"
13 #include "impeller/base/backend_cast.h"
14 #include "impeller/renderer/backend/vulkan/vk.h"
15 #include "impeller/renderer/capabilities.h"
16
17 namespace impeller {
18
19 class ContextVK;
20
21 enum class OptionalDeviceExtensionVK : uint32_t {
22 // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_pipeline_creation_feedback.html
23 kEXTPipelineCreationFeedback,
24 kLast,
25 };
26
27 //------------------------------------------------------------------------------
28 /// @brief The Vulkan layers and extensions wrangler.
29 ///
30 class CapabilitiesVK final : public Capabilities,
31 public BackendCast<CapabilitiesVK, Capabilities> {
32 public:
33 explicit CapabilitiesVK(bool enable_validations);
34
35 ~CapabilitiesVK();
36
37 bool IsValid() const;
38
39 bool AreValidationsEnabled() const;
40
41 bool HasOptionalDeviceExtension(OptionalDeviceExtensionVK extension) const;
42
43 std::optional<std::vector<std::string>> GetEnabledLayers() const;
44
45 std::optional<std::vector<std::string>> GetEnabledInstanceExtensions() const;
46
47 std::optional<std::vector<std::string>> GetEnabledDeviceExtensions(
48 const vk::PhysicalDevice& physical_device) const;
49
50 std::optional<vk::PhysicalDeviceFeatures> GetEnabledDeviceFeatures(
51 const vk::PhysicalDevice& physical_device) const;
52
53 [[nodiscard]] bool SetPhysicalDevice(
54 const vk::PhysicalDevice& physical_device);
55
56 const vk::PhysicalDeviceProperties& GetPhysicalDeviceProperties() const;
57
58 void SetOffscreenFormat(PixelFormat pixel_format) const;
59
60 // |Capabilities|
61 bool SupportsOffscreenMSAA() const override;
62
63 // |Capabilities|
64 bool SupportsSSBO() const override;
65
66 // |Capabilities|
67 bool SupportsBufferToTextureBlits() const override;
68
69 // |Capabilities|
70 bool SupportsTextureToTextureBlits() const override;
71
72 // |Capabilities|
73 bool SupportsFramebufferFetch() const override;
74
75 // |Capabilities|
76 bool SupportsCompute() const override;
77
78 // |Capabilities|
79 bool SupportsComputeSubgroups() const override;
80
81 // |Capabilities|
82 bool SupportsReadFromResolve() const override;
83
84 // |Capabilities|
85 bool SupportsReadFromOnscreenTexture() const override;
86
87 // |Capabilities|
88 bool SupportsDecalSamplerAddressMode() const override;
89
90 // |Capabilities|
91 bool SupportsDeviceTransientTextures() const override;
92
93 // |Capabilities|
94 PixelFormat GetDefaultColorFormat() const override;
95
96 // |Capabilities|
97 PixelFormat GetDefaultStencilFormat() const override;
98
99 // |Capabilities|
100 PixelFormat GetDefaultDepthStencilFormat() const override;
101
102 private:
103 bool validations_enabled_ = false;
104 std::map<std::string, std::set<std::string>> exts_;
105 std::set<OptionalDeviceExtensionVK> optional_device_extensions_;
106 mutable PixelFormat default_color_format_ = PixelFormat::kUnknown;
107 PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
108 PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
109 vk::PhysicalDeviceProperties device_properties_;
110 bool supports_compute_subgroups_ = false;
111 bool supports_device_transient_textures_ = false;
112 bool is_valid_ = false;
113
114 bool HasExtension(const std::string& ext) const;
115
116 bool HasLayer(const std::string& layer) const;
117
118 FML_DISALLOW_COPY_AND_ASSIGN(CapabilitiesVK);
119 };
120
121 } // namespace impeller
impeller::OptionalDeviceExtensionVK
OptionalDeviceExtensionVK
Definition: capabilities_vk.h:21
impeller::CapabilitiesVK::SupportsDecalSamplerAddressMode
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
Definition: capabilities_vk.cc:454
impeller::CapabilitiesVK::SetOffscreenFormat
void SetOffscreenFormat(PixelFormat pixel_format) const
Definition: capabilities_vk.cc:337
impeller::CapabilitiesVK::GetEnabledInstanceExtensions
std::optional< std::vector< std::string > > GetEnabledInstanceExtensions() const
Definition: capabilities_vk.cc:78
impeller::CapabilitiesVK::IsValid
bool IsValid() const
Definition: capabilities_vk.cc:57
impeller::CapabilitiesVK::SupportsOffscreenMSAA
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
Definition: capabilities_vk.cc:408
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:428
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:469
impeller::CapabilitiesVK::GetEnabledLayers
std::optional< std::vector< std::string > > GetEnabledLayers() const
Definition: capabilities_vk.cc:65
impeller::OptionalDeviceExtensionVK::kEXTPipelineCreationFeedback
@ kEXTPipelineCreationFeedback
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:423
impeller::CapabilitiesVK::SupportsComputeSubgroups
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
Definition: capabilities_vk.cc:439
impeller::CapabilitiesVK::HasOptionalDeviceExtension
bool HasOptionalDeviceExtension(OptionalDeviceExtensionVK extension) const
Definition: capabilities_vk.cc:483
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:445
vk.h
impeller::CapabilitiesVK::SetPhysicalDevice
bool SetPhysicalDevice(const vk::PhysicalDevice &physical_device)
Definition: capabilities_vk.cc:341
impeller::Capabilities
Definition: capabilities.h:14
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:464
backend_cast.h
impeller::CapabilitiesVK::GetEnabledDeviceFeatures
std::optional< vk::PhysicalDeviceFeatures > GetEnabledDeviceFeatures(const vk::PhysicalDevice &physical_device) const
Definition: capabilities_vk.cc:286
impeller::CapabilitiesVK::CapabilitiesVK
CapabilitiesVK(bool enable_validations)
Definition: capabilities_vk.cc:17
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:474
capabilities.h
impeller::PixelFormat::kUnknown
@ kUnknown
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:418
impeller::CapabilitiesVK::SupportsCompute
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
Definition: capabilities_vk.cc:433
impeller::CapabilitiesVK
The Vulkan layers and extensions wrangler.
Definition: capabilities_vk.h:30
impeller::BackendCast
Definition: backend_cast.h:12
impeller::CapabilitiesVK::SupportsDeviceTransientTextures
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
Definition: capabilities_vk.cc:459
impeller::CapabilitiesVK::GetPhysicalDeviceProperties
const vk::PhysicalDeviceProperties & GetPhysicalDeviceProperties() const
Definition: capabilities_vk.cc:479
impeller::CapabilitiesVK::SupportsSSBO
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
Definition: capabilities_vk.cc:413
impeller::CapabilitiesVK::AreValidationsEnabled
bool AreValidationsEnabled() const
Definition: capabilities_vk.cc:61
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:94
impeller::CapabilitiesVK::GetEnabledDeviceExtensions
std::optional< std::vector< std::string > > GetEnabledDeviceExtensions(const vk::PhysicalDevice &physical_device) const
Definition: capabilities_vk.cc:192
impeller
Definition: aiks_context.cc:10
impeller::CapabilitiesVK::SupportsReadFromOnscreenTexture
bool SupportsReadFromOnscreenTexture() const override
Whether the context backend supports binding the on-screen surface texture for shader reading.
Definition: capabilities_vk.cc:450