diff --git a/libs/rs/driver/rsdCore.cpp b/libs/rs/driver/rsdCore.cpp index b9348950d05a5..9b7990050be83 100644 --- a/libs/rs/driver/rsdCore.cpp +++ b/libs/rs/driver/rsdCore.cpp @@ -270,6 +270,9 @@ void SetPriority(const Context *rsc, int32_t priority) { for (uint32_t ct=0; ct < dc->mWorkers.mCount; ct++) { setpriority(PRIO_PROCESS, dc->mWorkers.mNativeThreadId[ct], priority); } + if (dc->mHasGraphics) { + rsdGLSetPriority(rsc, priority); + } } void Shutdown(Context *rsc) { diff --git a/libs/rs/driver/rsdCore.h b/libs/rs/driver/rsdCore.h index ce86d118a8cdd..3698fab79fc38 100644 --- a/libs/rs/driver/rsdCore.h +++ b/libs/rs/driver/rsdCore.h @@ -46,6 +46,7 @@ typedef struct ScriptTLSStructRec { typedef struct RsdHalRec { uint32_t version_major; uint32_t version_minor; + bool mHasGraphics; struct Workers { volatile int mRunningCount; diff --git a/libs/rs/driver/rsdGL.cpp b/libs/rs/driver/rsdGL.cpp index b53a68cf9efd2..80abb0e5779a6 100644 --- a/libs/rs/driver/rsdGL.cpp +++ b/libs/rs/driver/rsdGL.cpp @@ -359,6 +359,7 @@ bool rsdGLInit(const Context *rsc) { dc->gl.vertexArrayState = new RsdVertexArrayState(); dc->gl.vertexArrayState->init(dc->gl.gl.maxVertexAttribs); dc->gl.currentFrameBuffer = NULL; + dc->mHasGraphics = true; ALOGV("%p initGLThread end", rsc); rsc->setWatchdogGL(NULL, 0, NULL); @@ -419,6 +420,15 @@ void rsdGLSwap(const android::renderscript::Context *rsc) { RSD_CALL_GL(eglSwapBuffers, dc->gl.egl.display, dc->gl.egl.surface); } +void rsdGLSetPriority(const Context *rsc, int32_t priority) { + if (priority > 0) { + // Mark context as low priority. + ALOGV("low pri"); + } else { + ALOGV("normal pri"); + } +} + void rsdGLCheckError(const android::renderscript::Context *rsc, const char *msg, bool isFatal) { GLenum err = glGetError(); diff --git a/libs/rs/driver/rsdGL.h b/libs/rs/driver/rsdGL.h index fc33885d5362d..988a5dfde3fe1 100644 --- a/libs/rs/driver/rsdGL.h +++ b/libs/rs/driver/rsdGL.h @@ -82,6 +82,8 @@ bool rsdGLSetSurface(const android::renderscript::Context *rsc, void rsdGLSwap(const android::renderscript::Context *rsc); void rsdGLCheckError(const android::renderscript::Context *rsc, const char *msg, bool isFatal = false); +void rsdGLSetPriority(const android::renderscript::Context *rsc, + int32_t priority); #endif diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index ad2ff0ff0dac8..62b3c5ceb9cfe 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -347,6 +347,7 @@ void Context::setPriority(int32_t p) { #else setpriority(PRIO_PROCESS, mNativeThreadId, p); #endif + mHal.funcs.setPriority(this, mThreadPriority); } Context::Context() {