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 size_t GetMinimumUniformAlignment() const override {
130 return minimum_uniform_alignment_;
131 }
132
133 // |Capabilities|
134 bool NeedsPartitionedHostBuffer() const override {
135 return needs_partitioned_host_buffer_;
136 }
137
138 private:
139 StandardCapabilities(bool supports_offscreen_msaa,
140 bool supports_ssbo,
141 bool supports_texture_to_texture_blits,
142 bool supports_framebuffer_fetch,
143 bool supports_compute,
144 bool supports_compute_subgroups,
145 bool supports_read_from_resolve,
146 bool supports_decal_sampler_address_mode,
147 bool supports_device_transient_textures,
148 bool supports_triangle_fan,
149 bool supports_extended_range_formats,
150 PixelFormat default_color_format,
151 PixelFormat default_stencil_format,
152 PixelFormat default_depth_stencil_format,
153 PixelFormat default_glyph_atlas_format,
154 ISize default_maximum_render_pass_attachment_size,
155 size_t minimum_uniform_alignment,
156 bool needs_partitioned_host_buffer,
157 bool supports_texture_compression_bc,
158 bool supports_texture_compression_etc2,
159 bool supports_texture_compression_astc,
160 bool supports_texture_compression_astc_hdr)
161 : supports_offscreen_msaa_(supports_offscreen_msaa),
162 supports_ssbo_(supports_ssbo),
163 supports_texture_to_texture_blits_(supports_texture_to_texture_blits),
164 supports_framebuffer_fetch_(supports_framebuffer_fetch),
165 supports_compute_(supports_compute),
166 supports_compute_subgroups_(supports_compute_subgroups),
167 supports_read_from_resolve_(supports_read_from_resolve),
168 supports_decal_sampler_address_mode_(
169 supports_decal_sampler_address_mode),
170 supports_device_transient_textures_(supports_device_transient_textures),
171 supports_triangle_fan_(supports_triangle_fan),
172 supports_extended_range_formats_(supports_extended_range_formats),
173 needs_partitioned_host_buffer_(needs_partitioned_host_buffer),
174 default_color_format_(default_color_format),
175 default_stencil_format_(default_stencil_format),
176 default_depth_stencil_format_(default_depth_stencil_format),
177 default_glyph_atlas_format_(default_glyph_atlas_format),
178 default_maximum_render_pass_attachment_size_(
179 default_maximum_render_pass_attachment_size),
180 minimum_uniform_alignment_(minimum_uniform_alignment),
181 supports_texture_compression_bc_(supports_texture_compression_bc),
182 supports_texture_compression_etc2_(supports_texture_compression_etc2),
183 supports_texture_compression_astc_(supports_texture_compression_astc),
184 supports_texture_compression_astc_hdr_(
185 supports_texture_compression_astc_hdr) {}
186
188
189 bool supports_offscreen_msaa_ = false;
190 bool supports_ssbo_ = false;
191 bool supports_texture_to_texture_blits_ = false;
192 bool supports_framebuffer_fetch_ = false;
193 bool supports_compute_ = false;
194 bool supports_compute_subgroups_ = false;
195 bool supports_read_from_resolve_ = false;
196 bool supports_decal_sampler_address_mode_ = false;
197 bool supports_device_transient_textures_ = false;
198 bool supports_triangle_fan_ = false;
199 bool supports_extended_range_formats_ = false;
200 bool needs_partitioned_host_buffer_ = false;
201 PixelFormat default_color_format_ = PixelFormat::kUnknown;
202 PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
203 PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
204 PixelFormat default_glyph_atlas_format_ = PixelFormat::kUnknown;
205 ISize default_maximum_render_pass_attachment_size_ = ISize(1, 1);
206 size_t minimum_uniform_alignment_ = 256;
207 bool supports_texture_compression_bc_ = false;
208 bool supports_texture_compression_etc2_ = false;
209 bool supports_texture_compression_astc_ = false;
210 bool supports_texture_compression_astc_hdr_ = false;
211
213
214 StandardCapabilities& operator=(const StandardCapabilities&) = delete;
215};
216
218
220
222 supports_offscreen_msaa_ = value;
223 return *this;
224}
225
227 supports_ssbo_ = value;
228 return *this;
229}
230
232 bool value) {
233 supports_texture_to_texture_blits_ = value;
234 return *this;
235}
236
238 bool value) {
239 supports_framebuffer_fetch_ = value;
240 return *this;
241}
242
244 supports_compute_ = value;
245 return *this;
246}
247
249 bool value) {
250 supports_compute_subgroups_ = value;
251 return *this;
252}
253
255 PixelFormat value) {
256 default_color_format_ = value;
257 return *this;
258}
259
261 PixelFormat value) {
262 default_stencil_format_ = value;
263 return *this;
264}
265
267 PixelFormat value) {
268 default_depth_stencil_format_ = value;
269 return *this;
270}
271
273 bool read_from_resolve) {
274 supports_read_from_resolve_ = read_from_resolve;
275 return *this;
276}
277
279 bool value) {
280 supports_decal_sampler_address_mode_ = value;
281 return *this;
282}
283
285 bool value) {
286 supports_device_transient_textures_ = value;
287 return *this;
288}
289
291 PixelFormat value) {
292 default_glyph_atlas_format_ = value;
293 return *this;
294}
295
297 supports_triangle_fan_ = value;
298 return *this;
299}
300
302 ISize size) {
303 default_maximum_render_pass_attachment_size_ = size;
304 return *this;
305}
306
308 bool value) {
309 supports_extended_range_formats_ = value;
310 return *this;
311}
312
315 bool value) {
316 switch (family) {
318 supports_texture_compression_bc_ = value;
319 break;
321 supports_texture_compression_etc2_ = value;
322 break;
324 supports_texture_compression_astc_ = value;
325 break;
327 supports_texture_compression_astc_hdr_ = value;
328 break;
329 }
330 return *this;
331}
332
334 size_t value) {
335 minimum_uniform_alignment_ = value;
336 return *this;
337}
338
340 bool value) {
341 needs_partitioned_host_buffer_ = value;
342 return *this;
343}
344
345std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
346 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
347 return std::unique_ptr<StandardCapabilities>(new StandardCapabilities( //
348 supports_offscreen_msaa_, //
349 supports_ssbo_, //
350 supports_texture_to_texture_blits_, //
351 supports_framebuffer_fetch_, //
352 supports_compute_, //
353 supports_compute_subgroups_, //
354 supports_read_from_resolve_, //
355 supports_decal_sampler_address_mode_, //
356 supports_device_transient_textures_, //
357 supports_triangle_fan_, //
358 supports_extended_range_formats_, //
359 default_color_format_.value_or(PixelFormat::kUnknown), //
360 default_stencil_format_.value_or(PixelFormat::kUnknown), //
361 default_depth_stencil_format_.value_or(PixelFormat::kUnknown), //
362 default_glyph_atlas_format_.value_or(PixelFormat::kUnknown), //
363 default_maximum_render_pass_attachment_size_.value_or(ISize{1, 1}), //
364 minimum_uniform_alignment_, //
365 needs_partitioned_host_buffer_, //
366 supports_texture_compression_bc_, //
367 supports_texture_compression_etc2_, //
368 supports_texture_compression_astc_, //
369 supports_texture_compression_astc_hdr_ //
370 ));
371}
372
373} // 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 & 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...
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