Enable IMG_context_priority depending on availability
The config value from the config store can still be used to
override it.
Test: Enable gpu completion tracing, observe how SF preempts other
GPU drawing
Bug: 64674361
Change-Id: Id2f6f11019c2e6cae078fb9e64e3d9d72e42533c
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
index 179b790..22016ed 100644
--- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
@@ -27,6 +27,12 @@
#include <SurfaceFlinger.h>
#include <vector>
+#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
+#include <configstore/Utils.h>
+
+using namespace android::hardware::configstore;
+using namespace android::hardware::configstore::V1_0;
+
extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name);
// ---------------------------------------------------------------------------
@@ -70,13 +76,11 @@
contextAttributes.reserve(6);
contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
contextAttributes.push_back(contextClientVersion);
-#ifdef EGL_IMG_context_priority
- if (SurfaceFlinger::useContextPriority) {
+ bool useContextPriority = overrideUseContextPriorityFromConfig(extensions.hasContextPriority());
+ if (useContextPriority) {
contextAttributes.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG);
contextAttributes.push_back(EGL_CONTEXT_PRIORITY_HIGH_IMG);
}
-#endif
- contextAttributes.push_back(EGL_NONE);
contextAttributes.push_back(EGL_NONE);
EGLContext ctxt = eglCreateContext(display, config, nullptr, contextAttributes.data());
@@ -131,6 +135,18 @@
return engine;
}
+bool RenderEngine::overrideUseContextPriorityFromConfig(bool useContextPriority) {
+ OptionalBool ret;
+ ISurfaceFlingerConfigs::getService()->useContextPriority([&ret](OptionalBool b) {
+ ret = b;
+ });
+ if (ret.specified) {
+ return ret.value;
+ } else {
+ return useContextPriority;
+ }
+}
+
RenderEngine::RenderEngine()
: mEGLDisplay(EGL_NO_DISPLAY), mEGLConfig(nullptr), mEGLContext(EGL_NO_CONTEXT) {}