| Flutter Impeller |

capabilities.cc
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 #include "impeller/renderer/capabilities.h"
6
7 namespace impeller {
8
9 Capabilities::Capabilities() = default;
10
11 Capabilities::~Capabilities() = default;
12
13 class StandardCapabilities final : public Capabilities {
14 public:
15 // |Capabilities|
16 ~StandardCapabilities() override = default;
17
18 // |Capabilities|
19 bool SupportsOffscreenMSAA() const override {
20 return supports_offscreen_msaa_;
21 }
22
23 // |Capabilities|
24 bool SupportsImplicitResolvingMSAA() const override { return false; }
25
26 // |Capabilities|
27 bool SupportsSSBO() const override { return supports_ssbo_; }
28
29 // |Capabilities|
30 bool SupportsBufferToTextureBlits() const override {
31 return supports_buffer_to_texture_blits_;
32 }
33
34 // |Capabilities|
35 bool SupportsTextureToTextureBlits() const override {
36 return supports_texture_to_texture_blits_;
37 }
38
39 // |Capabilities|
40 bool SupportsFramebufferFetch() const override {
41 return supports_framebuffer_fetch_;
42 }
43
44 // |Capabilities|
45 bool SupportsCompute() const override { return supports_compute_; }
46
47 // |Capabilities|
48 bool SupportsComputeSubgroups() const override {
49 return supports_compute_subgroups_;
50 }
51
52 // |Capabilities|
53 bool SupportsReadFromResolve() const override {
54 return supports_read_from_resolve_;
55 }
56
57 // |Capabilities|
58 bool SupportsDecalSamplerAddressMode() const override {
59 return supports_decal_sampler_address_mode_;
60 }
61
62 // |Capabilities|
63 PixelFormat GetDefaultColorFormat() const override {
64 return default_color_format_;
65 }
66
67 // |Capabilities|
68 PixelFormat GetDefaultStencilFormat() const override {
69 return default_stencil_format_;
70 }
71
72 // |Capabilities|
73 PixelFormat GetDefaultDepthStencilFormat() const override {
74 return default_depth_stencil_format_;
75 }
76
77 bool SupportsDeviceTransientTextures() const override {
78 return supports_device_transient_textures_;
79 }
80
81 private:
82 StandardCapabilities(bool supports_offscreen_msaa,
83 bool supports_ssbo,
84 bool supports_buffer_to_texture_blits,
85 bool supports_texture_to_texture_blits,
86 bool supports_framebuffer_fetch,
87 bool supports_compute,
88 bool supports_compute_subgroups,
89 bool supports_read_from_resolve,
90 bool supports_decal_sampler_address_mode,
91 bool supports_device_transient_textures,
92 PixelFormat default_color_format,
93 PixelFormat default_stencil_format,
94 PixelFormat default_depth_stencil_format)
95 : supports_offscreen_msaa_(supports_offscreen_msaa),
96 supports_ssbo_(supports_ssbo),
97 supports_buffer_to_texture_blits_(supports_buffer_to_texture_blits),
98 supports_texture_to_texture_blits_(supports_texture_to_texture_blits),
99 supports_framebuffer_fetch_(supports_framebuffer_fetch),
100 supports_compute_(supports_compute),
101 supports_compute_subgroups_(supports_compute_subgroups),
102 supports_read_from_resolve_(supports_read_from_resolve),
103 supports_decal_sampler_address_mode_(
104 supports_decal_sampler_address_mode),
105 supports_device_transient_textures_(supports_device_transient_textures),
106 default_color_format_(default_color_format),
107 default_stencil_format_(default_stencil_format),
108 default_depth_stencil_format_(default_depth_stencil_format) {}
109
110 friend class CapabilitiesBuilder;
111
112 bool supports_offscreen_msaa_ = false;
113 bool supports_ssbo_ = false;
114 bool supports_buffer_to_texture_blits_ = false;
115 bool supports_texture_to_texture_blits_ = false;
116 bool supports_framebuffer_fetch_ = false;
117 bool supports_compute_ = false;
118 bool supports_compute_subgroups_ = false;
119 bool supports_read_from_resolve_ = false;
120 bool supports_decal_sampler_address_mode_ = false;
121 bool supports_device_transient_textures_ = false;
122 PixelFormat default_color_format_ = PixelFormat::kUnknown;
123 PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
124 PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
125
126 StandardCapabilities(const StandardCapabilities&) = delete;
127
128 StandardCapabilities& operator=(const StandardCapabilities&) = delete;
129 };
130
131 CapabilitiesBuilder::CapabilitiesBuilder() = default;
132
133 CapabilitiesBuilder::~CapabilitiesBuilder() = default;
134
135 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsOffscreenMSAA(bool value) {
136 supports_offscreen_msaa_ = value;
137 return *this;
138 }
139
140 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsSSBO(bool value) {
141 supports_ssbo_ = value;
142 return *this;
143 }
144
145 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsBufferToTextureBlits(
146 bool value) {
147 supports_buffer_to_texture_blits_ = value;
148 return *this;
149 }
150
151 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsTextureToTextureBlits(
152 bool value) {
153 supports_texture_to_texture_blits_ = value;
154 return *this;
155 }
156
157 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsFramebufferFetch(
158 bool value) {
159 supports_framebuffer_fetch_ = value;
160 return *this;
161 }
162
163 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsCompute(bool value) {
164 supports_compute_ = value;
165 return *this;
166 }
167
168 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsComputeSubgroups(
169 bool value) {
170 supports_compute_subgroups_ = value;
171 return *this;
172 }
173
174 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultColorFormat(
175 PixelFormat value) {
176 default_color_format_ = value;
177 return *this;
178 }
179
180 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultStencilFormat(
181 PixelFormat value) {
182 default_stencil_format_ = value;
183 return *this;
184 }
185
186 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultDepthStencilFormat(
187 PixelFormat value) {
188 default_depth_stencil_format_ = value;
189 return *this;
190 }
191
192 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsReadFromResolve(
193 bool read_from_resolve) {
194 supports_read_from_resolve_ = read_from_resolve;
195 return *this;
196 }
197
198 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode(
199 bool value) {
200 supports_decal_sampler_address_mode_ = value;
201 return *this;
202 }
203
204 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDeviceTransientTextures(
205 bool value) {
206 supports_device_transient_textures_ = value;
207 return *this;
208 }
209
210 std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
211 return std::unique_ptr<StandardCapabilities>(new StandardCapabilities( //
212 supports_offscreen_msaa_, //
213 supports_ssbo_, //
214 supports_buffer_to_texture_blits_, //
215 supports_texture_to_texture_blits_, //
216 supports_framebuffer_fetch_, //
217 supports_compute_, //
218 supports_compute_subgroups_, //
219 supports_read_from_resolve_, //
220 supports_decal_sampler_address_mode_, //
221 supports_device_transient_textures_, //
222 default_color_format_.value_or(PixelFormat::kUnknown), //
223 default_stencil_format_.value_or(PixelFormat::kUnknown), //
224 default_depth_stencil_format_.value_or(PixelFormat::kUnknown) //
225 ));
226 }
227
228 } // namespace impeller
impeller::CapabilitiesBuilder::CapabilitiesBuilder
CapabilitiesBuilder()
impeller::StandardCapabilities::SupportsComputeSubgroups
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
Definition: capabilities.cc:48
impeller::StandardCapabilities::SupportsTextureToTextureBlits
bool SupportsTextureToTextureBlits() const override
Whether the context backend supports blitting from one texture region to another texture region (via ...
Definition: capabilities.cc:35
impeller::StandardCapabilities::SupportsFramebufferFetch
bool SupportsFramebufferFetch() const override
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
Definition: capabilities.cc:40
impeller::StandardCapabilities::SupportsCompute
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
Definition: capabilities.cc:45
impeller::CapabilitiesBuilder::Build
std::unique_ptr< Capabilities > Build()
Definition: capabilities.cc:210
impeller::StandardCapabilities::~StandardCapabilities
~StandardCapabilities() override=default
impeller::StandardCapabilities::GetDefaultStencilFormat
PixelFormat GetDefaultStencilFormat() const override
Returns a supported PixelFormat for textures that store stencil information. May include a depth chan...
Definition: capabilities.cc:68
impeller::CapabilitiesBuilder
Definition: capabilities.h:116
impeller::StandardCapabilities::SupportsReadFromResolve
bool SupportsReadFromResolve() const override
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
Definition: capabilities.cc:53
impeller::StandardCapabilities::SupportsSSBO
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
Definition: capabilities.cc:27
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:94
impeller::Capabilities
Definition: capabilities.h:15
impeller::CapabilitiesBuilder::SetSupportsSSBO
CapabilitiesBuilder & SetSupportsSSBO(bool value)
Definition: capabilities.cc:140
impeller::StandardCapabilities::SupportsImplicitResolvingMSAA
bool SupportsImplicitResolvingMSAA() const override
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
Definition: capabilities.cc:24
impeller::CapabilitiesBuilder::SetSupportsCompute
CapabilitiesBuilder & SetSupportsCompute(bool value)
Definition: capabilities.cc:163
impeller::CapabilitiesBuilder::SetDefaultDepthStencilFormat
CapabilitiesBuilder & SetDefaultDepthStencilFormat(PixelFormat value)
Definition: capabilities.cc:186
impeller::StandardCapabilities
Definition: capabilities.cc:13
impeller::StandardCapabilities::SupportsBufferToTextureBlits
bool SupportsBufferToTextureBlits() const override
Whether the context backend supports blitting from a given DeviceBuffer view to a texture region (via...
Definition: capabilities.cc:30
impeller::CapabilitiesBuilder::SetSupportsFramebufferFetch
CapabilitiesBuilder & SetSupportsFramebufferFetch(bool value)
Definition: capabilities.cc:157
impeller::StandardCapabilities::GetDefaultColorFormat
PixelFormat GetDefaultColorFormat() const override
Returns a supported PixelFormat for textures that store 4-channel colors (red/green/blue/alpha).
Definition: capabilities.cc:63
impeller::CapabilitiesBuilder::~CapabilitiesBuilder
~CapabilitiesBuilder()
impeller::CapabilitiesBuilder::SetSupportsComputeSubgroups
CapabilitiesBuilder & SetSupportsComputeSubgroups(bool value)
Definition: capabilities.cc:168
capabilities.h
impeller::Capabilities::Capabilities
Capabilities()
impeller::StandardCapabilities::SupportsDecalSamplerAddressMode
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
Definition: capabilities.cc:58
impeller::CapabilitiesBuilder::SetSupportsTextureToTextureBlits
CapabilitiesBuilder & SetSupportsTextureToTextureBlits(bool value)
Definition: capabilities.cc:151
impeller::StandardCapabilities::SupportsOffscreenMSAA
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
Definition: capabilities.cc:19
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::StandardCapabilities::SupportsDeviceTransientTextures
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
Definition: capabilities.cc:77
impeller::StandardCapabilities::GetDefaultDepthStencilFormat
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
Definition: capabilities.cc:73
impeller::CapabilitiesBuilder::SetDefaultColorFormat
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
Definition: capabilities.cc:174
impeller::CapabilitiesBuilder::SetDefaultStencilFormat
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
Definition: capabilities.cc:180
impeller::CapabilitiesBuilder::SetSupportsBufferToTextureBlits
CapabilitiesBuilder & SetSupportsBufferToTextureBlits(bool value)
Definition: capabilities.cc:145
impeller::Capabilities::~Capabilities
virtual ~Capabilities()
impeller::CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode
CapabilitiesBuilder & SetSupportsDecalSamplerAddressMode(bool value)
Definition: capabilities.cc:198
impeller::CapabilitiesBuilder::SetSupportsDeviceTransientTextures
CapabilitiesBuilder & SetSupportsDeviceTransientTextures(bool value)
Definition: capabilities.cc:204
impeller
Definition: aiks_context.cc:10
impeller::CapabilitiesBuilder::SetSupportsReadFromResolve
CapabilitiesBuilder & SetSupportsReadFromResolve(bool value)
Definition: capabilities.cc:192
impeller::CapabilitiesBuilder::SetSupportsOffscreenMSAA
CapabilitiesBuilder & SetSupportsOffscreenMSAA(bool value)
Definition: capabilities.cc:135