diff options
author | Joe Onorato <joeo@android.com> | 2009-09-23 16:37:36 -0700 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2009-09-23 17:26:07 -0700 |
commit | 9ac2c66f0171593113238635c6a7921c41215e77 (patch) | |
tree | 77b1468329a63d5bf1e98e7c6dce739a313afce9 /libs/rs | |
parent | 8799b96ea09d5fdd9904dd9de3002c0a9cd28fdc (diff) | |
download | frameworks_base-9ac2c66f0171593113238635c6a7921c41215e77.zip frameworks_base-9ac2c66f0171593113238635c6a7921c41215e77.tar.gz frameworks_base-9ac2c66f0171593113238635c6a7921c41215e77.tar.bz2 |
Make the renderscript timing logging available by setting debug.rs.profile=1
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/rsContext.cpp | 42 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 3 | ||||
-rw-r--r-- | libs/rs/rsThreadIO.cpp | 12 | ||||
-rw-r--r-- | libs/rs/rsUtils.h | 2 |
4 files changed, 35 insertions, 24 deletions
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index ab8d065..cc11ab2 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -20,12 +20,16 @@ #include <ui/FramebufferNativeWindow.h> #include <ui/EGLUtils.h> +#include <cutils/properties.h> + #include <GLES/gl.h> #include <GLES/glext.h> using namespace android; using namespace android::renderscript; +bool g_logTimes = -1; + pthread_key_t Context::gThreadTLSKey = 0; void Context::initEGL() @@ -113,9 +117,9 @@ bool Context::runScript(Script *s, uint32_t launchID) bool Context::runRootScript() { -#if RS_LOG_TIMES - timerSet(RS_TIMER_CLEAR_SWAP); -#endif + if (this->logTimes) { + timerSet(RS_TIMER_CLEAR_SWAP); + } rsAssert(mRootScript->mEnviroment.mIsRoot); eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth); @@ -136,9 +140,9 @@ bool Context::runRootScript() glClear(GL_COLOR_BUFFER_BIT); } -#if RS_LOG_TIMES - timerSet(RS_TIMER_SCRIPT); -#endif + if (this->logTimes) { + timerSet(RS_TIMER_SCRIPT); + } bool ret = runScript(mRootScript.get(), 0); return ret; } @@ -204,11 +208,19 @@ void Context::setupCheck() mVertex->setupGL(this, &mStateVertex); } +static bool get_log_times() +{ + char buf[PROPERTY_VALUE_MAX]; + property_get("debug.rs.profile", buf, "0"); + return 0 != strcmp(buf, "0"); +} void * Context::threadProc(void *vrsc) { Context *rsc = static_cast<Context *>(vrsc); + rsc->logTimes = get_log_times(); + rsc->initEGL(); ScriptTLSStruct *tlsStruct = new ScriptTLSStruct; @@ -240,16 +252,16 @@ void * Context::threadProc(void *vrsc) if (mDraw) { mDraw = rsc->runRootScript(); -#if RS_LOG_TIMES - rsc->timerSet(RS_TIMER_CLEAR_SWAP); -#endif + if (rsc->logTimes) { + rsc->timerSet(RS_TIMER_CLEAR_SWAP); + } eglSwapBuffers(rsc->mEGL.mDisplay, rsc->mEGL.mSurface); -#if RS_LOG_TIMES - rsc->timerFrame(); - rsc->timerSet(RS_TIMER_INTERNAL); - rsc->timerPrint(); - rsc->timerReset(); -#endif + if (rsc->logTimes) { + rsc->timerFrame(); + rsc->timerSet(RS_TIMER_INTERNAL); + rsc->timerPrint(); + rsc->timerReset(); + } } if (rsc->mObjDestroy.mNeedToEmpty) { rsc->objDestroyOOBRun(); diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 3e07f3e..1fb697a 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -143,6 +143,8 @@ public: bool checkVersion1_1() const {return (mGL.mMajorVersion > 1) || (mGL.mMinorVersion >= 1); } bool checkVersion2_0() const {return mGL.mMajorVersion >= 2; } + bool logTimes; + protected: Device *mDev; @@ -215,7 +217,6 @@ private: uint64_t mTimeLastFrame; }; - } } #endif diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp index db4bb81..4072f06 100644 --- a/libs/rs/rsThreadIO.cpp +++ b/libs/rs/rsThreadIO.cpp @@ -42,13 +42,13 @@ bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand) uint32_t cmdID = 0; uint32_t cmdSize = 0; ret = true; -#if RS_LOG_TIMES - con->timerSet(Context::RS_TIMER_IDLE); -#endif + if (con->logTimes) { + con->timerSet(Context::RS_TIMER_IDLE); + } const void * data = mToCore.get(&cmdID, &cmdSize); -#if RS_LOG_TIMES - con->timerSet(Context::RS_TIMER_INTERNAL); -#endif + if (con->logTimes) { + con->timerSet(Context::RS_TIMER_INTERNAL); + } waitForCommand = false; //LOGV("playCoreCommands 3 %i %i", cmdID, cmdSize); diff --git a/libs/rs/rsUtils.h b/libs/rs/rsUtils.h index ec928db..63d73a1 100644 --- a/libs/rs/rsUtils.h +++ b/libs/rs/rsUtils.h @@ -41,8 +41,6 @@ namespace renderscript { #define rsAssert(v) while(0) #endif -#define RS_LOG_TIMES 0 - template<typename T> T rsMin(T in1, T in2) { |