diff options
-rw-r--r-- | driver/rsdRuntimeStubs.cpp | 15 | ||||
-rw-r--r-- | rsRuntime.h | 3 | ||||
-rw-r--r-- | rsScriptC.cpp | 9 | ||||
-rw-r--r-- | rsScriptC_Lib.cpp | 19 |
4 files changed, 18 insertions, 28 deletions
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp index bc5c8922..c728ca71 100644 --- a/driver/rsdRuntimeStubs.cpp +++ b/driver/rsdRuntimeStubs.cpp @@ -439,9 +439,8 @@ 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, sc); + (Allocation *)out.p, usr, 0, (RsScriptCall *)call); } void __attribute__((overloadable)) rsForEach(::rs_script script, @@ -449,18 +448,16 @@ 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, sc); + usr, 0, nullptr); } 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, sc); + nullptr, 0, nullptr); } // These functions are only supported in 32-bit. @@ -471,9 +468,8 @@ 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, sc); + usr, usrLen, nullptr); } void __attribute__((overloadable)) rsForEach(::rs_script script, @@ -483,9 +479,8 @@ 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, sc); + usr, usrLen, (RsScriptCall *)call); } #endif diff --git a/rsRuntime.h b/rsRuntime.h index de6ede36..5a058830 100644 --- a/rsRuntime.h +++ b/rsRuntime.h @@ -159,8 +159,7 @@ void rsrForEach(Context *, Script *target, Allocation *out, const void *usr, uint32_t usrBytes, - const RsScriptCall *call, - const Script *callingScript); + const RsScriptCall *call); ////////////////////////////////////////////////////////////////////////////// diff --git a/rsScriptC.cpp b/rsScriptC.cpp index e1685b91..a24334e3 100644 --- a/rsScriptC.cpp +++ b/rsScriptC.cpp @@ -192,6 +192,15 @@ void ScriptC::runForEach(Context *rsc, const void * usr, size_t usrBytes, const RsScriptCall *sc) { + // Make a copy of RsScriptCall and zero out extra fields that are absent + // in API levels below 23. + RsScriptCall sc_copy; + if (sc != nullptr && getApiLevel() < 23) { + memset(&sc_copy, 0, sizeof(sc_copy)); + memcpy(&sc_copy, sc, 7*4); + sc = &sc_copy; + } + // Trace this function call. // To avoid overhead we only build the string if tracing is actually // enabled. diff --git a/rsScriptC_Lib.cpp b/rsScriptC_Lib.cpp index cc930211..c404bde9 100644 --- a/rsScriptC_Lib.cpp +++ b/rsScriptC_Lib.cpp @@ -238,30 +238,17 @@ void rsrForEach(Context *rsc, Script *target, Allocation *in, Allocation *out, const void *usr, uint32_t usrBytes, - 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; - } - } + const RsScriptCall *call) { if (in == nullptr) { target->runForEach(rsc, /* root slot */ 0, nullptr, 0, out, usr, - usrBytes, cptr); + usrBytes, call); } else { const Allocation *ins[1] = {in}; target->runForEach(rsc, /* root slot */ 0, ins, sizeof(ins) / sizeof(RsAllocation), out, usr, - usrBytes, cptr); + usrBytes, call); } } |