aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLingfeng Yang <lfy@google.com>2021-05-14 16:05:04 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-05-14 16:05:04 +0000
commit43539203d10397ce2a0ca8f600975b95d93e12d4 (patch)
treed66236388922f3d051444ce966c4a00c6844a66a
parent07e2149fa1823ad742c13f266f5615f15c7ff577 (diff)
parent119cb3376e9439f254db057caef586832c3dbd1f (diff)
downloadgoldfish-opengl-43539203d10397ce2a0ca8f600975b95d93e12d4.tar.gz
Fix missed case for replacing samplerExternalOES strings am: 1736cdf43c am: 119cb3376e
Original change: https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/1707469 Change-Id: I8ed48e684194ba26da99834f88e16b1026a39018
-rwxr-xr-xsystem/GLESv2_enc/GL2Encoder.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp
index 4640e706..4a90795f 100755
--- a/system/GLESv2_enc/GL2Encoder.cpp
+++ b/system/GLESv2_enc/GL2Encoder.cpp
@@ -1673,6 +1673,7 @@ GLint * GL2Encoder::getCompressedTextureFormats()
// Replace uses of samplerExternalOES with sampler2D, recording the names of
// modified shaders in data. Also remove
// #extension GL_OES_EGL_image_external : require
+// #extension GL_OES_EGL_image_external_essl3 : require
// statements.
//
// This implementation assumes the input has already been pre-processed. If not,
@@ -1762,34 +1763,40 @@ static bool replaceExternalSamplerUniformDefinition(char* str, const std::string
}
char* sampler_start = c;
c += samplerExternalType.size();
- if (!isspace(*c) && *c != '\0') {
+ if (!isspace(*c) && *c != '\0' && *c != ';') {
continue;
+ } else {
+ // capture sampler name
+ while (isspace(*c) && *c != '\0') {
+ c++;
+ }
}
- // capture sampler name
- while (isspace(*c) && *c != '\0') {
- c++;
- }
- if (!isalpha(*c) && *c != '_') {
- // not an identifier
- return false;
- }
- char* name_start = c;
- do {
- c++;
- } while (isalnum(*c) || *c == '_');
-
- size_t len = (size_t)(c - name_start);
- data->samplerExternalNames.push_back(
- std::string(name_start, len));
-
- // We only need to perform a string replacement for the original
- // occurrence of samplerExternalOES if a #define was used.
- //
- // The important part was to record the name in
- // |data->samplerExternalNames|.
- if (samplerExternalType == STR_SAMPLER_EXTERNAL_OES) {
- memcpy(sampler_start, STR_SAMPLER2D_SPACE, sizeof(STR_SAMPLER2D_SPACE)-1);
+ if ((!isalpha(*c) && *c != '_') || *c == ';') {
+ // not an identifier, but might have some effect anyway.
+ if (samplerExternalType == STR_SAMPLER_EXTERNAL_OES) {
+ memcpy(sampler_start, STR_SAMPLER2D_SPACE, sizeof(STR_SAMPLER2D_SPACE)-1);
+ }
+ } else {
+ char* name_start = c;
+ do {
+ c++;
+ } while (isalnum(*c) || *c == '_');
+
+ size_t len = (size_t)(c - name_start);
+ if (len) {
+ data->samplerExternalNames.push_back(
+ std::string(name_start, len));
+ }
+
+ // We only need to perform a string replacement for the original
+ // occurrence of samplerExternalOES if a #define was used.
+ //
+ // The important part was to record the name in
+ // |data->samplerExternalNames|.
+ if (samplerExternalType == STR_SAMPLER_EXTERNAL_OES) {
+ memcpy(sampler_start, STR_SAMPLER2D_SPACE, sizeof(STR_SAMPLER2D_SPACE)-1);
+ }
}
}