| Flutter Impeller |

capabilities_gles.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/backend/gles/capabilities_gles.h"
6
7 #include "impeller/core/formats.h"
8 #include "impeller/renderer/backend/gles/proc_table_gles.h"
9
10 namespace impeller {
11
12 // https://registry.khronos.org/OpenGL/extensions/EXT/EXT_shader_framebuffer_fetch.txt
13 static const constexpr char* kFramebufferFetchExt =
14 "GL_EXT_shader_framebuffer_fetch";
15
16 static const constexpr char* kTextureBorderClampExt =
17 "GL_EXT_texture_border_clamp";
18 static const constexpr char* kNvidiaTextureBorderClampExt =
19 "GL_NV_texture_border_clamp";
20
21 // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_multisampled_render_to_texture.txt
22 static const constexpr char* kMultisampledRenderToTextureExt =
23 "GL_EXT_multisampled_render_to_texture";
24
25 // https://registry.khronos.org/OpenGL/extensions/EXT/EXT_multisampled_render_to_texture2.txt
26 static const constexpr char* kMultisampledRenderToTexture2Ext =
27 "GL_EXT_multisampled_render_to_texture2";
28
29 // https://registry.khronos.org/OpenGL/extensions/OES/OES_element_index_uint.txt
30 static const constexpr char* kElementIndexUintExt = "GL_OES_element_index_uint";
31
32 CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) {
33 {
34 GLint value = 0;
35 gl.GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &value);
36 max_combined_texture_image_units = value;
37 }
38
39 {
40 GLint value = 0;
41 gl.GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &value);
42 max_cube_map_texture_size = value;
43 }
44
45 auto const desc = gl.GetDescription();
46
47 if (desc->IsES()) {
48 GLint value = 0;
49 gl.GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &value);
50 max_fragment_uniform_vectors = value;
51 }
52
53 {
54 GLint value = 0;
55 gl.GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value);
56 max_renderbuffer_size = value;
57 }
58
59 {
60 GLint value = 0;
61 gl.GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &value);
62 max_texture_image_units = value;
63 }
64
65 {
66 GLint value = 0;
67 gl.GetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
68 max_texture_size = ISize{value, value};
69 }
70
71 if (desc->IsES()) {
72 GLint value = 0;
73 gl.GetIntegerv(GL_MAX_VARYING_VECTORS, &value);
74 max_varying_vectors = value;
75 }
76
77 {
78 GLint value = 0;
79 gl.GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value);
80 max_vertex_attribs = value;
81 }
82
83 {
84 GLint value = 0;
85 gl.GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &value);
86 max_vertex_texture_image_units = value;
87 }
88
89 if (desc->IsES()) {
90 GLint value = 0;
91 gl.GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &value);
92 max_vertex_uniform_vectors = value;
93 }
94
95 {
96 GLint values[2] = {};
97 gl.GetIntegerv(GL_MAX_VIEWPORT_DIMS, values);
98 max_viewport_dims = ISize{values[0], values[1]};
99 }
100
101 {
102 GLint value = 0;
103 gl.GetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &value);
104 num_compressed_texture_formats = value;
105 }
106
107 if (desc->IsES()) {
108 GLint value = 0;
109 gl.GetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &value);
110 num_shader_binary_formats = value;
111 }
112
113 if (desc->IsES()) {
114 default_glyph_atlas_format_ = PixelFormat::kA8UNormInt;
115 } else {
116 default_glyph_atlas_format_ = PixelFormat::kR8UNormInt;
117 }
118
119 if (desc->GetGlVersion().major_version >= 3) {
120 supports_texture_to_texture_blits_ = true;
121 }
122
123 supports_framebuffer_fetch_ = desc->HasExtension(kFramebufferFetchExt);
124
125 if (desc->HasExtension(kTextureBorderClampExt) ||
126 desc->HasExtension(kNvidiaTextureBorderClampExt)) {
127 supports_decal_sampler_address_mode_ = true;
128 }
129
130 if (desc->HasExtension(kElementIndexUintExt)) {
131 supports_32bit_primitive_indices_ = true;
132 }
133
134 if (desc->HasExtension(kMultisampledRenderToTextureExt)) {
135 supports_implicit_msaa_ = true;
136
137 if (desc->HasExtension(kMultisampledRenderToTexture2Ext)) {
138 // We hard-code 4x MSAA, so let's make sure it's supported.
139 GLint value = 0;
140 gl.GetIntegerv(GL_MAX_SAMPLES_EXT, &value);
141 supports_offscreen_msaa_ = value >= 4;
142 }
143 } else if (desc->GetGlVersion().major_version >= 3 && desc->IsES()) {
144 GLint value = 0;
145 gl.GetIntegerv(GL_MAX_SAMPLES, &value);
146 supports_offscreen_msaa_ = value >= 4;
147 }
148 is_es_ = desc->IsES();
149 is_angle_ = desc->IsANGLE();
150 }
151
152 bool CapabilitiesGLES::IsES() const {
153 return is_es_;
154 }
155
156 size_t CapabilitiesGLES::GetMaxTextureUnits(ShaderStage stage) const {
157 switch (stage) {
158 case ShaderStage::kVertex:
159 return max_vertex_texture_image_units;
160 case ShaderStage::kFragment:
161 return max_texture_image_units;
162 case ShaderStage::kUnknown:
163 case ShaderStage::kCompute:
164 return 0u;
165 }
166 FML_UNREACHABLE();
167 }
168
169 bool CapabilitiesGLES::SupportsOffscreenMSAA() const {
170 return supports_offscreen_msaa_;
171 }
172
173 bool CapabilitiesGLES::SupportsImplicitResolvingMSAA() const {
174 return supports_implicit_msaa_;
175 }
176
177 bool CapabilitiesGLES::SupportsSSBO() const {
178 return false;
179 }
180
181 bool CapabilitiesGLES::SupportsTextureToTextureBlits() const {
182 return supports_texture_to_texture_blits_;
183 }
184
185 bool CapabilitiesGLES::SupportsFramebufferFetch() const {
186 return supports_framebuffer_fetch_;
187 }
188
189 bool CapabilitiesGLES::SupportsCompute() const {
190 return false;
191 }
192
193 bool CapabilitiesGLES::SupportsComputeSubgroups() const {
194 return false;
195 }
196
197 bool CapabilitiesGLES::SupportsReadFromResolve() const {
198 return false;
199 }
200
201 bool CapabilitiesGLES::SupportsDecalSamplerAddressMode() const {
202 return supports_decal_sampler_address_mode_;
203 }
204
205 bool CapabilitiesGLES::SupportsDeviceTransientTextures() const {
206 return false;
207 }
208
209 bool CapabilitiesGLES::SupportsTriangleFan() const {
210 return true;
211 }
212
213 PixelFormat CapabilitiesGLES::GetDefaultColorFormat() const {
214 return PixelFormat::kR8G8B8A8UNormInt;
215 }
216
217 PixelFormat CapabilitiesGLES::GetDefaultStencilFormat() const {
218 return PixelFormat::kS8UInt;
219 }
220
221 PixelFormat CapabilitiesGLES::GetDefaultDepthStencilFormat() const {
222 return PixelFormat::kD24UnormS8Uint;
223 }
224
225 bool CapabilitiesGLES::IsANGLE() const {
226 return is_angle_;
227 }
228
229 bool CapabilitiesGLES::SupportsPrimitiveRestart() const {
230 return false;
231 }
232
233 bool CapabilitiesGLES::Supports32BitPrimitiveIndices() const {
234 return supports_32bit_primitive_indices_;
235 }
236
237 bool CapabilitiesGLES::SupportsExtendedRangeFormats() const {
238 return false;
239 }
240
241 PixelFormat CapabilitiesGLES::GetDefaultGlyphAtlasFormat() const {
242 return default_glyph_atlas_format_;
243 }
244
245 ISize CapabilitiesGLES::GetMaximumRenderPassAttachmentSize() const {
246 return max_texture_size;
247 }
248
249 size_t CapabilitiesGLES::GetMinimumUniformAlignment() const {
250 return 256;
251 }
252
253 bool CapabilitiesGLES::NeedsPartitionedHostBuffer() const {
254 return false;
255 }
256
257 } // namespace impeller
capabilities_gles.h
impeller::CapabilitiesGLES::IsES
bool IsES() const
Whether this is an ES GL variant or (if false) desktop GL.
Definition: capabilities_gles.cc:152
impeller::CapabilitiesGLES::SupportsImplicitResolvingMSAA
bool SupportsImplicitResolvingMSAA() const override
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
Definition: capabilities_gles.cc:173
impeller::CapabilitiesGLES::GetDefaultDepthStencilFormat
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
Definition: capabilities_gles.cc:221
impeller::CapabilitiesGLES::max_vertex_uniform_vectors
size_t max_vertex_uniform_vectors
Definition: capabilities_gles.h:65
impeller::CapabilitiesGLES::GetDefaultColorFormat
PixelFormat GetDefaultColorFormat() const override
Returns a supported PixelFormat for textures that store 4-channel colors (red/green/blue/alpha).
Definition: capabilities_gles.cc:213
impeller::CapabilitiesGLES::SupportsSSBO
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
Definition: capabilities_gles.cc:177
impeller::CapabilitiesGLES::max_fragment_uniform_vectors
size_t max_fragment_uniform_vectors
Definition: capabilities_gles.h:44
impeller::CapabilitiesGLES::SupportsTextureToTextureBlits
bool SupportsTextureToTextureBlits() const override
Whether the context backend supports blitting from one texture region to another texture region (via ...
Definition: capabilities_gles.cc:181
impeller::CapabilitiesGLES::GetMaximumRenderPassAttachmentSize
ISize GetMaximumRenderPassAttachmentSize() const override
Return the maximum size of a render pass attachment.
Definition: capabilities_gles.cc:245
impeller::CapabilitiesGLES::CapabilitiesGLES
CapabilitiesGLES(const ProcTableGLES &gl)
Definition: capabilities_gles.cc:32
impeller::CapabilitiesGLES::max_viewport_dims
ISize max_viewport_dims
Definition: capabilities_gles.h:68
impeller::CapabilitiesGLES::max_renderbuffer_size
size_t max_renderbuffer_size
Definition: capabilities_gles.h:47
impeller::CapabilitiesGLES::SupportsPrimitiveRestart
bool SupportsPrimitiveRestart() const override
Whether primitive restart is supported.
Definition: capabilities_gles.cc:229
impeller::CapabilitiesGLES::GetMaxTextureUnits
size_t GetMaxTextureUnits(ShaderStage stage) const
Definition: capabilities_gles.cc:156
impeller::CapabilitiesGLES::NeedsPartitionedHostBuffer
bool NeedsPartitionedHostBuffer() const override
Whether the host buffer should use separate device buffers for indexes from other data.
Definition: capabilities_gles.cc:253
impeller::CapabilitiesGLES::IsANGLE
bool IsANGLE() const
Definition: capabilities_gles.cc:225
impeller::CapabilitiesGLES::max_cube_map_texture_size
size_t max_cube_map_texture_size
Definition: capabilities_gles.h:41
impeller::CapabilitiesGLES::max_vertex_texture_image_units
size_t max_vertex_texture_image_units
Definition: capabilities_gles.h:62
impeller::CapabilitiesGLES::SupportsTriangleFan
bool SupportsTriangleFan() const override
Whether the primitive type TriangleFan is supported by the backend.
Definition: capabilities_gles.cc:209
impeller::CapabilitiesGLES::num_shader_binary_formats
size_t num_shader_binary_formats
Definition: capabilities_gles.h:74
impeller::CapabilitiesGLES::Supports32BitPrimitiveIndices
bool Supports32BitPrimitiveIndices() const override
Whether 32-bit values are supported in index buffers used to draw primitives.
Definition: capabilities_gles.cc:233
impeller::CapabilitiesGLES::max_combined_texture_image_units
size_t max_combined_texture_image_units
Definition: capabilities_gles.h:38
impeller::CapabilitiesGLES::SupportsOffscreenMSAA
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
Definition: capabilities_gles.cc:169
impeller::CapabilitiesGLES::GetMinimumUniformAlignment
size_t GetMinimumUniformAlignment() const override
The minimum alignment of uniform value offsets in bytes.
Definition: capabilities_gles.cc:249
impeller::CapabilitiesGLES::GetDefaultStencilFormat
PixelFormat GetDefaultStencilFormat() const override
Returns a supported PixelFormat for textures that store stencil information. May include a depth chan...
Definition: capabilities_gles.cc:217
impeller::CapabilitiesGLES::SupportsReadFromResolve
bool SupportsReadFromResolve() const override
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
Definition: capabilities_gles.cc:197
impeller::CapabilitiesGLES::SupportsDeviceTransientTextures
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
Definition: capabilities_gles.cc:205
impeller::CapabilitiesGLES::SupportsDecalSamplerAddressMode
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
Definition: capabilities_gles.cc:201
impeller::CapabilitiesGLES::max_texture_image_units
size_t max_texture_image_units
Definition: capabilities_gles.h:50
impeller::CapabilitiesGLES::GetDefaultGlyphAtlasFormat
PixelFormat GetDefaultGlyphAtlasFormat() const override
Returns the default pixel format for the alpha bitmap glyph atlas.
Definition: capabilities_gles.cc:241
impeller::CapabilitiesGLES::max_texture_size
ISize max_texture_size
Definition: capabilities_gles.h:53
impeller::CapabilitiesGLES::max_vertex_attribs
size_t max_vertex_attribs
Definition: capabilities_gles.h:59
impeller::CapabilitiesGLES::SupportsExtendedRangeFormats
bool SupportsExtendedRangeFormats() const override
Whether the XR formats are supported on this device.
Definition: capabilities_gles.cc:237
impeller::CapabilitiesGLES::SupportsCompute
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
Definition: capabilities_gles.cc:189
impeller::CapabilitiesGLES::max_varying_vectors
size_t max_varying_vectors
Definition: capabilities_gles.h:56
impeller::CapabilitiesGLES::SupportsComputeSubgroups
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
Definition: capabilities_gles.cc:193
impeller::CapabilitiesGLES::num_compressed_texture_formats
size_t num_compressed_texture_formats
Definition: capabilities_gles.h:71
impeller::CapabilitiesGLES::SupportsFramebufferFetch
bool SupportsFramebufferFetch() const override
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
Definition: capabilities_gles.cc:185
impeller::ProcTableGLES
Definition: proc_table_gles.h:283
impeller::ProcTableGLES::GetDescription
const DescriptionGLES * GetDescription() const
Definition: proc_table_gles.cc:208
formats.h
value
int32_t value
Definition: dl_golden_unittests.cc:459
impeller
Definition: allocation.cc:12
impeller::kTextureBorderClampExt
static constexpr const char * kTextureBorderClampExt
Definition: capabilities_gles.cc:16
impeller::kMultisampledRenderToTexture2Ext
static constexpr const char * kMultisampledRenderToTexture2Ext
Definition: capabilities_gles.cc:26
impeller::kNvidiaTextureBorderClampExt
static constexpr const char * kNvidiaTextureBorderClampExt
Definition: capabilities_gles.cc:18
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
impeller::PixelFormat::kD24UnormS8Uint
@ kD24UnormS8Uint
impeller::PixelFormat::kR8UNormInt
@ kR8UNormInt
impeller::PixelFormat::kA8UNormInt
@ kA8UNormInt
impeller::PixelFormat::kS8UInt
@ kS8UInt
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::ShaderStage::kUnknown
@ kUnknown
impeller::ShaderStage::kCompute
@ kCompute
impeller::ShaderStage::kFragment
@ kFragment
impeller::ShaderStage::kVertex
@ kVertex
impeller::kFramebufferFetchExt
static constexpr const char * kFramebufferFetchExt
Definition: capabilities_gles.cc:13
impeller::kElementIndexUintExt
static constexpr const char * kElementIndexUintExt
Definition: capabilities_gles.cc:30
impeller::kMultisampledRenderToTextureExt
static constexpr const char * kMultisampledRenderToTextureExt
Definition: capabilities_gles.cc:22
proc_table_gles.h
impeller::TSize
Definition: size.h:25