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