Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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
6
9
10namespace impeller {
11
12// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_shader_framebuffer_fetch.txt
13static const constexpr char* kFramebufferFetchExt =
14 "GL_EXT_shader_framebuffer_fetch";
15
16static const constexpr char* kTextureBorderClampExt =
17 "GL_EXT_texture_border_clamp";
18static 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
22static 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
26static 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
30static const constexpr char* kElementIndexUintExt = "GL_OES_element_index_uint";
31
33 {
34 GLint value = 0;
35 gl.GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &value);
37 }
38
39 {
40 GLint value = 0;
41 gl.GetIntegerv(GL_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);
51 }
52
53 {
54 GLint value = 0;
55 gl.GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value);
57 }
58
59 {
60 GLint value = 0;
61 gl.GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &value);
63 }
64
65 {
66 GLint value = 0;
67 gl.GetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
69 }
70
71 if (desc->IsES()) {
72 GLint value = 0;
73 gl.GetIntegerv(GL_MAX_VARYING_VECTORS, &value);
75 }
76
77 {
78 GLint value = 0;
79 gl.GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value);
81 }
82
83 {
84 GLint value = 0;
85 gl.GetIntegerv(GL_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);
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);
105 }
106
107 if (desc->IsES()) {
108 GLint value = 0;
109 gl.GetIntegerv(GL_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
153 return is_es_;
154}
155
157 switch (stage) {
164 return 0u;
165 }
167}
168
170 return supports_offscreen_msaa_;
171}
172
174 return supports_implicit_msaa_;
175}
176
178 return false;
179}
180
182 return supports_texture_to_texture_blits_;
183}
184
186 return supports_framebuffer_fetch_;
187}
188
190 return false;
191}
192
194 return false;
195}
196
198 return false;
199}
200
202 return supports_decal_sampler_address_mode_;
203}
204
206 return false;
207}
208
210 return true;
211}
212
216
220
224
226 return is_angle_;
227}
228
230 return false;
231}
232
234 return supports_32bit_primitive_indices_;
235}
236
238 return false;
239}
240
242 return default_glyph_atlas_format_;
243}
244
248
250 return 256;
251}
252
254 return false;
255}
256
257} // namespace impeller
bool IsES() const
Whether this is an ES GL variant or (if false) desktop GL.
bool SupportsImplicitResolvingMSAA() const override
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
PixelFormat GetDefaultDepthStencilFormat() const override
Returns a supported PixelFormat for textures that store both a stencil and depth component....
PixelFormat GetDefaultColorFormat() const override
Returns a supported PixelFormat for textures that store 4-channel colors (red/green/blue/alpha).
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
bool SupportsTextureToTextureBlits() const override
Whether the context backend supports blitting from one texture region to another texture region (via ...
ISize GetMaximumRenderPassAttachmentSize() const override
Return the maximum size of a render pass attachment.
CapabilitiesGLES(const ProcTableGLES &gl)
bool SupportsPrimitiveRestart() const override
Whether primitive restart is supported.
size_t GetMaxTextureUnits(ShaderStage stage) const
bool NeedsPartitionedHostBuffer() const override
Whether the host buffer should use separate device buffers for indexes from other data.
bool SupportsTriangleFan() const override
Whether the primitive type TriangleFan is supported by the backend.
bool Supports32BitPrimitiveIndices() const override
Whether 32-bit values are supported in index buffers used to draw primitives.
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
size_t GetMinimumUniformAlignment() const override
The minimum alignment of uniform value offsets in bytes.
PixelFormat GetDefaultStencilFormat() const override
Returns a supported PixelFormat for textures that store stencil information. May include a depth chan...
bool SupportsReadFromResolve() const override
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
PixelFormat GetDefaultGlyphAtlasFormat() const override
Returns the default pixel format for the alpha bitmap glyph atlas.
bool SupportsExtendedRangeFormats() const override
Whether the XR formats are supported on this device.
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
bool SupportsFramebufferFetch() const override
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
const DescriptionGLES * GetDescription() const
int32_t value
#define FML_UNREACHABLE()
Definition logging.h:128
static const constexpr char * kMultisampledRenderToTexture2Ext
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:99
static const constexpr char * kMultisampledRenderToTextureExt
static const constexpr char * kTextureBorderClampExt
static const constexpr char * kNvidiaTextureBorderClampExt
static const constexpr char * kFramebufferFetchExt
static const constexpr char * kElementIndexUintExt