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 
6 
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 
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  }
137  is_es_ = desc->IsES();
138  is_angle_ = desc->IsANGLE();
139 }
140 
142  return is_es_;
143 }
144 
146  switch (stage) {
153  return 0u;
154  }
155  FML_UNREACHABLE();
156 }
157 
159  return supports_offscreen_msaa_;
160 }
161 
163  return supports_implicit_msaa_;
164 }
165 
167  return false;
168 }
169 
171  return supports_texture_to_texture_blits_;
172 }
173 
175  return supports_framebuffer_fetch_;
176 }
177 
179  return false;
180 }
181 
183  return false;
184 }
185 
187  return false;
188 }
189 
191  return supports_decal_sampler_address_mode_;
192 }
193 
195  return false;
196 }
197 
199  return true;
200 }
201 
204 }
205 
207  return PixelFormat::kS8UInt;
208 }
209 
212 }
213 
215  return is_angle_;
216 }
217 
219  return false;
220 }
221 
223  return default_glyph_atlas_format_;
224 }
225 
227  return max_texture_size;
228 }
229 
230 } // 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 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.
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 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
static constexpr const char * kTextureBorderClampExt
static constexpr const char * kMultisampledRenderToTexture2Ext
static constexpr const char * kNvidiaTextureBorderClampExt
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
static constexpr const char * kFramebufferFetchExt
static constexpr const char * kMultisampledRenderToTextureExt