| 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 CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) {
26 {
27 GLint value = 0;
28 gl.GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &value);
29 max_combined_texture_image_units = value;
30 }
31
32 {
33 GLint value = 0;
34 gl.GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &value);
35 max_cube_map_texture_size = value;
36 }
37
38 auto const desc = gl.GetDescription();
39
40 if (desc->IsES()) {
41 GLint value = 0;
42 gl.GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &value);
43 max_fragment_uniform_vectors = value;
44 }
45
46 {
47 GLint value = 0;
48 gl.GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value);
49 max_renderbuffer_size = value;
50 }
51
52 {
53 GLint value = 0;
54 gl.GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &value);
55 max_texture_image_units = value;
56 }
57
58 {
59 GLint value = 0;
60 gl.GetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
61 max_texture_size = ISize{value, value};
62 }
63
64 if (desc->IsES()) {
65 GLint value = 0;
66 gl.GetIntegerv(GL_MAX_VARYING_VECTORS, &value);
67 max_varying_vectors = value;
68 }
69
70 {
71 GLint value = 0;
72 gl.GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value);
73 max_vertex_attribs = value;
74 }
75
76 {
77 GLint value = 0;
78 gl.GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &value);
79 max_vertex_texture_image_units = value;
80 }
81
82 if (desc->IsES()) {
83 GLint value = 0;
84 gl.GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &value);
85 max_vertex_uniform_vectors = value;
86 }
87
88 {
89 GLint values[2] = {};
90 gl.GetIntegerv(GL_MAX_VIEWPORT_DIMS, values);
91 max_viewport_dims = ISize{values[0], values[1]};
92 }
93
94 {
95 GLint value = 0;
96 gl.GetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &value);
97 num_compressed_texture_formats = value;
98 }
99
100 if (desc->IsES()) {
101 GLint value = 0;
102 gl.GetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &value);
103 num_shader_binary_formats = value;
104 }
105
106 if (desc->IsES()) {
107 default_glyph_atlas_format_ = PixelFormat::kA8UNormInt;
108 } else {
109 default_glyph_atlas_format_ = PixelFormat::kR8UNormInt;
110 }
111
112 supports_framebuffer_fetch_ = desc->HasExtension(kFramebufferFetchExt);
113
114 if (desc->HasExtension(kTextureBorderClampExt) ||
115 desc->HasExtension(kNvidiaTextureBorderClampExt)) {
116 supports_decal_sampler_address_mode_ = true;
117 }
118
119 if (desc->HasExtension(kMultisampledRenderToTextureExt)) {
120 supports_implicit_msaa_ = true;
121
122 // We hard-code 4x MSAA, so let's make sure it's supported.
123 GLint value = 0;
124 gl.GetIntegerv(GL_MAX_SAMPLES_EXT, &value);
125 supports_offscreen_msaa_ = value >= 4;
126 }
127
128 is_angle_ = desc->IsANGLE();
129 }
130
131 size_t CapabilitiesGLES::GetMaxTextureUnits(ShaderStage stage) const {
132 switch (stage) {
133 case ShaderStage::kVertex:
134 return max_vertex_texture_image_units;
135 case ShaderStage::kFragment:
136 return max_texture_image_units;
137 case ShaderStage::kUnknown:
138 case ShaderStage::kCompute:
139 return 0u;
140 }
141 FML_UNREACHABLE();
142 }
143
144 bool CapabilitiesGLES::SupportsOffscreenMSAA() const {
145 return supports_offscreen_msaa_;
146 }
147
148 bool CapabilitiesGLES::SupportsImplicitResolvingMSAA() const {
149 return supports_implicit_msaa_;
150 }
151
152 bool CapabilitiesGLES::SupportsSSBO() const {
153 return false;
154 }
155
156 bool CapabilitiesGLES::SupportsTextureToTextureBlits() const {
157 return false;
158 }
159
160 bool CapabilitiesGLES::SupportsFramebufferFetch() const {
161 return supports_framebuffer_fetch_;
162 }
163
164 bool CapabilitiesGLES::SupportsCompute() const {
165 return false;
166 }
167
168 bool CapabilitiesGLES::SupportsComputeSubgroups() const {
169 return false;
170 }
171
172 bool CapabilitiesGLES::SupportsReadFromResolve() const {
173 return false;
174 }
175
176 bool CapabilitiesGLES::SupportsDecalSamplerAddressMode() const {
177 return supports_decal_sampler_address_mode_;
178 }
179
180 bool CapabilitiesGLES::SupportsDeviceTransientTextures() const {
181 return false;
182 }
183
184 PixelFormat CapabilitiesGLES::GetDefaultColorFormat() const {
185 return PixelFormat::kR8G8B8A8UNormInt;
186 }
187
188 PixelFormat CapabilitiesGLES::GetDefaultStencilFormat() const {
189 return PixelFormat::kS8UInt;
190 }
191
192 PixelFormat CapabilitiesGLES::GetDefaultDepthStencilFormat() const {
193 return PixelFormat::kD24UnormS8Uint;
194 }
195
196 bool CapabilitiesGLES::IsANGLE() const {
197 return is_angle_;
198 }
199
200 PixelFormat CapabilitiesGLES::GetDefaultGlyphAtlasFormat() const {
201 return default_glyph_atlas_format_;
202 }
203
204 } // namespace impeller
impeller::CapabilitiesGLES::max_vertex_attribs
size_t max_vertex_attribs
Definition: capabilities_gles.h:59
impeller::CapabilitiesGLES::max_viewport_dims
ISize max_viewport_dims
Definition: capabilities_gles.h:68
impeller::PixelFormat::kS8UInt
@ kS8UInt
impeller::CapabilitiesGLES::IsANGLE
bool IsANGLE() const
Definition: capabilities_gles.cc:196
impeller::kMultisampledRenderToTextureExt
static const constexpr char * kMultisampledRenderToTextureExt
Definition: capabilities_gles.cc:22
impeller::ShaderStage::kUnknown
@ kUnknown
impeller::PixelFormat::kA8UNormInt
@ kA8UNormInt
impeller::PixelFormat::kR8UNormInt
@ kR8UNormInt
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:160
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:192
impeller::CapabilitiesGLES::max_fragment_uniform_vectors
size_t max_fragment_uniform_vectors
Definition: capabilities_gles.h:44
impeller::CapabilitiesGLES::GetMaxTextureUnits
size_t GetMaxTextureUnits(ShaderStage stage) const
Definition: capabilities_gles.cc:131
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::CapabilitiesGLES::CapabilitiesGLES
CapabilitiesGLES(const ProcTableGLES &gl)
Definition: capabilities_gles.cc:25
formats.h
impeller::kFramebufferFetchExt
static const constexpr char * kFramebufferFetchExt
Definition: capabilities_gles.cc:13
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::CapabilitiesGLES::max_cube_map_texture_size
size_t max_cube_map_texture_size
Definition: capabilities_gles.h:41
impeller::CapabilitiesGLES::max_vertex_uniform_vectors
size_t max_vertex_uniform_vectors
Definition: capabilities_gles.h:65
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:148
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
impeller::TSize
Definition: size.h:19
impeller::CapabilitiesGLES::SupportsSSBO
bool SupportsSSBO() const override
Whether the context backend supports binding Shader Storage Buffer Objects (SSBOs) to pipelines.
Definition: capabilities_gles.cc:152
impeller::CapabilitiesGLES::max_combined_texture_image_units
size_t max_combined_texture_image_units
Definition: capabilities_gles.h:38
impeller::CapabilitiesGLES::SupportsDecalSamplerAddressMode
bool SupportsDecalSamplerAddressMode() const override
Whether the context backend supports SamplerAddressMode::Decal.
Definition: capabilities_gles.cc:176
impeller::CapabilitiesGLES::max_vertex_texture_image_units
size_t max_vertex_texture_image_units
Definition: capabilities_gles.h:62
impeller::CapabilitiesGLES::SupportsDeviceTransientTextures
bool SupportsDeviceTransientTextures() const override
Whether the context backend supports allocating StorageMode::kDeviceTransient (aka "memoryless") text...
Definition: capabilities_gles.cc:180
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:188
impeller::CapabilitiesGLES::max_texture_size
ISize max_texture_size
Definition: capabilities_gles.h:53
impeller::CapabilitiesGLES::max_texture_image_units
size_t max_texture_image_units
Definition: capabilities_gles.h:50
impeller::PixelFormat::kD24UnormS8Uint
@ kD24UnormS8Uint
impeller::ProcTableGLES
Definition: proc_table_gles.h:228
impeller::ShaderStage::kFragment
@ kFragment
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:156
impeller::CapabilitiesGLES::SupportsComputeSubgroups
bool SupportsComputeSubgroups() const override
Whether the context backend supports configuring ComputePass command subgroups.
Definition: capabilities_gles.cc:168
proc_table_gles.h
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:172
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:184
impeller::kNvidiaTextureBorderClampExt
static const constexpr char * kNvidiaTextureBorderClampExt
Definition: capabilities_gles.cc:18
impeller::CapabilitiesGLES::max_renderbuffer_size
size_t max_renderbuffer_size
Definition: capabilities_gles.h:47
impeller::CapabilitiesGLES::num_shader_binary_formats
size_t num_shader_binary_formats
Definition: capabilities_gles.h:74
impeller::ShaderStage::kVertex
@ kVertex
impeller::CapabilitiesGLES::SupportsCompute
bool SupportsCompute() const override
Whether the context backend supports ComputePass.
Definition: capabilities_gles.cc:164
impeller::ShaderStage::kCompute
@ kCompute
impeller::kTextureBorderClampExt
static const constexpr char * kTextureBorderClampExt
Definition: capabilities_gles.cc:16
impeller::CapabilitiesGLES::GetDefaultGlyphAtlasFormat
PixelFormat GetDefaultGlyphAtlasFormat() const override
Returns the default pixel format for the alpha bitmap glyph atlas.
Definition: capabilities_gles.cc:200
capabilities_gles.h
impeller::CapabilitiesGLES::num_compressed_texture_formats
size_t num_compressed_texture_formats
Definition: capabilities_gles.h:71
impeller
Definition: aiks_blend_unittests.cc:18
impeller::ProcTableGLES::GetDescription
const DescriptionGLES * GetDescription() const
Definition: proc_table_gles.cc:199
impeller::CapabilitiesGLES::SupportsOffscreenMSAA
bool SupportsOffscreenMSAA() const override
Whether the context backend supports attaching offscreen MSAA color/stencil textures.
Definition: capabilities_gles.cc:144
impeller::CapabilitiesGLES::max_varying_vectors
size_t max_varying_vectors
Definition: capabilities_gles.h:56