summaryrefslogtreecommitdiff
path: root/rs/jni/android_renderscript_RenderScript.cpp
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2015-07-23 22:54:59 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-07-23 22:54:59 +0000
commitb3a1674a47f8671f0e35e63c8d2ba7b3b73abc59 (patch)
tree429f67bf06161984b061b00434ad7aaa839508d0 /rs/jni/android_renderscript_RenderScript.cpp
parent43250dd37f1843f1e0a8ff19aaae287a41f3094b (diff)
parented3ffe0fc86de016ff2b4231e2fcc74a6119f6c7 (diff)
am ed3ffe0f: am 6430812a: Merge "RenderScript: implement a Script entry point for calling a reduce-style kernel."
* commit 'ed3ffe0fc86de016ff2b4231e2fcc74a6119f6c7': RenderScript: implement a Script entry point for calling a reduce-style kernel.
Diffstat (limited to 'rs/jni/android_renderscript_RenderScript.cpp')
-rw-r--r--rs/jni/android_renderscript_RenderScript.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index 6a41699fc77e..0419d33c686c 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -1948,6 +1948,59 @@ nScriptForEach(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot,
}
}
+static void
+nScriptReduce(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot,
+ jlong ain, jlong aout, jintArray limits)
+{
+ if (kLogApi) {
+ ALOGD("nScriptReduce, con(%p), s(%p), slot(%i) ain(%" PRId64 ") aout(%" PRId64 ")", (RsContext)con, (void *)script, slot, ain, aout);
+ }
+
+ RsScriptCall sc, *sca = nullptr;
+ uint32_t sc_size = 0;
+
+ jint limit_len = 0;
+ jint *limit_ptr = nullptr;
+
+ // If the caller passed limits, reflect them in the RsScriptCall.
+ if (limits != nullptr) {
+ limit_len = _env->GetArrayLength(limits);
+ limit_ptr = _env->GetIntArrayElements(limits, nullptr);
+
+ // We expect to be passed an array [x1, x2] which specifies
+ // the sub-range for a 1-dimensional reduction.
+ assert(limit_len == 2);
+ UNUSED(limit_len); // As the assert might not be compiled.
+
+ sc.xStart = limit_ptr[0];
+ sc.xEnd = limit_ptr[1];
+ sc.yStart = 0;
+ sc.yEnd = 0;
+ sc.zStart = 0;
+ sc.zEnd = 0;
+ sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ sc.arrayStart = 0;
+ sc.arrayEnd = 0;
+ sc.array2Start = 0;
+ sc.array2End = 0;
+ sc.array3Start = 0;
+ sc.array3End = 0;
+ sc.array4Start = 0;
+ sc.array4End = 0;
+
+ sca = &sc;
+ sc_size = sizeof(sc);
+ }
+
+ rsScriptReduce((RsContext)con, (RsScript)script, slot,
+ (RsAllocation)ain, (RsAllocation)aout,
+ sca, sc_size);
+
+ if (limits != nullptr) {
+ _env->ReleaseIntArrayElements(limits, limit_ptr, JNI_ABORT);
+ }
+}
+
// -----------------------------------
static jlong
@@ -2531,6 +2584,7 @@ static JNINativeMethod methods[] = {
{"rsnScriptInvokeV", "(JJI[B)V", (void*)nScriptInvokeV },
{"rsnScriptForEach", "(JJI[JJ[B[I)V", (void*)nScriptForEach },
+{"rsnScriptReduce", "(JJIJJ[I)V", (void*)nScriptReduce },
{"rsnScriptSetVarI", "(JJII)V", (void*)nScriptSetVarI },
{"rsnScriptGetVarI", "(JJI)I", (void*)nScriptGetVarI },