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 
7 
8 namespace impeller {
9 
10 Capabilities::Capabilities() = default;
11 
12 Capabilities::~Capabilities() = default;
13 
14 class StandardCapabilities final : public Capabilities {
15  public:
16  // |Capabilities|
17  ~StandardCapabilities() override = default;
18 
19  // |Capabilities|
20  bool SupportsOffscreenMSAA() const override {
21  return supports_offscreen_msaa_;
22  }
23 
24  // |Capabilities|
25  bool SupportsImplicitResolvingMSAA() const override { return false; }
26 
27  // |Capabilities|
28  bool SupportsSSBO() const override { return supports_ssbo_; }
29 
30  // |Capabilities|
31  bool SupportsTextureToTextureBlits() const override {
32  return supports_texture_to_texture_blits_;
33  }
34 
35  // |Capabilities|
36  bool SupportsFramebufferFetch() const override {
37  return supports_framebuffer_fetch_;
38  }
39 
40  // |Capabilities|
41  bool SupportsCompute() const override { return supports_compute_; }
42 
43  // |Capabilities|
44  bool SupportsComputeSubgroups() const override {
45  return supports_compute_subgroups_;
46  }
47 
48  // |Capabilities|
49  bool SupportsReadFromResolve() const override {
50  return supports_read_from_resolve_;
51  }
52 
53  // |Capabilities|
54  bool SupportsDecalSamplerAddressMode() const override {
55  return supports_decal_sampler_address_mode_;
56  }
57 
58  // |Capabilities|
59  bool SupportsTriangleFan() const override { return supports_triangle_fan_; }
60 
61  // |Capabilities|
63  return default_color_format_;
64  }
65 
66  // |Capabilities|
68  return default_stencil_format_;
69  }
70 
71  // |Capabilities|
73  return default_depth_stencil_format_;
74  }
75 
76  // |Capabilities|
77  bool SupportsDeviceTransientTextures() const override {
78  return supports_device_transient_textures_;
79  }
80 
81  // |Capabilities|
83  return default_glyph_atlas_format_;
84  }
85 
86  // |Capabilities|
88  return default_maximum_render_pass_attachment_size_;
89  }
90 
91  // |Capabilities|
92  bool SupportsPrimitiveRestart() const override { return true; }
93 
94  // |Capabilities|
95  bool SupportsExtendedRangeFormats() const override {
96  return supports_extended_range_formats_;
97  }
98 
99  private:
100  StandardCapabilities(bool supports_offscreen_msaa,
101  bool supports_ssbo,
102  bool supports_texture_to_texture_blits,
103  bool supports_framebuffer_fetch,
104  bool supports_compute,
105  bool supports_compute_subgroups,
106  bool supports_read_from_resolve,
107  bool supports_decal_sampler_address_mode,
108  bool supports_device_transient_textures,
109  bool supports_triangle_fan,
110  bool supports_extended_range_formats,
111  PixelFormat default_color_format,
112  PixelFormat default_stencil_format,
113  PixelFormat default_depth_stencil_format,
114  PixelFormat default_glyph_atlas_format,
115  ISize default_maximum_render_pass_attachment_size)
116  : supports_offscreen_msaa_(supports_offscreen_msaa),
117  supports_ssbo_(supports_ssbo),
118  supports_texture_to_texture_blits_(supports_texture_to_texture_blits),
119  supports_framebuffer_fetch_(supports_framebuffer_fetch),
120  supports_compute_(supports_compute),
121  supports_compute_subgroups_(supports_compute_subgroups),
122  supports_read_from_resolve_(supports_read_from_resolve),
123  supports_decal_sampler_address_mode_(
124  supports_decal_sampler_address_mode),
125  supports_device_transient_textures_(supports_device_transient_textures),
126  supports_triangle_fan_(supports_triangle_fan),
127  supports_extended_range_formats_(supports_extended_range_formats),
128  default_color_format_(default_color_format),
129  default_stencil_format_(default_stencil_format),
130  default_depth_stencil_format_(default_depth_stencil_format),
131  default_glyph_atlas_format_(default_glyph_atlas_format),
132  default_maximum_render_pass_attachment_size_(
133  default_maximum_render_pass_attachment_size) {}
134 
135  friend class CapabilitiesBuilder;
136 
137  bool supports_offscreen_msaa_ = false;
138  bool supports_ssbo_ = false;
139  bool supports_texture_to_texture_blits_ = false;
140  bool supports_framebuffer_fetch_ = false;
141  bool supports_compute_ = false;
142  bool supports_compute_subgroups_ = false;
143  bool supports_read_from_resolve_ = false;
144  bool supports_decal_sampler_address_mode_ = false;
145  bool supports_device_transient_textures_ = false;
146  bool supports_triangle_fan_ = false;
147  bool supports_extended_range_formats_ = false;
148  PixelFormat default_color_format_ = PixelFormat::kUnknown;
149  PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
150  PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
151  PixelFormat default_glyph_atlas_format_ = PixelFormat::kUnknown;
152  ISize default_maximum_render_pass_attachment_size_ = ISize(1, 1);
153 
155 
156  StandardCapabilities& operator=(const StandardCapabilities&) = delete;
157 };
158 
160 
162 
164  supports_offscreen_msaa_ = value;
165  return *this;
166 }
167 
169  supports_ssbo_ = value;
170  return *this;
171 }
172 
174  bool value) {
175  supports_texture_to_texture_blits_ = value;
176  return *this;
177 }
178 
180  bool value) {
181  supports_framebuffer_fetch_ = value;
182  return *this;
183 }
184 
186  supports_compute_ = value;
187  return *this;
188 }
189 
191  bool value) {
192  supports_compute_subgroups_ = value;
193  return *this;
194 }
195 
197  PixelFormat value) {
198  default_color_format_ = value;
199  return *this;
200 }
201 
203  PixelFormat value) {
204  default_stencil_format_ = value;
205  return *this;
206 }
207 
209  PixelFormat value) {
210  default_depth_stencil_format_ = value;
211  return *this;
212 }
213 
215  bool read_from_resolve) {
216  supports_read_from_resolve_ = read_from_resolve;
217  return *this;
218 }
219 
221  bool value) {
222  supports_decal_sampler_address_mode_ = value;
223  return *this;
224 }
225 
227  bool value) {
228  supports_device_transient_textures_ = value;
229  return *this;
230 }
231 
233  PixelFormat value) {
234  default_glyph_atlas_format_ = value;
235  return *this;
236 }
237 
239  supports_triangle_fan_ = value;
240  return *this;
241 }
242 
244  ISize size) {
245  default_maximum_render_pass_attachment_size_ = size;
246  return *this;
247 }
248 
250  bool value) {
251  supports_extended_range_formats_ = value;
252  return *this;
253 }
254 
255 std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
256  // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
257  return std::unique_ptr<StandardCapabilities>(new StandardCapabilities( //
258  supports_offscreen_msaa_, //
259  supports_ssbo_, //
260  supports_texture_to_texture_blits_, //
261  supports_framebuffer_fetch_, //
262  supports_compute_, //
263  supports_compute_subgroups_, //
264  supports_read_from_resolve_, //
265  supports_decal_sampler_address_mode_, //
266  supports_device_transient_textures_, //
267  supports_triangle_fan_, //
268  supports_extended_range_formats_, //
269  default_color_format_.value_or(PixelFormat::kUnknown), //
270  default_stencil_format_.value_or(PixelFormat::kUnknown), //
271  default_depth_stencil_format_.value_or(PixelFormat::kUnknown), //
272  default_glyph_atlas_format_.value_or(PixelFormat::kUnknown), //
273  default_maximum_render_pass_attachment_size_.value_or(ISize{1, 1}) //
274  ));
275 }
276 
277 } // namespace impeller
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
CapabilitiesBuilder & SetSupportsComputeSubgroups(bool value)
CapabilitiesBuilder & SetSupportsTextureToTextureBlits(bool value)
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
CapabilitiesBuilder & SetSupportsDeviceTransientTextures(bool value)
CapabilitiesBuilder & SetSupportsTriangleFan(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)
~StandardCapabilities() override=default
bool SupportsReadFromResolve() const override
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
Definition: capabilities.cc:49
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
Definition: capabilities.cc:72
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
Definition: capabilities.cc:44
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
Definition: capabilities.cc:20
ISize GetMaximumRenderPassAttachmentSize() const override
Return the maximum size of a render pass attachment.
Definition: capabilities.cc:87
bool SupportsTextureToTextureBlits() const override
Whether the context backend supports blitting from one texture region to another texture region (via ...
Definition: capabilities.cc:31
bool SupportsFramebufferFetch() const override
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
Definition: capabilities.cc:36
PixelFormat GetDefaultGlyphAtlasFormat() const override
Returns the default pixel format for the alpha bitmap glyph atlas.
Definition: capabilities.cc:82
PixelFormat GetDefaultStencilFormat() const override
Returns a supported PixelFormat for textures that store stencil information. May include a depth chan...
Definition: capabilities.cc:67
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
Definition: capabilities.cc:41
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
Definition: capabilities.cc:28
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
Definition: capabilities.cc:77
bool SupportsImplicitResolvingMSAA() const override
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
Definition: capabilities.cc:25
bool SupportsPrimitiveRestart() const override
Whether primitive restart is supported.
Definition: capabilities.cc:92
PixelFormat GetDefaultColorFormat() const override
Returns a supported PixelFormat for textures that store 4-channel colors (red/green/blue/alpha).
Definition: capabilities.cc:62
bool SupportsExtendedRangeFormats() const override
Whether the XR formats are supported on this device.
Definition: capabilities.cc:95
bool SupportsTriangleFan() const override
Whether the primitive type TriangleFan is supported by the backend.
Definition: capabilities.cc:59
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
Definition: capabilities.cc:54
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