| 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 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|
62 PixelFormat GetDefaultColorFormat() const override {
63 return default_color_format_;
64 }
65
66 // |Capabilities|
67 PixelFormat GetDefaultStencilFormat() const override {
68 return default_stencil_format_;
69 }
70
71 // |Capabilities|
72 PixelFormat GetDefaultDepthStencilFormat() const override {
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|
82 PixelFormat GetDefaultGlyphAtlasFormat() const override {
83 return default_glyph_atlas_format_;
84 }
85
86 // |Capabilities|
87 ISize GetMaximumRenderPassAttachmentSize() const override {
88 return default_maximum_render_pass_attachment_size_;
89 }
90
91 private:
92 StandardCapabilities(bool supports_offscreen_msaa,
93 bool supports_ssbo,
94 bool supports_texture_to_texture_blits,
95 bool supports_framebuffer_fetch,
96 bool supports_compute,
97 bool supports_compute_subgroups,
98 bool supports_read_from_resolve,
99 bool supports_decal_sampler_address_mode,
100 bool supports_device_transient_textures,
101 bool supports_triangle_fan,
102 PixelFormat default_color_format,
103 PixelFormat default_stencil_format,
104 PixelFormat default_depth_stencil_format,
105 PixelFormat default_glyph_atlas_format,
106 ISize default_maximum_render_pass_attachment_size)
107 : supports_offscreen_msaa_(supports_offscreen_msaa),
108 supports_ssbo_(supports_ssbo),
109 supports_texture_to_texture_blits_(supports_texture_to_texture_blits),
110 supports_framebuffer_fetch_(supports_framebuffer_fetch),
111 supports_compute_(supports_compute),
112 supports_compute_subgroups_(supports_compute_subgroups),
113 supports_read_from_resolve_(supports_read_from_resolve),
114 supports_decal_sampler_address_mode_(
115 supports_decal_sampler_address_mode),
116 supports_device_transient_textures_(supports_device_transient_textures),
117 supports_triangle_fan_(supports_triangle_fan),
118 default_color_format_(default_color_format),
119 default_stencil_format_(default_stencil_format),
120 default_depth_stencil_format_(default_depth_stencil_format),
121 default_glyph_atlas_format_(default_glyph_atlas_format),
122 default_maximum_render_pass_attachment_size_(
123 default_maximum_render_pass_attachment_size) {}
124
125 friend class CapabilitiesBuilder;
126
127 bool supports_offscreen_msaa_ = false;
128 bool supports_ssbo_ = false;
129 bool supports_texture_to_texture_blits_ = false;
130 bool supports_framebuffer_fetch_ = false;
131 bool supports_compute_ = false;
132 bool supports_compute_subgroups_ = false;
133 bool supports_read_from_resolve_ = false;
134 bool supports_decal_sampler_address_mode_ = false;
135 bool supports_device_transient_textures_ = false;
136 bool supports_triangle_fan_ = false;
137 PixelFormat default_color_format_ = PixelFormat::kUnknown;
138 PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
139 PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
140 PixelFormat default_glyph_atlas_format_ = PixelFormat::kUnknown;
141 ISize default_maximum_render_pass_attachment_size_ = ISize(1, 1);
142
143 StandardCapabilities(const StandardCapabilities&) = delete;
144
145 StandardCapabilities& operator=(const StandardCapabilities&) = delete;
146 };
147
148 CapabilitiesBuilder::CapabilitiesBuilder() = default;
149
150 CapabilitiesBuilder::~CapabilitiesBuilder() = default;
151
152 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsOffscreenMSAA(bool value) {
153 supports_offscreen_msaa_ = value;
154 return *this;
155 }
156
157 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsSSBO(bool value) {
158 supports_ssbo_ = value;
159 return *this;
160 }
161
162 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsTextureToTextureBlits(
163 bool value) {
164 supports_texture_to_texture_blits_ = value;
165 return *this;
166 }
167
168 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsFramebufferFetch(
169 bool value) {
170 supports_framebuffer_fetch_ = value;
171 return *this;
172 }
173
174 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsCompute(bool value) {
175 supports_compute_ = value;
176 return *this;
177 }
178
179 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsComputeSubgroups(
180 bool value) {
181 supports_compute_subgroups_ = value;
182 return *this;
183 }
184
185 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultColorFormat(
186 PixelFormat value) {
187 default_color_format_ = value;
188 return *this;
189 }
190
191 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultStencilFormat(
192 PixelFormat value) {
193 default_stencil_format_ = value;
194 return *this;
195 }
196
197 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultDepthStencilFormat(
198 PixelFormat value) {
199 default_depth_stencil_format_ = value;
200 return *this;
201 }
202
203 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsReadFromResolve(
204 bool read_from_resolve) {
205 supports_read_from_resolve_ = read_from_resolve;
206 return *this;
207 }
208
209 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode(
210 bool value) {
211 supports_decal_sampler_address_mode_ = value;
212 return *this;
213 }
214
215 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDeviceTransientTextures(
216 bool value) {
217 supports_device_transient_textures_ = value;
218 return *this;
219 }
220
221 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultGlyphAtlasFormat(
222 PixelFormat value) {
223 default_glyph_atlas_format_ = value;
224 return *this;
225 }
226
227 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsTriangleFan(bool value) {
228 supports_triangle_fan_ = value;
229 return *this;
230 }
231
232 CapabilitiesBuilder& CapabilitiesBuilder::SetMaximumRenderPassAttachmentSize(
233 ISize size) {
234 default_maximum_render_pass_attachment_size_ = size;
235 return *this;
236 }
237
238 std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
239 return std::unique_ptr<StandardCapabilities>(new StandardCapabilities( //
240 supports_offscreen_msaa_, //
241 supports_ssbo_, //
242 supports_texture_to_texture_blits_, //
243 supports_framebuffer_fetch_, //
244 supports_compute_, //
245 supports_compute_subgroups_, //
246 supports_read_from_resolve_, //
247 supports_decal_sampler_address_mode_, //
248 supports_device_transient_textures_, //
249 supports_triangle_fan_, //
250 default_color_format_.value_or(PixelFormat::kUnknown), //
251 default_stencil_format_.value_or(PixelFormat::kUnknown), //
252 default_depth_stencil_format_.value_or(PixelFormat::kUnknown), //
253 default_glyph_atlas_format_.value_or(PixelFormat::kUnknown), //
254 default_maximum_render_pass_attachment_size_.value_or(ISize{1, 1}) //
255 ));
256 }
257
258 } // 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:44
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:31
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:36
impeller::ISize
ISize64 ISize
Definition: size.h:140
impeller::StandardCapabilities::SupportsCompute
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
Definition: capabilities.cc:41
impeller::CapabilitiesBuilder::Build
std::unique_ptr< Capabilities > Build()
Definition: capabilities.cc:238
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:67
impeller::CapabilitiesBuilder
Definition: capabilities.h:124
formats.h
impeller::CapabilitiesBuilder::SetSupportsTriangleFan
CapabilitiesBuilder & SetSupportsTriangleFan(bool value)
Definition: capabilities.cc:227
impeller::StandardCapabilities::SupportsReadFromResolve
bool SupportsReadFromResolve() const override
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
Definition: capabilities.cc:49
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:99
impeller::Capabilities
Definition: capabilities.h:14
impeller::TSize
Definition: size.h:19
impeller::CapabilitiesBuilder::SetSupportsSSBO
CapabilitiesBuilder & SetSupportsSSBO(bool value)
Definition: capabilities.cc:157
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:174
impeller::CapabilitiesBuilder::SetDefaultDepthStencilFormat
CapabilitiesBuilder & SetDefaultDepthStencilFormat(PixelFormat value)
Definition: capabilities.cc:197
impeller::CapabilitiesBuilder::SetMaximumRenderPassAttachmentSize
CapabilitiesBuilder & SetMaximumRenderPassAttachmentSize(ISize size)
Definition: capabilities.cc:232
impeller::CapabilitiesBuilder::SetDefaultGlyphAtlasFormat
CapabilitiesBuilder & SetDefaultGlyphAtlasFormat(PixelFormat value)
Definition: capabilities.cc:221
impeller::StandardCapabilities
Definition: capabilities.cc:14
impeller::CapabilitiesBuilder::SetSupportsFramebufferFetch
CapabilitiesBuilder & SetSupportsFramebufferFetch(bool value)
Definition: capabilities.cc:168
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:62
impeller::CapabilitiesBuilder::~CapabilitiesBuilder
~CapabilitiesBuilder()
impeller::StandardCapabilities::SupportsTriangleFan
bool SupportsTriangleFan() const override
Whether the primitive type TriangleFan is supported by the backend.
Definition: capabilities.cc:59
impeller::CapabilitiesBuilder::SetSupportsComputeSubgroups
CapabilitiesBuilder & SetSupportsComputeSubgroups(bool value)
Definition: capabilities.cc:179
impeller::StandardCapabilities::GetMaximumRenderPassAttachmentSize
ISize GetMaximumRenderPassAttachmentSize() const override
Return the maximum size of a render pass attachment.
Definition: capabilities.cc:87
capabilities.h
impeller::Capabilities::Capabilities
Capabilities()
impeller::StandardCapabilities::SupportsDecalSamplerAddressMode
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
Definition: capabilities.cc:54
impeller::CapabilitiesBuilder::SetSupportsTextureToTextureBlits
CapabilitiesBuilder & SetSupportsTextureToTextureBlits(bool value)
Definition: capabilities.cc:162
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:77
impeller::StandardCapabilities::GetDefaultDepthStencilFormat
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
Definition: capabilities.cc:72
impeller::CapabilitiesBuilder::SetDefaultColorFormat
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
Definition: capabilities.cc:185
impeller::CapabilitiesBuilder::SetDefaultStencilFormat
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
Definition: capabilities.cc:191
impeller::StandardCapabilities::GetDefaultGlyphAtlasFormat
PixelFormat GetDefaultGlyphAtlasFormat() const override
Returns the default pixel format for the alpha bitmap glyph atlas.
Definition: capabilities.cc:82
impeller::Capabilities::~Capabilities
virtual ~Capabilities()
impeller::CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode
CapabilitiesBuilder & SetSupportsDecalSamplerAddressMode(bool value)
Definition: capabilities.cc:209
impeller::CapabilitiesBuilder::SetSupportsDeviceTransientTextures
CapabilitiesBuilder & SetSupportsDeviceTransientTextures(bool value)
Definition: capabilities.cc:215
impeller
Definition: allocation.cc:12
impeller::CapabilitiesBuilder::SetSupportsReadFromResolve
CapabilitiesBuilder & SetSupportsReadFromResolve(bool value)
Definition: capabilities.cc:203
impeller::CapabilitiesBuilder::SetSupportsOffscreenMSAA
CapabilitiesBuilder & SetSupportsOffscreenMSAA(bool value)
Definition: capabilities.cc:152