diff options
author | Lingfeng Yang <lfy@google.com> | 2021-05-14 16:22:00 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-14 16:22:00 +0000 |
commit | d89c80516d9933c861909831c6c07f2446574314 (patch) | |
tree | 13a59893f840ddee2f4524c2479e3d7d61db0a3f | |
parent | adb414a2d1a047bcaec3e1134dd9f078709d0728 (diff) | |
parent | 43539203d10397ce2a0ca8f600975b95d93e12d4 (diff) | |
download | goldfish-opengl-d89c80516d9933c861909831c6c07f2446574314.tar.gz |
Fix missed case for replacing samplerExternalOES strings am: 1736cdf43c am: 119cb3376e am: 43539203d1
Original change: https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/1707469
Change-Id: I33a1a22d526efc3779aa9ef19352ab13c543aa9e
-rwxr-xr-x | system/GLESv2_enc/GL2Encoder.cpp | 57 |
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); + } } } |