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 
6 
7 namespace impeller {
8 
10 
11 Capabilities::~Capabilities() = default;
12 
13 class StandardCapabilities final : public Capabilities {
14  public:
15  // |Capabilities|
16  ~StandardCapabilities() override = default;
17 
18  // |Capabilities|
19  bool SupportsOffscreenMSAA() const override {
20  return supports_offscreen_msaa_;
21  }
22 
23  // |Capabilities|
24  bool SupportsSSBO() const override { return supports_ssbo_; }
25 
26  // |Capabilities|
27  bool SupportsBufferToTextureBlits() const override {
28  return supports_buffer_to_texture_blits_;
29  }
30 
31  // |Capabilities|
32  bool SupportsTextureToTextureBlits() const override {
33  return supports_texture_to_texture_blits_;
34  }
35 
36  // |Capabilities|
37  bool SupportsFramebufferFetch() const override {
38  return supports_framebuffer_fetch_;
39  }
40 
41  // |Capabilities|
42  bool SupportsCompute() const override { return supports_compute_; }
43 
44  // |Capabilities|
45  bool SupportsComputeSubgroups() const override {
46  return supports_compute_subgroups_;
47  }
48 
49  // |Capabilities|
50  bool SupportsReadFromOnscreenTexture() const override {
51  return supports_read_from_onscreen_texture_;
52  }
53 
54  // |Capabilities|
55  bool SupportsReadFromResolve() const override {
56  return supports_read_from_resolve_;
57  }
58 
59  // |Capabilities|
60  bool SupportsDecalSamplerAddressMode() const override {
61  return supports_decal_sampler_address_mode_;
62  }
63 
64  // |Capabilities|
66  return default_color_format_;
67  }
68 
69  // |Capabilities|
71  return default_stencil_format_;
72  }
73 
74  // |Capabilities|
76  return default_depth_stencil_format_;
77  }
78 
79  bool SupportsDeviceTransientTextures() const override {
80  return supports_device_transient_textures_;
81  }
82 
83  private:
84  StandardCapabilities(bool supports_offscreen_msaa,
85  bool supports_ssbo,
86  bool supports_buffer_to_texture_blits,
87  bool supports_texture_to_texture_blits,
88  bool supports_framebuffer_fetch,
89  bool supports_compute,
90  bool supports_compute_subgroups,
91  bool supports_read_from_onscreen_texture,
92  bool supports_read_from_resolve,
93  bool supports_decal_sampler_address_mode,
94  bool supports_device_transient_textures,
95  PixelFormat default_color_format,
96  PixelFormat default_stencil_format,
97  PixelFormat default_depth_stencil_format)
98  : supports_offscreen_msaa_(supports_offscreen_msaa),
99  supports_ssbo_(supports_ssbo),
100  supports_buffer_to_texture_blits_(supports_buffer_to_texture_blits),
101  supports_texture_to_texture_blits_(supports_texture_to_texture_blits),
102  supports_framebuffer_fetch_(supports_framebuffer_fetch),
103  supports_compute_(supports_compute),
104  supports_compute_subgroups_(supports_compute_subgroups),
105  supports_read_from_onscreen_texture_(
106  supports_read_from_onscreen_texture),
107  supports_read_from_resolve_(supports_read_from_resolve),
108  supports_decal_sampler_address_mode_(
109  supports_decal_sampler_address_mode),
110  supports_device_transient_textures_(supports_device_transient_textures),
111  default_color_format_(default_color_format),
112  default_stencil_format_(default_stencil_format),
113  default_depth_stencil_format_(default_depth_stencil_format) {}
114 
115  friend class CapabilitiesBuilder;
116 
117  bool supports_offscreen_msaa_ = false;
118  bool supports_ssbo_ = false;
119  bool supports_buffer_to_texture_blits_ = false;
120  bool supports_texture_to_texture_blits_ = false;
121  bool supports_framebuffer_fetch_ = false;
122  bool supports_compute_ = false;
123  bool supports_compute_subgroups_ = false;
124  bool supports_read_from_onscreen_texture_ = false;
125  bool supports_read_from_resolve_ = false;
126  bool supports_decal_sampler_address_mode_ = false;
127  bool supports_device_transient_textures_ = false;
128  PixelFormat default_color_format_ = PixelFormat::kUnknown;
129  PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
130  PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
131 
132  FML_DISALLOW_COPY_AND_ASSIGN(StandardCapabilities);
133 };
134 
136 
138 
140  supports_offscreen_msaa_ = value;
141  return *this;
142 }
143 
145  supports_ssbo_ = value;
146  return *this;
147 }
148 
150  bool value) {
151  supports_buffer_to_texture_blits_ = value;
152  return *this;
153 }
154 
156  bool value) {
157  supports_texture_to_texture_blits_ = value;
158  return *this;
159 }
160 
162  bool value) {
163  supports_framebuffer_fetch_ = value;
164  return *this;
165 }
166 
168  supports_compute_ = value;
169  return *this;
170 }
171 
173  bool value) {
174  supports_compute_subgroups_ = value;
175  return *this;
176 }
177 
179  bool read_from_onscreen_texture) {
180  supports_read_from_onscreen_texture_ = read_from_onscreen_texture;
181  return *this;
182 }
183 
185  bool read_from_resolve) {
186  supports_read_from_resolve_ = read_from_resolve;
187  return *this;
188 }
189 
191  PixelFormat value) {
192  default_color_format_ = value;
193  return *this;
194 }
195 
197  PixelFormat value) {
198  default_stencil_format_ = value;
199  return *this;
200 }
201 
203  PixelFormat value) {
204  default_depth_stencil_format_ = value;
205  return *this;
206 }
207 
209  bool value) {
210  supports_decal_sampler_address_mode_ = value;
211  return *this;
212 }
213 
215  bool value) {
216  supports_device_transient_textures_ = value;
217  return *this;
218 }
219 
220 std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
221  return std::unique_ptr<StandardCapabilities>(new StandardCapabilities( //
222  supports_offscreen_msaa_, //
223  supports_ssbo_, //
224  supports_buffer_to_texture_blits_, //
225  supports_texture_to_texture_blits_, //
226  supports_framebuffer_fetch_, //
227  supports_compute_, //
228  supports_compute_subgroups_, //
229  supports_read_from_onscreen_texture_, //
230  supports_read_from_resolve_, //
231  supports_decal_sampler_address_mode_, //
232  supports_device_transient_textures_, //
233  default_color_format_.value_or(PixelFormat::kUnknown), //
234  default_stencil_format_.value_or(PixelFormat::kUnknown), //
235  default_depth_stencil_format_.value_or(PixelFormat::kUnknown) //
236  ));
237 }
238 
239 } // namespace impeller
impeller::CapabilitiesBuilder::CapabilitiesBuilder
CapabilitiesBuilder()
impeller::StandardCapabilities::SupportsComputeSubgroups
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
Definition: capabilities.cc:45
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:32
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:37
impeller::StandardCapabilities::SupportsCompute
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
Definition: capabilities.cc:42
impeller::CapabilitiesBuilder::Build
std::unique_ptr< Capabilities > Build()
Definition: capabilities.cc:220
impeller::StandardCapabilities::SupportsReadFromOnscreenTexture
bool SupportsReadFromOnscreenTexture() const override
Whether the context backend supports binding the on-screen surface texture for shader reading.
Definition: capabilities.cc:50
impeller::StandardCapabilities::~StandardCapabilities
~StandardCapabilities() override=default
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:70
impeller::CapabilitiesBuilder
Definition: capabilities.h:112
impeller::StandardCapabilities::SupportsReadFromResolve
bool SupportsReadFromResolve() const override
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
Definition: capabilities.cc:55
impeller::StandardCapabilities::SupportsSSBO
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
Definition: capabilities.cc:24
impeller::Capabilities
Definition: capabilities.h:14
impeller::CapabilitiesBuilder::SetSupportsSSBO
CapabilitiesBuilder & SetSupportsSSBO(bool value)
Definition: capabilities.cc:144
impeller::CapabilitiesBuilder::SetSupportsCompute
CapabilitiesBuilder & SetSupportsCompute(bool value)
Definition: capabilities.cc:167
impeller::CapabilitiesBuilder::SetDefaultDepthStencilFormat
CapabilitiesBuilder & SetDefaultDepthStencilFormat(PixelFormat value)
Definition: capabilities.cc:202
impeller::StandardCapabilities
Definition: capabilities.cc:13
impeller::StandardCapabilities::SupportsBufferToTextureBlits
bool SupportsBufferToTextureBlits() const override
Whether the context backend supports blitting from a given DeviceBuffer view to a texture region (via...
Definition: capabilities.cc:27
impeller::CapabilitiesBuilder::SetSupportsFramebufferFetch
CapabilitiesBuilder & SetSupportsFramebufferFetch(bool value)
Definition: capabilities.cc:161
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:65
impeller::CapabilitiesBuilder::~CapabilitiesBuilder
~CapabilitiesBuilder()
impeller::CapabilitiesBuilder::SetSupportsComputeSubgroups
CapabilitiesBuilder & SetSupportsComputeSubgroups(bool value)
Definition: capabilities.cc:172
capabilities.h
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::Capabilities::Capabilities
Capabilities()
impeller::StandardCapabilities::SupportsDecalSamplerAddressMode
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
Definition: capabilities.cc:60
impeller::CapabilitiesBuilder::SetSupportsTextureToTextureBlits
CapabilitiesBuilder & SetSupportsTextureToTextureBlits(bool value)
Definition: capabilities.cc:155
impeller::StandardCapabilities::SupportsOffscreenMSAA
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
Definition: capabilities.cc:19
impeller::StandardCapabilities::SupportsDeviceTransientTextures
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
Definition: capabilities.cc:79
impeller::StandardCapabilities::GetDefaultDepthStencilFormat
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
Definition: capabilities.cc:75
impeller::CapabilitiesBuilder::SetDefaultColorFormat
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
Definition: capabilities.cc:190
impeller::CapabilitiesBuilder::SetDefaultStencilFormat
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
Definition: capabilities.cc:196
impeller::CapabilitiesBuilder::SetSupportsBufferToTextureBlits
CapabilitiesBuilder & SetSupportsBufferToTextureBlits(bool value)
Definition: capabilities.cc:149
impeller::Capabilities::~Capabilities
virtual ~Capabilities()
impeller::CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode
CapabilitiesBuilder & SetSupportsDecalSamplerAddressMode(bool value)
Definition: capabilities.cc:208
impeller::CapabilitiesBuilder::SetSupportsDeviceTransientTextures
CapabilitiesBuilder & SetSupportsDeviceTransientTextures(bool value)
Definition: capabilities.cc:214
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:94
impeller::CapabilitiesBuilder::SetSupportsReadFromOnscreenTexture
CapabilitiesBuilder & SetSupportsReadFromOnscreenTexture(bool value)
Definition: capabilities.cc:178
impeller
Definition: aiks_context.cc:10
impeller::CapabilitiesBuilder::SetSupportsReadFromResolve
CapabilitiesBuilder & SetSupportsReadFromResolve(bool value)
Definition: capabilities.cc:184
impeller::CapabilitiesBuilder::SetSupportsOffscreenMSAA
CapabilitiesBuilder & SetSupportsOffscreenMSAA(bool value)
Definition: capabilities.cc:139