Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
capabilities.h
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#ifndef FLUTTER_IMPELLER_RENDERER_CAPABILITIES_H_
6#define FLUTTER_IMPELLER_RENDERER_CAPABILITIES_H_
7
8#include <memory>
9
11
12namespace impeller {
13
15 public:
16 virtual ~Capabilities();
17
18 /// @brief Whether the context backend supports attaching offscreen MSAA
19 /// color/stencil textures.
20 virtual bool SupportsOffscreenMSAA() const = 0;
21
22 /// @brief Whether the context backend supports multisampled rendering to
23 /// the on-screen surface without requiring an explicit resolve of
24 /// the MSAA color attachment.
25 virtual bool SupportsImplicitResolvingMSAA() const = 0;
26
27 /// @brief Whether the context backend supports binding Shader Storage Buffer
28 /// Objects (SSBOs) to pipelines.
29 virtual bool SupportsSSBO() const = 0;
30
31 /// @brief Whether the context backend supports blitting from one texture
32 /// region to another texture region (via the relevant
33 /// `BlitPass::AddCopy` overloads).
34 virtual bool SupportsTextureToTextureBlits() const = 0;
35
36 /// @brief Whether the context backend is able to support pipelines with
37 /// shaders that read from the framebuffer (i.e. pixels that have been
38 /// written by previous draw calls in the current render pass).
39 ///
40 /// Example of reading from the first color attachment in a GLSL
41 /// shader:
42 /// ```
43 /// uniform subpassInput subpass_input;
44 ///
45 /// out vec4 frag_color;
46 ///
47 /// void main() {
48 /// vec4 color = subpassLoad(subpass_input);
49 /// // Invert the colors drawn to the framebuffer.
50 /// frag_color = vec4(vec3(1) - color.rgb, color.a);
51 /// }
52 /// ```
53 virtual bool SupportsFramebufferFetch() const = 0;
54
55 /// @brief Whether the context backend supports `ComputePass`.
56 virtual bool SupportsCompute() const = 0;
57
58 /// @brief Whether the context backend supports configuring `ComputePass`
59 /// command subgroups.
60 virtual bool SupportsComputeSubgroups() const = 0;
61
62 /// @brief Whether the context backend supports binding the current
63 /// `RenderPass` attachments. This is supported if the backend can
64 /// guarantee that attachment textures will not be mutated until the
65 /// render pass has fully completed.
66 ///
67 /// This is possible because many mobile graphics cards track
68 /// `RenderPass` attachment state in intermediary tile memory prior to
69 /// Storing the pass in the heap allocated attachments on DRAM.
70 /// Metal's hazard tracking and Vulkan's barriers are granular enough
71 /// to allow for safely accessing attachment textures prior to storage
72 /// in the same `RenderPass`.
73 virtual bool SupportsReadFromResolve() const = 0;
74
75 /// @brief Whether the context backend supports `SamplerAddressMode::Decal`.
76 virtual bool SupportsDecalSamplerAddressMode() const = 0;
77
78 /// @brief Whether the context backend supports allocating
79 /// `StorageMode::kDeviceTransient` (aka "memoryless") textures, which
80 /// are temporary textures kept in tile memory for the duration of the
81 /// `RenderPass` it's attached to.
82 ///
83 /// This feature is especially useful for MSAA and stencils.
84 virtual bool SupportsDeviceTransientTextures() const = 0;
85
86 /// @brief Whether the primitive type TriangleFan is supported by the backend.
87 virtual bool SupportsTriangleFan() const = 0;
88
89 /// @brief Whether primitive restart is supported.
90 virtual bool SupportsPrimitiveRestart() const = 0;
91
92 /// @brief Whether 32-bit values are supported in index buffers used to draw
93 /// primitives.
94 virtual bool Supports32BitPrimitiveIndices() const = 0;
95
96 /// @brief Whether a texture whose mip levels were uploaded by hand (rather
97 /// than produced by `BlitPass::GenerateMipmap`) samples with correct
98 /// per-level selection. True everywhere except OpenGL ES 2.0 without
99 /// GL_APPLE_texture_max_level, where the sampled mip range cannot be
100 /// bounded to the levels the texture declares.
101 virtual bool SupportsManuallyMippedTextures() const = 0;
102
103 /// @brief Returns a supported `PixelFormat` for textures that store
104 /// 4-channel colors (red/green/blue/alpha).
106
107 /// @brief Returns a supported `PixelFormat` for textures that store stencil
108 /// information. May include a depth channel if a stencil-only format
109 /// is not available.
111
112 /// @brief Returns a supported `PixelFormat` for textures that store both a
113 /// stencil and depth component. This will never return a depth-only
114 /// or stencil-only texture.
115 /// Returns `PixelFormat::kUnknown` if no suitable depth+stencil
116 /// format was found.
118
119 /// @brief Returns the default pixel format for the alpha bitmap glyph atlas.
120 ///
121 /// Some backends may use Red channel while others use grey. This
122 /// should not have any impact
124
125 /// @brief Return the maximum size of a render pass attachment.
126 ///
127 /// Note that this may be smaller than the maximum allocatable texture size.
129
130 /// @brief Whether the XR formats are supported on this device.
131 ///
132 /// This is only ever true for iOS and macOS devices. We may need
133 /// to revisit this API when approaching wide gamut rendering for
134 /// Vulkan and GLES.
135 virtual bool SupportsExtendedRangeFormats() const = 0;
136
137 /// @brief Whether the given family of block-compressed texture formats is
138 /// supported by this device. Compressed formats are sample-only and
139 /// their support varies by hardware, so callers must check this before
140 /// allocating a compressed texture.
142 CompressedTextureFamily family) const = 0;
143
144 /// @brief Whether a non-zero mip level of a texture can be attached as a
145 /// render target. Rendering into a cube map face or array layer is
146 /// always supported. Metal and Vulkan support this; the GLES backend
147 /// does not yet, so it returns false there.
148 virtual bool SupportsFramebufferRenderMipmap() const = 0;
149
150 /// @brief The minimum alignment of uniform value offsets in bytes.
151 virtual size_t GetMinimumUniformAlignment() const = 0;
152
153 /// @brief The minimum alignment of storage buffer value offsets in bytes.
154 virtual size_t GetMinimumStorageBufferAlignment() const;
155
156 /// @brief Whether the host buffer should use separate device buffers
157 /// for indexes from other data.
158 virtual bool NeedsPartitionedHostBuffer() const = 0;
159
160 protected:
162
163 Capabilities(const Capabilities&) = delete;
164
166};
167
169 public:
171
173
175
177
179
181
183
185
187
189
191
193
195
197
199
202 bool value);
203
205
207
209
211
213
214 std::unique_ptr<Capabilities> Build();
215
216 private:
217 bool supports_offscreen_msaa_ = false;
218 bool supports_ssbo_ = false;
219 bool supports_texture_to_texture_blits_ = false;
220 bool supports_framebuffer_fetch_ = false;
221 bool supports_compute_ = false;
222 bool supports_compute_subgroups_ = false;
223 bool supports_read_from_resolve_ = false;
224 bool supports_decal_sampler_address_mode_ = false;
225 bool supports_device_transient_textures_ = false;
226 bool supports_triangle_fan_ = false;
227 bool supports_extended_range_formats_ = false;
228 bool needs_partitioned_host_buffer_ = false;
229 bool supports_texture_compression_bc_ = false;
230 bool supports_texture_compression_etc2_ = false;
231 bool supports_texture_compression_astc_ = false;
232 bool supports_texture_compression_astc_hdr_ = false;
233 std::optional<PixelFormat> default_color_format_ = std::nullopt;
234 std::optional<PixelFormat> default_stencil_format_ = std::nullopt;
235 std::optional<PixelFormat> default_depth_stencil_format_ = std::nullopt;
236 std::optional<PixelFormat> default_glyph_atlas_format_ = std::nullopt;
237 std::optional<ISize> default_maximum_render_pass_attachment_size_ =
238 std::nullopt;
239 size_t minimum_uniform_alignment_ = 256;
240
242
243 CapabilitiesBuilder& operator=(const CapabilitiesBuilder&) = delete;
244};
245
246} // namespace impeller
247
248#endif // FLUTTER_IMPELLER_RENDERER_CAPABILITIES_H_
CapabilitiesBuilder & SetDefaultColorFormat(PixelFormat value)
CapabilitiesBuilder & SetSupportsComputeSubgroups(bool value)
CapabilitiesBuilder & SetMinimumUniformAlignment(size_t value)
CapabilitiesBuilder & SetSupportsTextureToTextureBlits(bool value)
CapabilitiesBuilder & SetDefaultStencilFormat(PixelFormat value)
CapabilitiesBuilder & SetSupportsDeviceTransientTextures(bool value)
CapabilitiesBuilder & SetSupportsTriangleFan(bool value)
CapabilitiesBuilder & SetNeedsPartitionedHostBuffer(bool value)
CapabilitiesBuilder & SetSupportsFramebufferFetch(bool value)
CapabilitiesBuilder & SetSupportsDecalSamplerAddressMode(bool value)
CapabilitiesBuilder & SetSupportsTextureCompression(CompressedTextureFamily family, 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)
virtual bool SupportsFramebufferRenderMipmap() const =0
Whether a non-zero mip level of a texture can be attached as a render target. Rendering into a cube m...
virtual PixelFormat GetDefaultStencilFormat() const =0
Returns a supported PixelFormat for textures that store stencil information. May include a depth chan...
virtual size_t GetMinimumUniformAlignment() const =0
The minimum alignment of uniform value offsets in bytes.
virtual bool SupportsOffscreenMSAA() const =0
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
virtual bool SupportsImplicitResolvingMSAA() const =0
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
virtual bool SupportsFramebufferFetch() const =0
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
virtual bool SupportsDecalSamplerAddressMode() const =0
Whether the context backend supports SamplerAddressMode::Decal.
virtual bool SupportsReadFromResolve() const =0
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
virtual bool SupportsTriangleFan() const =0
Whether the primitive type TriangleFan is supported by the backend.
virtual bool SupportsComputeSubgroups() const =0
Whether the context backend supports configuring ComputePass command subgroups.
Capabilities & operator=(const Capabilities &)=delete
virtual bool NeedsPartitionedHostBuffer() const =0
Whether the host buffer should use separate device buffers for indexes from other data.
virtual bool Supports32BitPrimitiveIndices() const =0
Whether 32-bit values are supported in index buffers used to draw primitives.
Capabilities(const Capabilities &)=delete
virtual PixelFormat GetDefaultGlyphAtlasFormat() const =0
Returns the default pixel format for the alpha bitmap glyph atlas.
virtual bool SupportsPrimitiveRestart() const =0
Whether primitive restart is supported.
virtual PixelFormat GetDefaultColorFormat() const =0
Returns a supported PixelFormat for textures that store 4-channel colors (red/green/blue/alpha).
virtual ISize GetMaximumRenderPassAttachmentSize() const =0
Return the maximum size of a render pass attachment.
virtual bool SupportsDeviceTransientTextures() const =0
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
virtual size_t GetMinimumStorageBufferAlignment() const
The minimum alignment of storage buffer value offsets in bytes.
virtual bool SupportsCompute() const =0
Whether the context backend supports ComputePass.
virtual bool SupportsExtendedRangeFormats() const =0
Whether the XR formats are supported on this device.
virtual bool SupportsSSBO() const =0
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
virtual PixelFormat GetDefaultDepthStencilFormat() const =0
Returns a supported PixelFormat for textures that store both a stencil and depth component....
virtual bool SupportsManuallyMippedTextures() const =0
Whether a texture whose mip levels were uploaded by hand (rather than produced by BlitPass::GenerateM...
virtual bool SupportsTextureCompression(CompressedTextureFamily family) const =0
Whether the given family of block-compressed texture formats is supported by this device....
virtual bool SupportsTextureToTextureBlits() const =0
Whether the context backend supports blitting from one texture region to another texture region (via ...
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:99
CompressedTextureFamily
The family of a block-compressed pixel format. GPUs support compressed formats on a per-family basis,...
Definition formats.h:146