Skip to content

Commit 976ae27

Browse files
committed
Add support for handling a bitcode wrapper to librs.
BUG=5425905 Change-Id: I75676060703df6d9043b287fea900c4379455ee2
1 parent 335c4e6 commit 976ae27

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

libs/rs/rsScriptC.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#ifndef ANDROID_RS_SERIALIZE
2323
#include <bcinfo/BitcodeTranslator.h>
24+
#include <bcinfo/BitcodeWrapper.h>
2425
#endif
2526

2627
using namespace android;
@@ -196,7 +197,24 @@ bool ScriptC::runCompiler(Context *rsc,
196197

197198
//LOGE("runCompiler %p %p %p %p %p %i", rsc, this, resName, cacheDir, bitcode, bitcodeLen);
198199
#ifndef ANDROID_RS_SERIALIZE
199-
uint32_t sdkVersion = rsc->getTargetSdkVersion();
200+
uint32_t sdkVersion = 0;
201+
bcinfo::BitcodeWrapper bcWrapper((const char *)bitcode, bitcodeLen);
202+
if (!bcWrapper.unwrap()) {
203+
LOGE("Bitcode is not in proper container format (raw or wrapper)");
204+
return false;
205+
}
206+
207+
rsAssert(bcWrapper.getHeaderVersion() == 0);
208+
if (bcWrapper.getBCFileType() == bcinfo::BC_WRAPPER) {
209+
sdkVersion = bcWrapper.getTargetAPI();
210+
}
211+
212+
if (sdkVersion == 0) {
213+
// This signals that we didn't have a wrapper containing information
214+
// about the bitcode.
215+
sdkVersion = rsc->getTargetSdkVersion();
216+
}
217+
200218
if (BT) {
201219
delete BT;
202220
}

0 commit comments

Comments
 (0)