| 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 #include "impeller/core/formats.h"
7
8 namespace impeller {
9
10 Capabilities::Capabilities() = default;
11
12 Capabilities::~Capabilities() = default;
13
14 class StandardCapabilities final : public Capabilities {
15 public:
16 // |Capabilities|
17 ~StandardCapabilities() override = default;
18
19 // |Capabilities|
20 bool SupportsOffscreenMSAA() const override {
21 return supports_offscreen_msaa_;
22 }
23
24 // |Capabilities|
25 bool SupportsImplicitResolvingMSAA() const override { return false; }
26
27 // |Capabilities|
28 bool SupportsSSBO() const override { return supports_ssbo_; }
29
30 // |Capabilities|
31 bool SupportsTextureToTextureBlits() const override {
32 return supports_texture_to_texture_blits_;
33 }
34
35 // |Capabilities|
36 bool SupportsFramebufferFetch() const override {
37 return supports_framebuffer_fetch_;
38 }
39
40 // |Capabilities|
41 bool SupportsCompute() const override { return supports_compute_; }
42
43 // |Capabilities|
44 bool SupportsComputeSubgroups() const override {
45 return supports_compute_subgroups_;
46 }
47
48 // |Capabilities|
49 bool SupportsReadFromResolve() const override {
50 return supports_read_from_resolve_;
51 }
52
53 // |Capabilities|
54 bool SupportsDecalSamplerAddressMode() const override {
55 return supports_decal_sampler_address_mode_;
56 }
57
58 // |Capabilities|
59 bool SupportsTriangleFan() const override { return supports_triangle_fan_; }
60
61 // |Capabilities|
62 PixelFormat GetDefaultColorFormat() const override {
63 return default_color_format_;
64 }
65
66 // |Capabilities|
67 PixelFormat GetDefaultStencilFormat() const override {
68 return default_stencil_format_;
69 }
70
71 // |Capabilities|
72 PixelFormat GetDefaultDepthStencilFormat() const override {
73 return default_depth_stencil_format_;
74 }
75
76 // |Capabilities|
77 bool SupportsDeviceTransientTextures() const override {
78 return supports_device_transient_textures_;
79 }
80
81 // |Capabilities|
82 PixelFormat GetDefaultGlyphAtlasFormat() const override {
83 return default_glyph_atlas_format_;
84 }
85
86 // |Capabilities|
87 ISize GetMaximumRenderPassAttachmentSize() const override {
88 return default_maximum_render_pass_attachment_size_;
89 }
90
91 // |Capabilities|
92 bool SupportsPrimitiveRestart() const override { return true; }
93
94 // |Capabilities|
95 bool SupportsExtendedRangeFormats() const override {
96 return supports_extended_range_formats_;
97 }
98
99 // |Capabilities|
100 size_t GetMinimumUniformAlignment() const override {
101 return minimum_uniform_alignment_;
102 }
103
104 // |Capabilities|
105 bool NeedsPartitionedHostBuffer() const override {
106 return needs_partitioned_host_buffer_;
107 }
108
109 private:
110 StandardCapabilities(bool supports_offscreen_msaa,
111 bool supports_ssbo,
112 bool supports_texture_to_texture_blits,
113 bool supports_framebuffer_fetch,
114 bool supports_compute,
115 bool supports_compute_subgroups,
116 bool supports_read_from_resolve,
117 bool supports_decal_sampler_address_mode,
118 bool supports_device_transient_textures,
119 bool supports_triangle_fan,
120 bool supports_extended_range_formats,
121 PixelFormat default_color_format,
122 PixelFormat default_stencil_format,
123 PixelFormat default_depth_stencil_format,
124 PixelFormat default_glyph_atlas_format,
125 ISize default_maximum_render_pass_attachment_size,
126 size_t minimum_uniform_alignment,
127 bool needs_partitioned_host_buffer)
128 : supports_offscreen_msaa_(supports_offscreen_msaa),
129 supports_ssbo_(supports_ssbo),
130 supports_texture_to_texture_blits_(supports_texture_to_texture_blits),
131 supports_framebuffer_fetch_(supports_framebuffer_fetch),
132 supports_compute_(supports_compute),
133 supports_compute_subgroups_(supports_compute_subgroups),
134 supports_read_from_resolve_(supports_read_from_resolve),
135 supports_decal_sampler_address_mode_(
136 supports_decal_sampler_address_mode),
137 supports_device_transient_textures_(supports_device_transient_textures),
138 supports_triangle_fan_(supports_triangle_fan),
139 supports_extended_range_formats_(supports_extended_range_formats),
140 needs_partitioned_host_buffer_(needs_partitioned_host_buffer),
141 default_color_format_(default_color_format),
142 default_stencil_format_(default_stencil_format),
143 default_depth_stencil_format_(default_depth_stencil_format),
144 default_glyph_atlas_format_(default_glyph_atlas_format),
145 default_maximum_render_pass_attachment_size_(
146 default_maximum_render_pass_attachment_size),
147 minimum_uniform_alignment_(minimum_uniform_alignment) {}
148
149 friend class CapabilitiesBuilder;
150
151 bool supports_offscreen_msaa_ = false;
152 bool supports_ssbo_ = false;
153 bool supports_texture_to_texture_blits_ = false;
154 bool supports_framebuffer_fetch_ = false;
155 bool supports_compute_ = false;
156 bool supports_compute_subgroups_ = false;
157 bool supports_read_from_resolve_ = false;
158 bool supports_decal_sampler_address_mode_ = false;
159 bool supports_device_transient_textures_ = false;
160 bool supports_triangle_fan_ = false;
161 bool supports_extended_range_formats_ = false;
162 bool needs_partitioned_host_buffer_ = false;
163 PixelFormat default_color_format_ = PixelFormat::kUnknown;
164 PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
165 PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
166 PixelFormat default_glyph_atlas_format_ = PixelFormat::kUnknown;
167 ISize default_maximum_render_pass_attachment_size_ = ISize(1, 1);
168 size_t minimum_uniform_alignment_ = 256;
169
170 StandardCapabilities(const StandardCapabilities&) = delete;
171
172 StandardCapabilities& operator=(const StandardCapabilities&) = delete;
173 };
174
175 CapabilitiesBuilder::CapabilitiesBuilder() = default;
176
177 CapabilitiesBuilder::~CapabilitiesBuilder() = default;
178
179 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsOffscreenMSAA(bool value) {
180 supports_offscreen_msaa_ = value;
181 return *this;
182 }
183
184 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsSSBO(bool value) {
185 supports_ssbo_ = value;
186 return *this;
187 }
188
189 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsTextureToTextureBlits(
190 bool value) {
191 supports_texture_to_texture_blits_ = value;
192 return *this;
193 }
194
195 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsFramebufferFetch(
196 bool value) {
197 supports_framebuffer_fetch_ = value;
198 return *this;
199 }
200
201 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsCompute(bool value) {
202 supports_compute_ = value;
203 return *this;
204 }
205
206 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsComputeSubgroups(
207 bool value) {
208 supports_compute_subgroups_ = value;
209 return *this;
210 }
211
212 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultColorFormat(
213 PixelFormat value) {
214 default_color_format_ = value;
215 return *this;
216 }
217
218 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultStencilFormat(
219 PixelFormat value) {
220 default_stencil_format_ = value;
221 return *this;
222 }
223
224 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultDepthStencilFormat(
225 PixelFormat value) {
226 default_depth_stencil_format_ = value;
227 return *this;
228 }
229
230 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsReadFromResolve(
231 bool read_from_resolve) {
232 supports_read_from_resolve_ = read_from_resolve;
233 return *this;
234 }
235
236 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode(
237 bool value) {
238 supports_decal_sampler_address_mode_ = value;
239 return *this;
240 }
241
242 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDeviceTransientTextures(
243 bool value) {
244 supports_device_transient_textures_ = value;
245 return *this;
246 }
247
248 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultGlyphAtlasFormat(
249 PixelFormat value) {
250 default_glyph_atlas_format_ = value;
251 return *this;
252 }
253
254 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsTriangleFan(bool value) {
255 supports_triangle_fan_ = value;
256 return *this;
257 }
258
259 CapabilitiesBuilder& CapabilitiesBuilder::SetMaximumRenderPassAttachmentSize(
260 ISize size) {
261 default_maximum_render_pass_attachment_size_ = size;
262 return *this;
263 }
264
265 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsExtendedRangeFormats(
266 bool value) {
267 supports_extended_range_formats_ = value;
268 return *this;
269 }
270
271 CapabilitiesBuilder& CapabilitiesBuilder::SetMinimumUniformAlignment(
272 size_t value) {
273 minimum_uniform_alignment_ = value;
274 return *this;
275 }
276
277 CapabilitiesBuilder& CapabilitiesBuilder::SetNeedsPartitionedHostBuffer(
278 bool value) {
279 needs_partitioned_host_buffer_ = value;
280 return *this;
281 }
282
283 std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
284 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
285 return std::unique_ptr<StandardCapabilities>(new StandardCapabilities( //
286 supports_offscreen_msaa_, //
287 supports_ssbo_, //
288 supports_texture_to_texture_blits_, //
289 supports_framebuffer_fetch_, //
290 supports_compute_, //
291 supports_compute_subgroups_, //
292 supports_read_from_resolve_, //
293 supports_decal_sampler_address_mode_, //
294 supports_device_transient_textures_, //
295 supports_triangle_fan_, //
296 supports_extended_range_formats_, //
297 default_color_format_.value_or(PixelFormat::kUnknown), //
298 default_stencil_format_.value_or(PixelFormat::kUnknown), //
299 default_depth_stencil_format_.value_or(PixelFormat::kUnknown), //
300 default_glyph_atlas_format_.value_or(PixelFormat::kUnknown), //
301 default_maximum_render_pass_attachment_size_.value_or(ISize{1, 1}), //
302 minimum_uniform_alignment_, //
303 needs_partitioned_host_buffer_ //
304 ));
305 }
306
307 } // namespace impeller
capabilities.h
impeller::CapabilitiesBuilder
Definition: capabilities.h:141
impeller::CapabilitiesBuilder::SetDefaultColorFormat
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
Definition: capabilities.cc:212
impeller::CapabilitiesBuilder::SetSupportsComputeSubgroups
CapabilitiesBuilder & SetSupportsComputeSubgroups(bool value)
Definition: capabilities.cc:206
impeller::CapabilitiesBuilder::SetMinimumUniformAlignment
CapabilitiesBuilder & SetMinimumUniformAlignment(size_t value)
Definition: capabilities.cc:271
impeller::CapabilitiesBuilder::SetSupportsTextureToTextureBlits
CapabilitiesBuilder & SetSupportsTextureToTextureBlits(bool value)
Definition: capabilities.cc:189
impeller::CapabilitiesBuilder::SetDefaultStencilFormat
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
Definition: capabilities.cc:218
impeller::CapabilitiesBuilder::CapabilitiesBuilder
CapabilitiesBuilder()
impeller::CapabilitiesBuilder::SetSupportsDeviceTransientTextures
CapabilitiesBuilder & SetSupportsDeviceTransientTextures(bool value)
Definition: capabilities.cc:242
impeller::CapabilitiesBuilder::SetSupportsTriangleFan
CapabilitiesBuilder & SetSupportsTriangleFan(bool value)
Definition: capabilities.cc:254
impeller::CapabilitiesBuilder::~CapabilitiesBuilder
~CapabilitiesBuilder()
impeller::CapabilitiesBuilder::SetNeedsPartitionedHostBuffer
CapabilitiesBuilder & SetNeedsPartitionedHostBuffer(bool value)
Definition: capabilities.cc:277
impeller::CapabilitiesBuilder::SetSupportsFramebufferFetch
CapabilitiesBuilder & SetSupportsFramebufferFetch(bool value)
Definition: capabilities.cc:195
impeller::CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode
CapabilitiesBuilder & SetSupportsDecalSamplerAddressMode(bool value)
Definition: capabilities.cc:236
impeller::CapabilitiesBuilder::SetSupportsOffscreenMSAA
CapabilitiesBuilder & SetSupportsOffscreenMSAA(bool value)
Definition: capabilities.cc:179
impeller::CapabilitiesBuilder::SetSupportsSSBO
CapabilitiesBuilder & SetSupportsSSBO(bool value)
Definition: capabilities.cc:184
impeller::CapabilitiesBuilder::SetMaximumRenderPassAttachmentSize
CapabilitiesBuilder & SetMaximumRenderPassAttachmentSize(ISize size)
Definition: capabilities.cc:259
impeller::CapabilitiesBuilder::SetSupportsExtendedRangeFormats
CapabilitiesBuilder & SetSupportsExtendedRangeFormats(bool value)
Definition: capabilities.cc:265
impeller::CapabilitiesBuilder::SetDefaultGlyphAtlasFormat
CapabilitiesBuilder & SetDefaultGlyphAtlasFormat(PixelFormat value)
Definition: capabilities.cc:248
impeller::CapabilitiesBuilder::SetSupportsCompute
CapabilitiesBuilder & SetSupportsCompute(bool value)
Definition: capabilities.cc:201
impeller::CapabilitiesBuilder::Build
std::unique_ptr< Capabilities > Build()
Definition: capabilities.cc:283
impeller::CapabilitiesBuilder::SetDefaultDepthStencilFormat
CapabilitiesBuilder & SetDefaultDepthStencilFormat(PixelFormat value)
Definition: capabilities.cc:224
impeller::CapabilitiesBuilder::SetSupportsReadFromResolve
CapabilitiesBuilder & SetSupportsReadFromResolve(bool value)
Definition: capabilities.cc:230
impeller::Capabilities
Definition: capabilities.h:14
impeller::Capabilities::Capabilities
Capabilities()
impeller::Capabilities::~Capabilities
virtual ~Capabilities()
impeller::StandardCapabilities
Definition: capabilities.cc:14
impeller::StandardCapabilities::~StandardCapabilities
~StandardCapabilities() override=default
impeller::StandardCapabilities::SupportsReadFromResolve
bool SupportsReadFromResolve() const override
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
Definition: capabilities.cc:49
impeller::StandardCapabilities::NeedsPartitionedHostBuffer
bool NeedsPartitionedHostBuffer() const override
Whether the host buffer should use separate device buffers for indexes from other data.
Definition: capabilities.cc:105
impeller::StandardCapabilities::GetDefaultDepthStencilFormat
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
Definition: capabilities.cc:72
impeller::StandardCapabilities::SupportsComputeSubgroups
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
Definition: capabilities.cc:44
impeller::StandardCapabilities::SupportsOffscreenMSAA
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
Definition: capabilities.cc:20
impeller::StandardCapabilities::GetMaximumRenderPassAttachmentSize
ISize GetMaximumRenderPassAttachmentSize() const override
Return the maximum size of a render pass attachment.
Definition: capabilities.cc:87
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:31
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:36
impeller::StandardCapabilities::GetDefaultGlyphAtlasFormat
PixelFormat GetDefaultGlyphAtlasFormat() const override
Returns the default pixel format for the alpha bitmap glyph atlas.
Definition: capabilities.cc:82
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:67
impeller::StandardCapabilities::SupportsCompute
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
Definition: capabilities.cc:41
impeller::StandardCapabilities::GetMinimumUniformAlignment
size_t GetMinimumUniformAlignment() const override
The minimum alignment of uniform value offsets in bytes.
Definition: capabilities.cc:100
impeller::StandardCapabilities::SupportsSSBO
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
Definition: capabilities.cc:28
impeller::StandardCapabilities::SupportsDeviceTransientTextures
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
Definition: capabilities.cc:77
impeller::StandardCapabilities::SupportsImplicitResolvingMSAA
bool SupportsImplicitResolvingMSAA() const override
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
Definition: capabilities.cc:25
impeller::StandardCapabilities::SupportsPrimitiveRestart
bool SupportsPrimitiveRestart() const override
Whether primitive restart is supported.
Definition: capabilities.cc:92
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:62
impeller::StandardCapabilities::SupportsExtendedRangeFormats
bool SupportsExtendedRangeFormats() const override
Whether the XR formats are supported on this device.
Definition: capabilities.cc:95
impeller::StandardCapabilities::SupportsTriangleFan
bool SupportsTriangleFan() const override
Whether the primitive type TriangleFan is supported by the backend.
Definition: capabilities.cc:59
impeller::StandardCapabilities::SupportsDecalSamplerAddressMode
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
Definition: capabilities.cc:54
formats.h
value
int32_t value
Definition: dl_golden_unittests.cc:459
impeller
Definition: allocation.cc:12
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::ISize
ISize64 ISize
Definition: size.h:162
impeller::TSize
Definition: size.h:25