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