Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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
7
8namespace impeller {
9
11
13
17
18class 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|
67 return default_color_format_;
68 }
69
70 // |Capabilities|
72 return default_stencil_format_;
73 }
74
75 // |Capabilities|
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|
87 return default_glyph_atlas_format_;
88 }
89
90 // |Capabilities|
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 SupportsManuallyMippedTextures() const override { return true; }
103
104 // |Capabilities|
105 bool SupportsExtendedRangeFormats() const override {
106 return supports_extended_range_formats_;
107 }
108
109 // |Capabilities|
110 bool SupportsFramebufferRenderMipmap() const override { return true; }
111
112 // |Capabilities|
114 CompressedTextureFamily family) const override {
115 switch (family) {
117 return supports_texture_compression_bc_;
119 return supports_texture_compression_etc2_;
121 return supports_texture_compression_astc_;
123 return supports_texture_compression_astc_hdr_;
124 }
125 return false;
126 }
127
128 // |Capabilities|
129 uint32_t GetMaxSamplerAnisotropy() const override {
130 return max_sampler_anisotropy_;
131 }
132
133 // |Capabilities|
134 size_t GetMinimumUniformAlignment() const override {
135 return minimum_uniform_alignment_;
136 }
137
138 // |Capabilities|
139 bool NeedsPartitionedHostBuffer() const override {
140 return needs_partitioned_host_buffer_;
141 }
142
143 private:
144 StandardCapabilities(bool supports_offscreen_msaa,
145 bool supports_ssbo,
146 bool supports_texture_to_texture_blits,
147 bool supports_framebuffer_fetch,
148 bool supports_compute,
149 bool supports_compute_subgroups,
150 bool supports_read_from_resolve,
151 bool supports_decal_sampler_address_mode,
152 bool supports_device_transient_textures,
153 bool supports_triangle_fan,
154 bool supports_extended_range_formats,
155 PixelFormat default_color_format,
156 PixelFormat default_stencil_format,
157 PixelFormat default_depth_stencil_format,
158 PixelFormat default_glyph_atlas_format,
159 ISize default_maximum_render_pass_attachment_size,
160 uint32_t max_sampler_anisotropy,
161 size_t minimum_uniform_alignment,
162 bool needs_partitioned_host_buffer,
163 bool supports_texture_compression_bc,
164 bool supports_texture_compression_etc2,
165 bool supports_texture_compression_astc,
166 bool supports_texture_compression_astc_hdr)
167 : supports_offscreen_msaa_(supports_offscreen_msaa),
168 supports_ssbo_(supports_ssbo),
169 supports_texture_to_texture_blits_(supports_texture_to_texture_blits),
170 supports_framebuffer_fetch_(supports_framebuffer_fetch),
171 supports_compute_(supports_compute),
172 supports_compute_subgroups_(supports_compute_subgroups),
173 supports_read_from_resolve_(supports_read_from_resolve),
174 supports_decal_sampler_address_mode_(
175 supports_decal_sampler_address_mode),
176 supports_device_transient_textures_(supports_device_transient_textures),
177 supports_triangle_fan_(supports_triangle_fan),
178 supports_extended_range_formats_(supports_extended_range_formats),
179 needs_partitioned_host_buffer_(needs_partitioned_host_buffer),
180 default_color_format_(default_color_format),
181 default_stencil_format_(default_stencil_format),
182 default_depth_stencil_format_(default_depth_stencil_format),
183 default_glyph_atlas_format_(default_glyph_atlas_format),
184 default_maximum_render_pass_attachment_size_(
185 default_maximum_render_pass_attachment_size),
186 max_sampler_anisotropy_(max_sampler_anisotropy),
187 minimum_uniform_alignment_(minimum_uniform_alignment),
188 supports_texture_compression_bc_(supports_texture_compression_bc),
189 supports_texture_compression_etc2_(supports_texture_compression_etc2),
190 supports_texture_compression_astc_(supports_texture_compression_astc),
191 supports_texture_compression_astc_hdr_(
192 supports_texture_compression_astc_hdr) {}
193
195
196 bool supports_offscreen_msaa_ = false;
197 bool supports_ssbo_ = false;
198 bool supports_texture_to_texture_blits_ = false;
199 bool supports_framebuffer_fetch_ = false;
200 bool supports_compute_ = false;
201 bool supports_compute_subgroups_ = false;
202 bool supports_read_from_resolve_ = false;
203 bool supports_decal_sampler_address_mode_ = false;
204 bool supports_device_transient_textures_ = false;
205 bool supports_triangle_fan_ = false;
206 bool supports_extended_range_formats_ = false;
207 bool needs_partitioned_host_buffer_ = false;
208 PixelFormat default_color_format_ = PixelFormat::kUnknown;
209 PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
210 PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
211 PixelFormat default_glyph_atlas_format_ = PixelFormat::kUnknown;
212 ISize default_maximum_render_pass_attachment_size_ = ISize(1, 1);
213 uint32_t max_sampler_anisotropy_ = 1;
214 size_t minimum_uniform_alignment_ = 256;
215 bool supports_texture_compression_bc_ = false;
216 bool supports_texture_compression_etc2_ = false;
217 bool supports_texture_compression_astc_ = false;
218 bool supports_texture_compression_astc_hdr_ = false;
219
221
222 StandardCapabilities& operator=(const StandardCapabilities&) = delete;
223};
224
226
228
230 supports_offscreen_msaa_ = value;
231 return *this;
232}
233
235 supports_ssbo_ = value;
236 return *this;
237}
238
240 bool value) {
241 supports_texture_to_texture_blits_ = value;
242 return *this;
243}
244
246 bool value) {
247 supports_framebuffer_fetch_ = value;
248 return *this;
249}
250
252 supports_compute_ = value;
253 return *this;
254}
255
257 bool value) {
258 supports_compute_subgroups_ = value;
259 return *this;
260}
261
263 PixelFormat value) {
264 default_color_format_ = value;
265 return *this;
266}
267
269 PixelFormat value) {
270 default_stencil_format_ = value;
271 return *this;
272}
273
275 PixelFormat value) {
276 default_depth_stencil_format_ = value;
277 return *this;
278}
279
281 bool read_from_resolve) {
282 supports_read_from_resolve_ = read_from_resolve;
283 return *this;
284}
285
287 bool value) {
288 supports_decal_sampler_address_mode_ = value;
289 return *this;
290}
291
293 bool value) {
294 supports_device_transient_textures_ = value;
295 return *this;
296}
297
299 PixelFormat value) {
300 default_glyph_atlas_format_ = value;
301 return *this;
302}
303
305 supports_triangle_fan_ = value;
306 return *this;
307}
308
310 ISize size) {
311 default_maximum_render_pass_attachment_size_ = size;
312 return *this;
313}
314
316 bool value) {
317 supports_extended_range_formats_ = value;
318 return *this;
319}
320
323 bool value) {
324 switch (family) {
326 supports_texture_compression_bc_ = value;
327 break;
329 supports_texture_compression_etc2_ = value;
330 break;
332 supports_texture_compression_astc_ = value;
333 break;
335 supports_texture_compression_astc_hdr_ = value;
336 break;
337 }
338 return *this;
339}
340
342 uint32_t value) {
343 max_sampler_anisotropy_ = value;
344 return *this;
345}
346
348 size_t value) {
349 minimum_uniform_alignment_ = value;
350 return *this;
351}
352
354 bool value) {
355 needs_partitioned_host_buffer_ = value;
356 return *this;
357}
358
359std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
360 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
361 return std::unique_ptr<StandardCapabilities>(new StandardCapabilities( //
362 supports_offscreen_msaa_, //
363 supports_ssbo_, //
364 supports_texture_to_texture_blits_, //
365 supports_framebuffer_fetch_, //
366 supports_compute_, //
367 supports_compute_subgroups_, //
368 supports_read_from_resolve_, //
369 supports_decal_sampler_address_mode_, //
370 supports_device_transient_textures_, //
371 supports_triangle_fan_, //
372 supports_extended_range_formats_, //
373 default_color_format_.value_or(PixelFormat::kUnknown), //
374 default_stencil_format_.value_or(PixelFormat::kUnknown), //
375 default_depth_stencil_format_.value_or(PixelFormat::kUnknown), //
376 default_glyph_atlas_format_.value_or(PixelFormat::kUnknown), //
377 default_maximum_render_pass_attachment_size_.value_or(ISize{1, 1}), //
378 max_sampler_anisotropy_, //
379 minimum_uniform_alignment_, //
380 needs_partitioned_host_buffer_, //
381 supports_texture_compression_bc_, //
382 supports_texture_compression_etc2_, //
383 supports_texture_compression_astc_, //
384 supports_texture_compression_astc_hdr_ //
385 ));
386}
387
388} // namespace impeller
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
CapabilitiesBuilder & SetSupportsComputeSubgroups(bool value)
CapabilitiesBuilder & SetMinimumUniformAlignment(size_t value)
CapabilitiesBuilder & SetSupportsTextureToTextureBlits(bool value)
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
CapabilitiesBuilder & SetSupportsDeviceTransientTextures(bool value)
CapabilitiesBuilder & SetSupportsTriangleFan(bool value)
CapabilitiesBuilder & SetMaxSamplerAnisotropy(uint32_t value)
CapabilitiesBuilder & SetNeedsPartitionedHostBuffer(bool value)
CapabilitiesBuilder & SetSupportsFramebufferFetch(bool value)
CapabilitiesBuilder & SetSupportsDecalSamplerAddressMode(bool value)
CapabilitiesBuilder & SetSupportsTextureCompression(CompressedTextureFamily family, bool value)
CapabilitiesBuilder & SetSupportsOffscreenMSAA(bool value)
CapabilitiesBuilder & SetSupportsSSBO(bool value)
CapabilitiesBuilder & SetMaximumRenderPassAttachmentSize(ISize size)
CapabilitiesBuilder & SetSupportsExtendedRangeFormats(bool value)
CapabilitiesBuilder & SetDefaultGlyphAtlasFormat(PixelFormat value)
CapabilitiesBuilder & SetSupportsCompute(bool value)
std::unique_ptr< Capabilities > Build()
CapabilitiesBuilder & SetDefaultDepthStencilFormat(PixelFormat value)
CapabilitiesBuilder & SetSupportsReadFromResolve(bool value)
virtual size_t GetMinimumUniformAlignment() const =0
The minimum alignment of uniform value offsets in bytes.
virtual size_t GetMinimumStorageBufferAlignment() const
The minimum alignment of storage buffer value offsets in bytes.
~StandardCapabilities() override=default
bool SupportsManuallyMippedTextures() const override
Whether a texture whose mip levels were uploaded by hand (rather than produced by BlitPass::GenerateM...
bool SupportsReadFromResolve() const override
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
bool NeedsPartitionedHostBuffer() const override
Whether the host buffer should use separate device buffers for indexes from other data.
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
ISize GetMaximumRenderPassAttachmentSize() const override
Return the maximum size of a render pass attachment.
bool SupportsTextureToTextureBlits() const override
Whether the context backend supports blitting from one texture region to another texture region (via ...
bool SupportsFramebufferFetch() const override
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
PixelFormat GetDefaultGlyphAtlasFormat() const override
Returns the default pixel format for the alpha bitmap glyph atlas.
PixelFormat GetDefaultStencilFormat() const override
Returns a supported PixelFormat for textures that store stencil information. May include a depth chan...
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
size_t GetMinimumUniformAlignment() const override
The minimum alignment of uniform value offsets in bytes.
bool Supports32BitPrimitiveIndices() const override
Whether 32-bit values are supported in index buffers used to draw primitives.
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
bool SupportsFramebufferRenderMipmap() const override
Whether a non-zero mip level of a texture can be attached as a render target. Rendering into a cube m...
bool SupportsImplicitResolvingMSAA() const override
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
uint32_t GetMaxSamplerAnisotropy() const override
The maximum anisotropy clamp supported by device samplers.
bool SupportsPrimitiveRestart() const override
Whether primitive restart is supported.
PixelFormat GetDefaultColorFormat() const override
Returns a supported PixelFormat for textures that store 4-channel colors (red/green/blue/alpha).
bool SupportsExtendedRangeFormats() const override
Whether the XR formats are supported on this device.
bool SupportsTextureCompression(CompressedTextureFamily family) const override
Whether the given family of block-compressed texture formats is supported by this device....
bool SupportsTriangleFan() const override
Whether the primitive type TriangleFan is supported by the backend.
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
int32_t value
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:99
CompressedTextureFamily
The family of a block-compressed pixel format. GPUs support compressed formats on a per-family basis,...
Definition formats.h:146
@ kASTCHDR
ASTC HDR. A separate device feature from ASTC LDR.
@ kBC
S3TC, RGTC, and BPTC (BC1 through BC7). Desktop GPUs.
@ kETC2
ETC2 and EAC. Mobile, OpenGL ES 3.0, and WebGL2.
@ kASTC
ASTC LDR. Modern mobile and some desktop.
ISize64 ISize
Definition size.h:162