summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2018-04-04 23:07:35 +0200
committerJorim Jaggi <jjaggi@google.com>2018-04-06 12:12:07 +0000
commit767e25ed613201d93d293a4c8ead5a21c0fb2b22 (patch)
treef1285c54d4e411f0a9eaa55096a4025f7b9353c3 /libs
parentddeaefb546c15f26bf7d4372a0d3e000463c7a5e (diff)
downloadbase-767e25ed613201d93d293a4c8ead5a21c0fb2b22.tar.gz
Add ability to change context priority of RT GL context
Test: Use method, observe GPU preemption behavior Bug: 75985430 Change-Id: Idc08d37f8c95f52c5aab7edf09c0cbff72b8482d
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/Properties.cpp2
-rw-r--r--libs/hwui/Properties.h2
-rw-r--r--libs/hwui/renderthread/EglManager.cpp14
3 files changed, 16 insertions, 2 deletions
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index 1602b4b39c91..0a6c45beedf9 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -65,6 +65,8 @@ bool Properties::runningInEmulator = false;
bool Properties::debuggingEnabled = false;
bool Properties::isolatedProcess = false;
+int Properties::contextPriority = 0;
+
static int property_get_int(const char* key, int defaultValue) {
char buf[PROPERTY_VALUE_MAX] = {
'\0',
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index 81a36574a097..764c50259540 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -271,6 +271,8 @@ public:
ANDROID_API static bool debuggingEnabled;
ANDROID_API static bool isolatedProcess;
+ ANDROID_API static int contextPriority;
+
private:
static ProfileType sProfileType;
static bool sDisableProfileBars;
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index 5b87e1013baf..6e239e357cf6 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -82,6 +82,7 @@ static struct {
bool pixelFormatFloat = false;
bool glColorSpace = false;
bool scRGB = false;
+ bool contextPriority = false;
} EglExtensions;
EglManager::EglManager(RenderThread& thread)
@@ -168,6 +169,7 @@ void EglManager::initExtensions() {
#else
EglExtensions.scRGB = extensions.has("EGL_EXT_gl_colorspace_scrgb");
#endif
+ EglExtensions.contextPriority = extensions.has("EGL_IMG_context_priority");
}
bool EglManager::hasEglContext() {
@@ -247,10 +249,18 @@ void EglManager::loadConfigs() {
}
void EglManager::createContext() {
- EGLint attribs[] = {EGL_CONTEXT_CLIENT_VERSION, GLES_VERSION, EGL_NONE};
+ std::vector<EGLint> contextAttributes;
+ contextAttributes.reserve(5);
+ contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
+ contextAttributes.push_back(GLES_VERSION);
+ if (Properties::contextPriority != 0 && EglExtensions.contextPriority) {
+ contextAttributes.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG);
+ contextAttributes.push_back(Properties::contextPriority);
+ }
+ contextAttributes.push_back(EGL_NONE);
mEglContext = eglCreateContext(
mEglDisplay, EglExtensions.noConfigContext ? ((EGLConfig) nullptr) : mEglConfig,
- EGL_NO_CONTEXT, attribs);
+ EGL_NO_CONTEXT, contextAttributes.data());
LOG_ALWAYS_FATAL_IF(mEglContext == EGL_NO_CONTEXT, "Failed to create context, error = %s",
eglErrorString());
}