diff options
| author | Stephen Hines <srhines@google.com> | 2013-06-05 17:18:04 -0700 |
|---|---|---|
| committer | Stephen Hines <srhines@google.com> | 2013-06-05 17:59:20 -0700 |
| commit | ba17ae494add84056bbf3275b68e40e62a643db0 (patch) | |
| tree | ae23d73fa0365fe62f5bf18caaf49d9c46e8b294 /cpu_ref/rsCpuScript.cpp | |
| parent | 582b3646d6634f74a13828cceb1414823c18e66f (diff) | |
Switch to separate build/load steps for Scripts.
Bug: 7342767
Change-Id: I94f81cb4dc917dd2cfc10c7718e9263454571db4
Diffstat (limited to 'cpu_ref/rsCpuScript.cpp')
| -rw-r--r-- | cpu_ref/rsCpuScript.cpp | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp index 50a536aa..4ba60d32 100644 --- a/cpu_ref/rsCpuScript.cpp +++ b/cpu_ref/rsCpuScript.cpp @@ -38,8 +38,35 @@ #include <bcc/Renderscript/RSCompilerDriver.h> #include <bcc/Renderscript/RSExecutable.h> #include <bcc/Renderscript/RSInfo.h> + #include <cutils/properties.h> #endif +#ifndef RS_COMPATIBILITY_LIB +namespace { +static bool is_force_recompile() { +#ifdef RS_SERVER + return false; +#else + char buf[PROPERTY_VALUE_MAX]; + + // Re-compile if floating point precision has been overridden. + property_get("debug.rs.precision", buf, ""); + if (buf[0] != '\0') { + return true; + } + + // Re-compile if debug.rs.forcerecompile is set. + property_get("debug.rs.forcerecompile", buf, "0"); + if ((::strcmp(buf, "1") == 0) || (::strcmp(buf, "true") == 0)) { + return true; + } else { + return false; + } +#endif // RS_SERVER +} +} // namespace +#endif // !defined(RS_COMPATIBILITY_LIB) + namespace android { namespace renderscript { @@ -121,7 +148,7 @@ bool RsdCpuScriptImpl::init(char const *resName, char const *cacheDir, mCtx->lockMutex(); #ifndef RS_COMPATIBILITY_LIB - bcc::RSExecutable *exec; + bcc::RSExecutable *exec = NULL; mCompilerContext = NULL; mCompilerDriver = NULL; @@ -161,10 +188,26 @@ bool RsdCpuScriptImpl::init(char const *resName, char const *cacheDir, // Use the libclcore_debug.bc instead of the default library. core_lib = bcc::RSInfo::LibCLCoreDebugPath; mCompilerDriver->setDebugContext(true); + // Skip the cache lookup + } else if (!is_force_recompile()) { + // Attempt to just load the script from cache first if we can. + exec = mCompilerDriver->loadScript(cacheDir, resName, + (const char *)bitcode, bitcodeSize); + } + + // TODO(srhines): This is being refactored, but it simply wraps the + // build (compile) and load steps together. + if (exec == NULL) { + bool built = mCompilerDriver->build(*mCompilerContext, cacheDir, + resName, (const char *)bitcode, + bitcodeSize, core_lib, + mCtx->getLinkRuntimeCallback()); + if (built) { + exec = mCompilerDriver->loadScript(cacheDir, resName, + (const char *)bitcode, + bitcodeSize); + } } - exec = mCompilerDriver->build(*mCompilerContext, cacheDir, resName, - (const char *)bitcode, bitcodeSize, core_lib, - mCtx->getLinkRuntimeCallback()); if (exec == NULL) { ALOGE("bcc: FAILS to prepare executable for '%s'", resName); |
