summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/rsdRuntimeStubs.cpp15
-rw-r--r--rsRuntime.h3
-rw-r--r--rsScript.cpp1
-rw-r--r--rsScript.h5
-rw-r--r--rsScriptC.cpp4
-rw-r--r--rsScriptC_Lib.cpp19
6 files changed, 38 insertions, 9 deletions
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp
index c728ca71..bc5c8922 100644
--- a/driver/rsdRuntimeStubs.cpp
+++ b/driver/rsdRuntimeStubs.cpp
@@ -439,8 +439,9 @@ void __attribute__((overloadable)) rsForEach(::rs_script script,
const void *usr,
const rs_script_call *call) {
Context *rsc = RsdCpuReference::getTlsContext();
+ const Script *sc = RsdCpuReference::getTlsScript();
rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p,
- (Allocation *)out.p, usr, 0, (RsScriptCall *)call);
+ (Allocation *)out.p, usr, 0, (RsScriptCall *)call, sc);
}
void __attribute__((overloadable)) rsForEach(::rs_script script,
@@ -448,16 +449,18 @@ void __attribute__((overloadable)) rsForEach(::rs_script script,
::rs_allocation out,
const void *usr) {
Context *rsc = RsdCpuReference::getTlsContext();
+ const Script *sc = RsdCpuReference::getTlsScript();
rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p, (Allocation *)out.p,
- usr, 0, nullptr);
+ usr, 0, nullptr, sc);
}
void __attribute__((overloadable)) rsForEach(::rs_script script,
::rs_allocation in,
::rs_allocation out) {
Context *rsc = RsdCpuReference::getTlsContext();
+ const Script *sc = RsdCpuReference::getTlsScript();
rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p, (Allocation *)out.p,
- nullptr, 0, nullptr);
+ nullptr, 0, nullptr, sc);
}
// These functions are only supported in 32-bit.
@@ -468,8 +471,9 @@ void __attribute__((overloadable)) rsForEach(::rs_script script,
const void *usr,
uint32_t usrLen) {
Context *rsc = RsdCpuReference::getTlsContext();
+ const Script *sc = RsdCpuReference::getTlsScript();
rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p, (Allocation *)out.p,
- usr, usrLen, nullptr);
+ usr, usrLen, nullptr, sc);
}
void __attribute__((overloadable)) rsForEach(::rs_script script,
@@ -479,8 +483,9 @@ void __attribute__((overloadable)) rsForEach(::rs_script script,
uint32_t usrLen,
const rs_script_call *call) {
Context *rsc = RsdCpuReference::getTlsContext();
+ const Script *sc = RsdCpuReference::getTlsScript();
rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p, (Allocation *)out.p,
- usr, usrLen, (RsScriptCall *)call);
+ usr, usrLen, (RsScriptCall *)call, sc);
}
#endif
diff --git a/rsRuntime.h b/rsRuntime.h
index 5a058830..de6ede36 100644
--- a/rsRuntime.h
+++ b/rsRuntime.h
@@ -159,7 +159,8 @@ void rsrForEach(Context *, Script *target,
Allocation *out,
const void *usr,
uint32_t usrBytes,
- const RsScriptCall *call);
+ const RsScriptCall *call,
+ const Script *callingScript);
//////////////////////////////////////////////////////////////////////////////
diff --git a/rsScript.cpp b/rsScript.cpp
index cb611afc..7ea9857b 100644
--- a/rsScript.cpp
+++ b/rsScript.cpp
@@ -28,6 +28,7 @@ Script::Script(Context *rsc) : ObjectBase(rsc) {
mTypes = nullptr;
mInitialized = false;
mHasObjectSlots = false;
+ mApiLevel = 0;
}
Script::~Script() {
diff --git a/rsScript.h b/rsScript.h
index 80bc622c..12de95c0 100644
--- a/rsScript.h
+++ b/rsScript.h
@@ -142,9 +142,14 @@ public:
}
virtual void callUpdateCacheObject(const Context *rsc, void *dstObj) const;
+ uint32_t getApiLevel() const {
+ return mApiLevel;
+ }
+
protected:
bool mInitialized;
bool mHasObjectSlots;
+ uint32_t mApiLevel;
ObjectBaseRef<Allocation> *mSlots;
ObjectBaseRef<const Type> *mTypes;
diff --git a/rsScriptC.cpp b/rsScriptC.cpp
index 4d791f79..e1685b91 100644
--- a/rsScriptC.cpp
+++ b/rsScriptC.cpp
@@ -310,6 +310,10 @@ bool ScriptC::runCompiler(Context *rsc,
sdkVersion = rsc->getTargetSdkVersion();
}
+ // Save off the sdkVersion, so that we can handle broken cases later.
+ // Bug 19734267
+ mApiLevel = sdkVersion;
+
if (BT) {
delete BT;
}
diff --git a/rsScriptC_Lib.cpp b/rsScriptC_Lib.cpp
index 628190d3..64040958 100644
--- a/rsScriptC_Lib.cpp
+++ b/rsScriptC_Lib.cpp
@@ -224,17 +224,30 @@ void rsrForEach(Context *rsc,
Script *target,
Allocation *in, Allocation *out,
const void *usr, uint32_t usrBytes,
- const RsScriptCall *call) {
+ const RsScriptCall *call,
+ const Script *callingScript) {
+
+ RsScriptCall c, *cptr = nullptr;
+ memset(&c, 0, sizeof(c));
+ if (call != nullptr) {
+ cptr = &c;
+ if (callingScript->getApiLevel() < 23) {
+ // Up to API 23, the structure was smaller and we need to zero extend
+ memcpy(&c, call, 7*4);
+ } else {
+ c = *call;
+ }
+ }
if (in == nullptr) {
target->runForEach(rsc, /* root slot */ 0, nullptr, 0, out, usr,
- usrBytes, call);
+ usrBytes, cptr);
} else {
const Allocation *ins[1] = {in};
target->runForEach(rsc, /* root slot */ 0, ins,
sizeof(ins) / sizeof(RsAllocation), out, usr,
- usrBytes, call);
+ usrBytes, cptr);
}
}