Flutter Engine
 
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 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
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
175
176 StandardCapabilities& operator=(const StandardCapabilities&) = delete;
177};
178
180
182
184 supports_offscreen_msaa_ = value;
185 return *this;
186}
187
189 supports_ssbo_ = value;
190 return *this;
191}
192
194 bool value) {
195 supports_texture_to_texture_blits_ = value;
196 return *this;
197}
198
200 bool value) {
201 supports_framebuffer_fetch_ = value;
202 return *this;
203}
204
206 supports_compute_ = value;
207 return *this;
208}
209
211 bool value) {
212 supports_compute_subgroups_ = value;
213 return *this;
214}
215
217 PixelFormat value) {
218 default_color_format_ = value;
219 return *this;
220}
221
223 PixelFormat value) {
224 default_stencil_format_ = value;
225 return *this;
226}
227
229 PixelFormat value) {
230 default_depth_stencil_format_ = value;
231 return *this;
232}
233
235 bool read_from_resolve) {
236 supports_read_from_resolve_ = read_from_resolve;
237 return *this;
238}
239
241 bool value) {
242 supports_decal_sampler_address_mode_ = value;
243 return *this;
244}
245
247 bool value) {
248 supports_device_transient_textures_ = value;
249 return *this;
250}
251
253 PixelFormat value) {
254 default_glyph_atlas_format_ = value;
255 return *this;
256}
257
259 supports_triangle_fan_ = value;
260 return *this;
261}
262
264 ISize size) {
265 default_maximum_render_pass_attachment_size_ = size;
266 return *this;
267}
268
270 bool value) {
271 supports_extended_range_formats_ = value;
272 return *this;
273}
274
276 size_t value) {
277 minimum_uniform_alignment_ = value;
278 return *this;
279}
280
282 bool value) {
283 needs_partitioned_host_buffer_ = value;
284 return *this;
285}
286
287std::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
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 & 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 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 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 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 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
ISize64 ISize
Definition size.h:162