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