diff options
author | 2011-11-23 13:58:13 -0800 | |
---|---|---|
committer | 2011-11-23 13:58:13 -0800 | |
commit | e7d17220be8e20523ffd1c9855f3d389d9ef22ee (patch) | |
tree | ef52f95323ad3333cc239fa082dccb7195e6d23a | |
parent | 08e74ba8b05573d0acddc51d09a2554b29a62dbc (diff) | |
parent | 09ee7c80eabe0d92119ea0ffff949109602b5833 (diff) |
Merge "Add support for handling a bitcode wrapper to librs."
-rw-r--r-- | libs/rs/rsScriptC.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index a5b1902765bc..ce3c643c32a3 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -21,6 +21,7 @@ #ifndef ANDROID_RS_SERIALIZE #include <bcinfo/BitcodeTranslator.h> +#include <bcinfo/BitcodeWrapper.h> #endif using namespace android; @@ -198,7 +199,24 @@ bool ScriptC::runCompiler(Context *rsc, //LOGE("runCompiler %p %p %p %p %p %i", rsc, this, resName, cacheDir, bitcode, bitcodeLen); #ifndef ANDROID_RS_SERIALIZE - uint32_t sdkVersion = rsc->getTargetSdkVersion(); + uint32_t sdkVersion = 0; + bcinfo::BitcodeWrapper bcWrapper((const char *)bitcode, bitcodeLen); + if (!bcWrapper.unwrap()) { + LOGE("Bitcode is not in proper container format (raw or wrapper)"); + return false; + } + + rsAssert(bcWrapper.getHeaderVersion() == 0); + if (bcWrapper.getBCFileType() == bcinfo::BC_WRAPPER) { + sdkVersion = bcWrapper.getTargetAPI(); + } + + if (sdkVersion == 0) { + // This signals that we didn't have a wrapper containing information + // about the bitcode. + sdkVersion = rsc->getTargetSdkVersion(); + } + if (BT) { delete BT; } |