Flutter Engine
 
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
30 {
31 GLint value = 0;
32 gl.GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &value);
34 }
35
36 {
37 GLint value = 0;
38 gl.GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &value);
40 }
41
42 auto const desc = gl.GetDescription();
43
44 if (desc->IsES()) {
45 GLint value = 0;
46 gl.GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &value);
48 }
49
50 {
51 GLint value = 0;
52 gl.GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value);
54 }
55
56 {
57 GLint value = 0;
58 gl.GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &value);
60 }
61
62 {
63 GLint value = 0;
64 gl.GetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
66 }
67
68 if (desc->IsES()) {
69 GLint value = 0;
70 gl.GetIntegerv(GL_MAX_VARYING_VECTORS, &value);
72 }
73
74 {
75 GLint value = 0;
76 gl.GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value);
78 }
79
80 {
81 GLint value = 0;
82 gl.GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &value);
84 }
85
86 if (desc->IsES()) {
87 GLint value = 0;
88 gl.GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &value);
90 }
91
92 {
93 GLint values[2] = {};
94 gl.GetIntegerv(GL_MAX_VIEWPORT_DIMS, values);
95 max_viewport_dims = ISize{values[0], values[1]};
96 }
97
98 {
99 GLint value = 0;
100 gl.GetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &value);
102 }
103
104 if (desc->IsES()) {
105 GLint value = 0;
106 gl.GetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &value);
108 }
109
110 if (desc->IsES()) {
111 default_glyph_atlas_format_ = PixelFormat::kA8UNormInt;
112 } else {
113 default_glyph_atlas_format_ = PixelFormat::kR8UNormInt;
114 }
115
116 if (desc->GetGlVersion().major_version >= 3) {
117 supports_texture_to_texture_blits_ = true;
118 }
119
120 supports_framebuffer_fetch_ = desc->HasExtension(kFramebufferFetchExt);
121
122 if (desc->HasExtension(kTextureBorderClampExt) ||
123 desc->HasExtension(kNvidiaTextureBorderClampExt)) {
124 supports_decal_sampler_address_mode_ = true;
125 }
126
127 if (desc->HasExtension(kMultisampledRenderToTextureExt)) {
128 supports_implicit_msaa_ = true;
129
130 if (desc->HasExtension(kMultisampledRenderToTexture2Ext)) {
131 // We hard-code 4x MSAA, so let's make sure it's supported.
132 GLint value = 0;
133 gl.GetIntegerv(GL_MAX_SAMPLES_EXT, &value);
134 supports_offscreen_msaa_ = value >= 4;
135 }
136 } else if (desc->GetGlVersion().major_version >= 3 && desc->IsES()) {
137 GLint value = 0;
138 gl.GetIntegerv(GL_MAX_SAMPLES, &value);
139 supports_offscreen_msaa_ = value >= 4;
140 }
141 is_es_ = desc->IsES();
142 is_angle_ = desc->IsANGLE();
143}
144
146 return is_es_;
147}
148
150 switch (stage) {
157 return 0u;
158 }
160}
161
163 return supports_offscreen_msaa_;
164}
165
167 return supports_implicit_msaa_;
168}
169
171 return false;
172}
173
175 return supports_texture_to_texture_blits_;
176}
177
179 return supports_framebuffer_fetch_;
180}
181
183 return false;
184}
185
187 return false;
188}
189
191 return false;
192}
193
195 return supports_decal_sampler_address_mode_;
196}
197
199 return false;
200}
201
203 return true;
204}
205
209
213
217
219 return is_angle_;
220}
221
223 return false;
224}
225
227 return false;
228}
229
231 return default_glyph_atlas_format_;
232}
233
237
239 return 256;
240}
241
243 return false;
244}
245
246} // 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 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