| 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 SupportsExtendedRangeFormats() const override {
100 return supports_extended_range_formats_;
101 }
102
103 // |Capabilities|
104 size_t GetMinimumUniformAlignment() const override {
105 return minimum_uniform_alignment_;
106 }
107
108 // |Capabilities|
109 bool NeedsPartitionedHostBuffer() const override {
110 return needs_partitioned_host_buffer_;
111 }
112
113 private:
114 StandardCapabilities(bool supports_offscreen_msaa,
115 bool supports_ssbo,
116 bool supports_texture_to_texture_blits,
117 bool supports_framebuffer_fetch,
118 bool supports_compute,
119 bool supports_compute_subgroups,
120 bool supports_read_from_resolve,
121 bool supports_decal_sampler_address_mode,
122 bool supports_device_transient_textures,
123 bool supports_triangle_fan,
124 bool supports_extended_range_formats,
125 PixelFormat default_color_format,
126 PixelFormat default_stencil_format,
127 PixelFormat default_depth_stencil_format,
128 PixelFormat default_glyph_atlas_format,
129 ISize default_maximum_render_pass_attachment_size,
130 size_t minimum_uniform_alignment,
131 bool needs_partitioned_host_buffer)
132 : supports_offscreen_msaa_(supports_offscreen_msaa),
133 supports_ssbo_(supports_ssbo),
134 supports_texture_to_texture_blits_(supports_texture_to_texture_blits),
135 supports_framebuffer_fetch_(supports_framebuffer_fetch),
136 supports_compute_(supports_compute),
137 supports_compute_subgroups_(supports_compute_subgroups),
138 supports_read_from_resolve_(supports_read_from_resolve),
139 supports_decal_sampler_address_mode_(
140 supports_decal_sampler_address_mode),
141 supports_device_transient_textures_(supports_device_transient_textures),
142 supports_triangle_fan_(supports_triangle_fan),
143 supports_extended_range_formats_(supports_extended_range_formats),
144 needs_partitioned_host_buffer_(needs_partitioned_host_buffer),
145 default_color_format_(default_color_format),
146 default_stencil_format_(default_stencil_format),
147 default_depth_stencil_format_(default_depth_stencil_format),
148 default_glyph_atlas_format_(default_glyph_atlas_format),
149 default_maximum_render_pass_attachment_size_(
150 default_maximum_render_pass_attachment_size),
151 minimum_uniform_alignment_(minimum_uniform_alignment) {}
152
153 friend class CapabilitiesBuilder;
154
155 bool supports_offscreen_msaa_ = false;
156 bool supports_ssbo_ = false;
157 bool supports_texture_to_texture_blits_ = false;
158 bool supports_framebuffer_fetch_ = false;
159 bool supports_compute_ = false;
160 bool supports_compute_subgroups_ = false;
161 bool supports_read_from_resolve_ = false;
162 bool supports_decal_sampler_address_mode_ = false;
163 bool supports_device_transient_textures_ = false;
164 bool supports_triangle_fan_ = false;
165 bool supports_extended_range_formats_ = false;
166 bool needs_partitioned_host_buffer_ = false;
167 PixelFormat default_color_format_ = PixelFormat::kUnknown;
168 PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
169 PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
170 PixelFormat default_glyph_atlas_format_ = PixelFormat::kUnknown;
171 ISize default_maximum_render_pass_attachment_size_ = ISize(1, 1);
172 size_t minimum_uniform_alignment_ = 256;
173
174 StandardCapabilities(const StandardCapabilities&) = delete;
175
176 StandardCapabilities& operator=(const StandardCapabilities&) = delete;
177 };
178
179 CapabilitiesBuilder::CapabilitiesBuilder() = default;
180
181 CapabilitiesBuilder::~CapabilitiesBuilder() = default;
182
183 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsOffscreenMSAA(bool value) {
184 supports_offscreen_msaa_ = value;
185 return *this;
186 }
187
188 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsSSBO(bool value) {
189 supports_ssbo_ = value;
190 return *this;
191 }
192
193 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsTextureToTextureBlits(
194 bool value) {
195 supports_texture_to_texture_blits_ = value;
196 return *this;
197 }
198
199 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsFramebufferFetch(
200 bool value) {
201 supports_framebuffer_fetch_ = value;
202 return *this;
203 }
204
205 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsCompute(bool value) {
206 supports_compute_ = value;
207 return *this;
208 }
209
210 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsComputeSubgroups(
211 bool value) {
212 supports_compute_subgroups_ = value;
213 return *this;
214 }
215
216 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultColorFormat(
217 PixelFormat value) {
218 default_color_format_ = value;
219 return *this;
220 }
221
222 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultStencilFormat(
223 PixelFormat value) {
224 default_stencil_format_ = value;
225 return *this;
226 }
227
228 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultDepthStencilFormat(
229 PixelFormat value) {
230 default_depth_stencil_format_ = value;
231 return *this;
232 }
233
234 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsReadFromResolve(
235 bool read_from_resolve) {
236 supports_read_from_resolve_ = read_from_resolve;
237 return *this;
238 }
239
240 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode(
241 bool value) {
242 supports_decal_sampler_address_mode_ = value;
243 return *this;
244 }
245
246 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDeviceTransientTextures(
247 bool value) {
248 supports_device_transient_textures_ = value;
249 return *this;
250 }
251
252 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultGlyphAtlasFormat(
253 PixelFormat value) {
254 default_glyph_atlas_format_ = value;
255 return *this;
256 }
257
258 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsTriangleFan(bool value) {
259 supports_triangle_fan_ = value;
260 return *this;
261 }
262
263 CapabilitiesBuilder& CapabilitiesBuilder::SetMaximumRenderPassAttachmentSize(
264 ISize size) {
265 default_maximum_render_pass_attachment_size_ = size;
266 return *this;
267 }
268
269 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsExtendedRangeFormats(
270 bool value) {
271 supports_extended_range_formats_ = value;
272 return *this;
273 }
274
275 CapabilitiesBuilder& CapabilitiesBuilder::SetMinimumUniformAlignment(
276 size_t value) {
277 minimum_uniform_alignment_ = value;
278 return *this;
279 }
280
281 CapabilitiesBuilder& CapabilitiesBuilder::SetNeedsPartitionedHostBuffer(
282 bool value) {
283 needs_partitioned_host_buffer_ = value;
284 return *this;
285 }
286
287 std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
288 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
289 return std::unique_ptr<StandardCapabilities>(new StandardCapabilities( //
290 supports_offscreen_msaa_, //
291 supports_ssbo_, //
292 supports_texture_to_texture_blits_, //
293 supports_framebuffer_fetch_, //
294 supports_compute_, //
295 supports_compute_subgroups_, //
296 supports_read_from_resolve_, //
297 supports_decal_sampler_address_mode_, //
298 supports_device_transient_textures_, //
299 supports_triangle_fan_, //
300 supports_extended_range_formats_, //
301 default_color_format_.value_or(PixelFormat::kUnknown), //
302 default_stencil_format_.value_or(PixelFormat::kUnknown), //
303 default_depth_stencil_format_.value_or(PixelFormat::kUnknown), //
304 default_glyph_atlas_format_.value_or(PixelFormat::kUnknown), //
305 default_maximum_render_pass_attachment_size_.value_or(ISize{1, 1}), //
306 minimum_uniform_alignment_, //
307 needs_partitioned_host_buffer_ //
308 ));
309 }
310
311 } // namespace impeller
capabilities.h
impeller::CapabilitiesBuilder
Definition: capabilities.h:144
impeller::CapabilitiesBuilder::SetDefaultColorFormat
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
Definition: capabilities.cc:216
impeller::CapabilitiesBuilder::SetSupportsComputeSubgroups
CapabilitiesBuilder & SetSupportsComputeSubgroups(bool value)
Definition: capabilities.cc:210
impeller::CapabilitiesBuilder::SetMinimumUniformAlignment
CapabilitiesBuilder & SetMinimumUniformAlignment(size_t value)
Definition: capabilities.cc:275
impeller::CapabilitiesBuilder::SetSupportsTextureToTextureBlits
CapabilitiesBuilder & SetSupportsTextureToTextureBlits(bool value)
Definition: capabilities.cc:193
impeller::CapabilitiesBuilder::SetDefaultStencilFormat
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
Definition: capabilities.cc:222
impeller::CapabilitiesBuilder::CapabilitiesBuilder
CapabilitiesBuilder()
impeller::CapabilitiesBuilder::SetSupportsDeviceTransientTextures
CapabilitiesBuilder & SetSupportsDeviceTransientTextures(bool value)
Definition: capabilities.cc:246
impeller::CapabilitiesBuilder::SetSupportsTriangleFan
CapabilitiesBuilder & SetSupportsTriangleFan(bool value)
Definition: capabilities.cc:258
impeller::CapabilitiesBuilder::~CapabilitiesBuilder
~CapabilitiesBuilder()
impeller::CapabilitiesBuilder::SetNeedsPartitionedHostBuffer
CapabilitiesBuilder & SetNeedsPartitionedHostBuffer(bool value)
Definition: capabilities.cc:281
impeller::CapabilitiesBuilder::SetSupportsFramebufferFetch
CapabilitiesBuilder & SetSupportsFramebufferFetch(bool value)
Definition: capabilities.cc:199
impeller::CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode
CapabilitiesBuilder & SetSupportsDecalSamplerAddressMode(bool value)
Definition: capabilities.cc:240
impeller::CapabilitiesBuilder::SetSupportsOffscreenMSAA
CapabilitiesBuilder & SetSupportsOffscreenMSAA(bool value)
Definition: capabilities.cc:183
impeller::CapabilitiesBuilder::SetSupportsSSBO
CapabilitiesBuilder & SetSupportsSSBO(bool value)
Definition: capabilities.cc:188
impeller::CapabilitiesBuilder::SetMaximumRenderPassAttachmentSize
CapabilitiesBuilder & SetMaximumRenderPassAttachmentSize(ISize size)
Definition: capabilities.cc:263
impeller::CapabilitiesBuilder::SetSupportsExtendedRangeFormats
CapabilitiesBuilder & SetSupportsExtendedRangeFormats(bool value)
Definition: capabilities.cc:269
impeller::CapabilitiesBuilder::SetDefaultGlyphAtlasFormat
CapabilitiesBuilder & SetDefaultGlyphAtlasFormat(PixelFormat value)
Definition: capabilities.cc:252
impeller::CapabilitiesBuilder::SetSupportsCompute
CapabilitiesBuilder & SetSupportsCompute(bool value)
Definition: capabilities.cc:205
impeller::CapabilitiesBuilder::Build
std::unique_ptr< Capabilities > Build()
Definition: capabilities.cc:287
impeller::CapabilitiesBuilder::SetDefaultDepthStencilFormat
CapabilitiesBuilder & SetDefaultDepthStencilFormat(PixelFormat value)
Definition: capabilities.cc:228
impeller::CapabilitiesBuilder::SetSupportsReadFromResolve
CapabilitiesBuilder & SetSupportsReadFromResolve(bool value)
Definition: capabilities.cc:234
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:109
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:104
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:99
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