Skip to content

Commit 4ee6386

Browse files
committed
EGL: Add flag for bugfixes found via advanced blobcache usage
Test: libEGL_test, EGL_test Bug: b/351867582, b/380483358 Flag: com.android.graphics.egl.flags.multifile_blobcache_advanced_usage Change-Id: I08c8b2e1e255caead4333b69e0a94148a3b4f0b1
1 parent d71f586 commit 4ee6386

7 files changed

Lines changed: 51 additions & 2 deletions

File tree

opengl/libs/Android.bp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ ndk_library {
6363
unversioned_until: "current",
6464
}
6565

66+
aconfig_declarations {
67+
name: "egl_flags",
68+
package: "com.android.graphics.egl.flags",
69+
container: "system",
70+
srcs: ["EGL/egl_flags.aconfig"],
71+
}
72+
73+
cc_aconfig_library {
74+
name: "libegl_flags",
75+
aconfig_declarations: "egl_flags",
76+
}
77+
6678
cc_defaults {
6779
name: "gl_libs_defaults",
6880
cflags: [
@@ -136,6 +148,7 @@ cc_library_static {
136148
],
137149
export_include_dirs: ["EGL"],
138150
shared_libs: [
151+
"libegl_flags",
139152
"libz",
140153
],
141154
}
@@ -166,6 +179,7 @@ cc_library_shared {
166179
"android.hardware.configstore@1.0",
167180
"android.hardware.configstore-utils",
168181
"libbase",
182+
"libegl_flags",
169183
"libhidlbase",
170184
"libnativebridge_lazy",
171185
"libnativeloader_lazy",
@@ -202,6 +216,7 @@ cc_test {
202216
"EGL/MultifileBlobCache_test.cpp",
203217
],
204218
shared_libs: [
219+
"libegl_flags",
205220
"libutils",
206221
"libz",
207222
],

opengl/libs/EGL/MultifileBlobCache.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838

3939
#include <utils/JenkinsHash.h>
4040

41+
#include <com_android_graphics_egl_flags.h>
42+
43+
using namespace com::android::graphics::egl;
44+
4145
using namespace std::literals;
4246

4347
constexpr uint32_t kMultifileMagic = 'MFB$';
@@ -80,8 +84,13 @@ MultifileBlobCache::MultifileBlobCache(size_t maxKeySize, size_t maxValueSize, s
8084
return;
8185
}
8286

83-
// Set the cache version, override if debug value set
87+
// Set the cache version
8488
mCacheVersion = kMultifileBlobCacheVersion;
89+
// Bump the version if we're using flagged features
90+
if (flags::multifile_blobcache_advanced_usage()) {
91+
mCacheVersion++;
92+
}
93+
// Override if debug value set
8594
int debugCacheVersion = base::GetIntProperty("debug.egl.blobcache.cache_version", -1);
8695
if (debugCacheVersion >= 0) {
8796
ALOGV("INIT: Using %u as cacheVersion instead of %u", debugCacheVersion, mCacheVersion);

opengl/libs/EGL/MultifileBlobCache.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232

3333
#include "FileBlobCache.h"
3434

35+
#include <com_android_graphics_egl_flags.h>
36+
37+
using namespace com::android::graphics::egl;
38+
3539
namespace android {
3640

3741
constexpr uint32_t kMultifileBlobCacheVersion = 2;

opengl/libs/EGL/MultifileBlobCache_test.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#include <fstream>
2626
#include <memory>
2727

28+
#include <com_android_graphics_egl_flags.h>
29+
30+
using namespace com::android::graphics::egl;
31+
2832
using namespace std::literals;
2933

3034
namespace android {
@@ -458,6 +462,8 @@ TEST_F(MultifileBlobCacheTest, MismatchedCacheVersionClears) {
458462
// Set one entry
459463
mMBC->set("abcd", 4, "efgh", 4);
460464

465+
uint32_t initialCacheVersion = mMBC->getCurrentCacheVersion();
466+
461467
// Close the cache so everything writes out
462468
mMBC->finish();
463469
mMBC.reset();
@@ -466,7 +472,7 @@ TEST_F(MultifileBlobCacheTest, MismatchedCacheVersionClears) {
466472
ASSERT_EQ(getCacheEntries().size(), 1);
467473

468474
// Set a debug cacheVersion
469-
std::string newCacheVersion = std::to_string(kMultifileBlobCacheVersion + 1);
475+
std::string newCacheVersion = std::to_string(initialCacheVersion + 1);
470476
ASSERT_TRUE(base::SetProperty("debug.egl.blobcache.cache_version", newCacheVersion.c_str()));
471477
ASSERT_TRUE(
472478
base::WaitForProperty("debug.egl.blobcache.cache_version", newCacheVersion.c_str()));

opengl/libs/EGL/egl_flags.aconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package: "com.android.graphics.egl.flags"
2+
container: "system"
3+
4+
flag {
5+
name: "multifile_blobcache_advanced_usage"
6+
namespace: "gpu"
7+
description: "This flag controls new behaviors to address bugs found via advanced usage"
8+
bug: "380483358"
9+
is_fixed_read_only: true
10+
metadata {
11+
purpose: PURPOSE_BUGFIX
12+
}
13+
}

opengl/libs/EGL/fuzzer/Android.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ cc_fuzz {
3737
],
3838

3939
shared_libs: [
40+
"libegl_flags",
4041
"libz",
4142
],
4243

opengl/tests/EGLTest/Android.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ cc_test {
2626
"android.hardware.configstore@1.0",
2727
"android.hardware.configstore-utils",
2828
"libEGL",
29+
"libegl_flags",
2930
"libbase",
3031
"libcutils",
3132
"libbinder",

0 commit comments

Comments
 (0)