|
5 | 5 | #include "impeller/renderer/backend/gles/capabilities_gles.h" |
6 | 6 |
|
7 | 7 | #include <algorithm> |
| 8 | +#include <charconv> |
| 9 | +#include <string> |
8 | 10 |
|
| 11 | +#include "impeller/base/strings.h" |
9 | 12 | #include "impeller/core/formats.h" |
10 | 13 | #include "impeller/renderer/backend/gles/proc_table_gles.h" |
11 | 14 |
|
@@ -61,6 +64,33 @@ static const constexpr char* kAppleTextureMaxLevelExt = |
61 | 64 | static const constexpr char* kTextureFilterAnisotropicExt = |
62 | 65 | "GL_EXT_texture_filter_anisotropic"; |
63 | 66 |
|
| 67 | +static bool MaliDriverNeedsTextureUploadRebind(const std::string& version) { |
| 68 | + // Arm's version string includes a driver release, for example: |
| 69 | + // "OpenGL ES 3.2 v1.r18p0-01rel0...". If it is unavailable, retain the |
| 70 | + // workaround rather than assuming that the driver has been fixed. |
| 71 | + const auto marker = version.find(" v1.r"); |
| 72 | + if (marker == std::string::npos) { |
| 73 | + return true; |
| 74 | + } |
| 75 | + const char* end = version.data() + version.size(); |
| 76 | + unsigned int release = 0; |
| 77 | + const auto release_result = |
| 78 | + std::from_chars(version.data() + marker + 5, end, release); |
| 79 | + if (release_result.ec != std::errc{} || release_result.ptr == end || |
| 80 | + *release_result.ptr != 'p') { |
| 81 | + return true; |
| 82 | + } |
| 83 | + unsigned int patch = 0; |
| 84 | + const auto patch_result = std::from_chars(release_result.ptr + 1, end, patch); |
| 85 | + if (patch_result.ec != std::errc{} || |
| 86 | + (patch_result.ptr != end && *patch_result.ptr != '-')) { |
| 87 | + return true; |
| 88 | + } |
| 89 | + // Arm erratum EN_ID 1,792,661 affects Bifrost/Valhall r17p0-r23p0 and was |
| 90 | + // fixed in r24p0. OEM backports within that range cannot be detected. |
| 91 | + return release >= 17 && release < 24; |
| 92 | +} |
| 93 | + |
64 | 94 | CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) { |
65 | 95 | { |
66 | 96 | GLint value = 0; |
@@ -179,6 +209,11 @@ CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) { |
179 | 209 | } |
180 | 210 | is_es_ = desc->IsES(); |
181 | 211 | is_angle_ = desc->IsANGLE(); |
| 212 | + needs_texture_upload_rebind_ = |
| 213 | + is_es_ && !is_angle_ && |
| 214 | + (HasPrefix(desc->GetRenderer(), "Mali-G") || |
| 215 | + HasPrefix(desc->GetRenderer(), "Immortalis-G")) && |
| 216 | + MaliDriverNeedsTextureUploadRebind(desc->GetGlVersionString()); |
182 | 217 |
|
183 | 218 | // ETC2 and EAC are mandatory in OpenGL ES 3.0. BC and ASTC are gated behind |
184 | 219 | // extensions and are not present on most mobile or desktop GLES. The whole BC |
@@ -231,6 +266,10 @@ CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) { |
231 | 266 | } |
232 | 267 | } |
233 | 268 |
|
| 269 | +bool CapabilitiesGLES::NeedsTextureUploadRebind() const { |
| 270 | + return needs_texture_upload_rebind_; |
| 271 | +} |
| 272 | + |
234 | 273 | bool CapabilitiesGLES::IsES() const { |
235 | 274 | return is_es_; |
236 | 275 | } |
|
0 commit comments