| 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 PixelFormat GetDefaultColorFormat() const override {
60 return default_color_format_;
61 }
62
63 // |Capabilities|
64 PixelFormat GetDefaultStencilFormat() const override {
65 return default_stencil_format_;
66 }
67
68 // |Capabilities|
69 PixelFormat GetDefaultDepthStencilFormat() const override {
70 return default_depth_stencil_format_;
71 }
72
73 // |Capabilities|
74 bool SupportsDeviceTransientTextures() const override {
75 return supports_device_transient_textures_;
76 }
77
78 // |Capabilities|
79 PixelFormat GetDefaultGlyphAtlasFormat() const override {
80 return default_glyph_atlas_format_;
81 }
82
83 private:
84 StandardCapabilities(bool supports_offscreen_msaa,
85 bool supports_ssbo,
86 bool supports_texture_to_texture_blits,
87 bool supports_framebuffer_fetch,
88 bool supports_compute,
89 bool supports_compute_subgroups,
90 bool supports_read_from_resolve,
91 bool supports_decal_sampler_address_mode,
92 bool supports_device_transient_textures,
93 PixelFormat default_color_format,
94 PixelFormat default_stencil_format,
95 PixelFormat default_depth_stencil_format,
96 PixelFormat default_glyph_atlas_format)
97 : supports_offscreen_msaa_(supports_offscreen_msaa),
98 supports_ssbo_(supports_ssbo),
99 supports_texture_to_texture_blits_(supports_texture_to_texture_blits),
100 supports_framebuffer_fetch_(supports_framebuffer_fetch),
101 supports_compute_(supports_compute),
102 supports_compute_subgroups_(supports_compute_subgroups),
103 supports_read_from_resolve_(supports_read_from_resolve),
104 supports_decal_sampler_address_mode_(
105 supports_decal_sampler_address_mode),
106 supports_device_transient_textures_(supports_device_transient_textures),
107 default_color_format_(default_color_format),
108 default_stencil_format_(default_stencil_format),
109 default_depth_stencil_format_(default_depth_stencil_format),
110 default_glyph_atlas_format_(default_glyph_atlas_format) {}
111
112 friend class CapabilitiesBuilder;
113
114 bool supports_offscreen_msaa_ = false;
115 bool supports_ssbo_ = false;
116 bool supports_texture_to_texture_blits_ = false;
117 bool supports_framebuffer_fetch_ = false;
118 bool supports_compute_ = false;
119 bool supports_compute_subgroups_ = false;
120 bool supports_read_from_resolve_ = false;
121 bool supports_decal_sampler_address_mode_ = false;
122 bool supports_device_transient_textures_ = false;
123 PixelFormat default_color_format_ = PixelFormat::kUnknown;
124 PixelFormat default_stencil_format_ = PixelFormat::kUnknown;
125 PixelFormat default_depth_stencil_format_ = PixelFormat::kUnknown;
126 PixelFormat default_glyph_atlas_format_ = PixelFormat::kUnknown;
127
128 StandardCapabilities(const StandardCapabilities&) = delete;
129
130 StandardCapabilities& operator=(const StandardCapabilities&) = delete;
131 };
132
133 CapabilitiesBuilder::CapabilitiesBuilder() = default;
134
135 CapabilitiesBuilder::~CapabilitiesBuilder() = default;
136
137 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsOffscreenMSAA(bool value) {
138 supports_offscreen_msaa_ = value;
139 return *this;
140 }
141
142 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsSSBO(bool value) {
143 supports_ssbo_ = value;
144 return *this;
145 }
146
147 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsTextureToTextureBlits(
148 bool value) {
149 supports_texture_to_texture_blits_ = value;
150 return *this;
151 }
152
153 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsFramebufferFetch(
154 bool value) {
155 supports_framebuffer_fetch_ = value;
156 return *this;
157 }
158
159 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsCompute(bool value) {
160 supports_compute_ = value;
161 return *this;
162 }
163
164 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsComputeSubgroups(
165 bool value) {
166 supports_compute_subgroups_ = value;
167 return *this;
168 }
169
170 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultColorFormat(
171 PixelFormat value) {
172 default_color_format_ = value;
173 return *this;
174 }
175
176 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultStencilFormat(
177 PixelFormat value) {
178 default_stencil_format_ = value;
179 return *this;
180 }
181
182 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultDepthStencilFormat(
183 PixelFormat value) {
184 default_depth_stencil_format_ = value;
185 return *this;
186 }
187
188 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsReadFromResolve(
189 bool read_from_resolve) {
190 supports_read_from_resolve_ = read_from_resolve;
191 return *this;
192 }
193
194 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode(
195 bool value) {
196 supports_decal_sampler_address_mode_ = value;
197 return *this;
198 }
199
200 CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsDeviceTransientTextures(
201 bool value) {
202 supports_device_transient_textures_ = value;
203 return *this;
204 }
205
206 CapabilitiesBuilder& CapabilitiesBuilder::SetDefaultGlyphAtlasFormat(
207 PixelFormat value) {
208 default_glyph_atlas_format_ = value;
209 return *this;
210 }
211
212 std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
213 return std::unique_ptr<StandardCapabilities>(new StandardCapabilities( //
214 supports_offscreen_msaa_, //
215 supports_ssbo_, //
216 supports_texture_to_texture_blits_, //
217 supports_framebuffer_fetch_, //
218 supports_compute_, //
219 supports_compute_subgroups_, //
220 supports_read_from_resolve_, //
221 supports_decal_sampler_address_mode_, //
222 supports_device_transient_textures_, //
223 default_color_format_.value_or(PixelFormat::kUnknown), //
224 default_stencil_format_.value_or(PixelFormat::kUnknown), //
225 default_depth_stencil_format_.value_or(PixelFormat::kUnknown), //
226 default_glyph_atlas_format_.value_or(PixelFormat::kUnknown) //
227 ));
228 }
229
230 } // 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::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:212
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:64
formats.h
impeller::CapabilitiesBuilder
Definition: capabilities.h:116
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::CapabilitiesBuilder::SetSupportsSSBO
CapabilitiesBuilder & SetSupportsSSBO(bool value)
Definition: capabilities.cc:142
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:159
impeller::CapabilitiesBuilder::SetDefaultDepthStencilFormat
CapabilitiesBuilder & SetDefaultDepthStencilFormat(PixelFormat value)
Definition: capabilities.cc:182
impeller::CapabilitiesBuilder::SetDefaultGlyphAtlasFormat
CapabilitiesBuilder & SetDefaultGlyphAtlasFormat(PixelFormat value)
Definition: capabilities.cc:206
impeller::StandardCapabilities
Definition: capabilities.cc:14
impeller::CapabilitiesBuilder::SetSupportsFramebufferFetch
CapabilitiesBuilder & SetSupportsFramebufferFetch(bool value)
Definition: capabilities.cc:153
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:59
impeller::CapabilitiesBuilder::~CapabilitiesBuilder
~CapabilitiesBuilder()
impeller::CapabilitiesBuilder::SetSupportsComputeSubgroups
CapabilitiesBuilder & SetSupportsComputeSubgroups(bool value)
Definition: capabilities.cc:164
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:147
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:74
impeller::StandardCapabilities::GetDefaultDepthStencilFormat
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
Definition: capabilities.cc:69
impeller::CapabilitiesBuilder::SetDefaultColorFormat
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
Definition: capabilities.cc:170
impeller::CapabilitiesBuilder::SetDefaultStencilFormat
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
Definition: capabilities.cc:176
impeller::StandardCapabilities::GetDefaultGlyphAtlasFormat
PixelFormat GetDefaultGlyphAtlasFormat() const override
Returns the default pixel format for the alpha bitmap glyph atlas.
Definition: capabilities.cc:79
impeller::Capabilities::~Capabilities
virtual ~Capabilities()
impeller::CapabilitiesBuilder::SetSupportsDecalSamplerAddressMode
CapabilitiesBuilder & SetSupportsDecalSamplerAddressMode(bool value)
Definition: capabilities.cc:194
impeller::CapabilitiesBuilder::SetSupportsDeviceTransientTextures
CapabilitiesBuilder & SetSupportsDeviceTransientTextures(bool value)
Definition: capabilities.cc:200
impeller
Definition: aiks_blend_unittests.cc:18
impeller::CapabilitiesBuilder::SetSupportsReadFromResolve
CapabilitiesBuilder & SetSupportsReadFromResolve(bool value)
Definition: capabilities.cc:188
impeller::CapabilitiesBuilder::SetSupportsOffscreenMSAA
CapabilitiesBuilder & SetSupportsOffscreenMSAA(bool value)
Definition: capabilities.cc:137