Fix thread priorities.
Graphics ran a display priority. Compute should run at a lower
priority.
Change-Id: I72055eeb2b62813d3b1d17f2d8e863b178019c8f
diff --git a/rsContext.cpp b/rsContext.cpp
index e7ff33d..b63d01d 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -289,20 +289,11 @@
void * Context::threadProc(void *vrsc) {
Context *rsc = static_cast<Context *>(vrsc);
+
#ifndef ANDROID_RS_SERIALIZE
rsc->mNativeThreadId = gettid();
-#ifndef RS_COMPATIBILITY_LIB
- if (!rsc->isSynchronous()) {
- setpriority(PRIO_PROCESS, rsc->mNativeThreadId, ANDROID_PRIORITY_DISPLAY);
- }
- rsc->mThreadPriority = ANDROID_PRIORITY_DISPLAY;
-#else
- if (!rsc->isSynchronous()) {
- setpriority(PRIO_PROCESS, rsc->mNativeThreadId, -4);
- }
- rsc->mThreadPriority = -4;
-#endif
#endif //ANDROID_RS_SERIALIZE
+
rsc->props.mLogTimes = getProp("debug.rs.profile") != 0;
rsc->props.mLogScripts = getProp("debug.rs.script") != 0;
rsc->props.mLogObjects = getProp("debug.rs.object") != 0;
@@ -362,8 +353,11 @@
}
#endif
-
- rsc->mHal.funcs.setPriority(rsc, rsc->mThreadPriority);
+ if (!rsc->isSynchronous()) {
+ // Due to legacy we default to normal_graphics
+ // setPriority will make the adjustments as needed.
+ rsc->setPriority(RS_THREAD_PRIORITY_NORMAL_GRAPHICS);
+ }
#ifndef RS_COMPATIBILITY_LIB
if (rsc->mIsGraphicsContext) {
@@ -502,6 +496,23 @@
void Context::setPriority(int32_t p) {
+ switch (p) {
+ // The public API will always send NORMAL_GRAPHICS
+ // for normal, we adjust here
+ case RS_THREAD_PRIORITY_NORMAL_GRAPHICS:
+ if (mIsGraphicsContext) {
+ break;
+ } else {
+ if (mHal.flags & RS_CONTEXT_LOW_LATENCY) {
+ p = RS_THREAD_PRIORITY_LOW_LATENCY;
+ } else {
+ p = RS_THREAD_PRIORITY_NORMAL;
+ }
+ }
+ case RS_THREAD_PRIORITY_LOW:
+ break;
+ }
+
// Note: If we put this in the proper "background" policy
// the wallpapers can become completly unresponsive at times.
// This is probably not what we want for something the user is actively
diff --git a/rsInternalDefines.h b/rsInternalDefines.h
index 678e6c8..81c13b5 100644
--- a/rsInternalDefines.h
+++ b/rsInternalDefines.h
@@ -198,6 +198,13 @@
} RsFileIndexEntry;
+enum RsThreadPriorities {
+ RS_THREAD_PRIORITY_LOW = 15,
+ RS_THREAD_PRIORITY_NORMAL_GRAPHICS = -8,
+ RS_THREAD_PRIORITY_NORMAL = -1,
+ RS_THREAD_PRIORITY_LOW_LATENCY = -4
+};
+
// Structure for rs.spec functions