summaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-09-02 23:45:05 +0200
committerMichael Bien <[email protected]>2010-09-02 23:45:05 +0200
commitbc4e1521cc2ccc91a033998847dc35e1a8c8687b (patch)
treeebd2a6e94b69519afc5aed07ebf49b03b80fbaea /resources
parent048f09aafe49e4eaddfe25ec4b302268510bc27b (diff)
CLMemObjectDestructorCallback for HLB and LLB.
Diffstat (limited to 'resources')
-rw-r--r--resources/cl-common.cfg3
-rw-r--r--resources/cl-if.cfg9
-rw-r--r--resources/cl-impl.cfg3
-rw-r--r--resources/clImplCustomCode.c26
4 files changed, 33 insertions, 8 deletions
diff --git a/resources/cl-common.cfg b/resources/cl-common.cfg
index f9c32c84..fab403b5 100644
--- a/resources/cl-common.cfg
+++ b/resources/cl-common.cfg
@@ -106,6 +106,3 @@ TagNativeBinding true
# platform dependent extensions
Ignore .*APPLE.*
-
-# TODO implement custom callbacks if this makes sense
-Ignore clSetMemObjectDestructorCallback
diff --git a/resources/cl-if.cfg b/resources/cl-if.cfg
index b8deb126..f65a417b 100644
--- a/resources/cl-if.cfg
+++ b/resources/cl-if.cfg
@@ -8,6 +8,7 @@ Import java.nio.LongBuffer
Import com.jogamp.opencl.impl.CLImageFormatImpl
import com.jogamp.opencl.impl.BuildProgramCallback
import com.jogamp.opencl.impl.CLEventCallback
+import com.jogamp.opencl.impl.CLMemObjectDestructorCallback
ClassJavadoc CL /**
ClassJavadoc CL * Java bindings to OpenCL, the Open Computing Language.
@@ -36,7 +37,13 @@ CustomJavaCode CL public int clBuildProgram(long program, int deviceCount, Poin
Ignore clSetEventCallback
CustomJavaCode CL
-CustomJavaCode CL public int clSetEventCallback(long event, int type, CLEventCallback listener);
+CustomJavaCode CL /** Interface to C language function: <br> <code> int32_t {@native clSetEventCallback}(cl_event event, cl_int command_exec_callback_type, void (CL_CALLBACK *pfn_event_notify) (cl_event event, cl_int event_command_exec_status, void *user_data), void *user_data); </code> */
+CustomJavaCode CL public int clSetEventCallback(long event, int type, CLEventCallback cb);
+
+Ignore clSetMemObjectDestructorCallback
+CustomJavaCode CL
+CustomJavaCode CL /** Interface to C language function: <br> <code> int32_t {@native clSetMemObjectDestructorCallback}(cl_mem memobj, void (CL_CALLBACK *pfn_notify) (cl_mem memobj, void *user_data), void *user_data); </code> */
+CustomJavaCode CL public int clSetMemObjectDestructorCallback(long memObjID, CLMemObjectDestructorCallback cb);
Ignore clEnqueueNativeKernel
#TODO..
diff --git a/resources/cl-impl.cfg b/resources/cl-impl.cfg
index f3367eac..856c85cd 100644
--- a/resources/cl-impl.cfg
+++ b/resources/cl-impl.cfg
@@ -75,6 +75,9 @@ ForceProcAddressGen clReleaseContext
Ignore clSetEventCallback
ForceProcAddressGen clSetEventCallback
+Ignore clSetMemObjectDestructorCallback
+ForceProcAddressGen clSetMemObjectDestructorCallback
+
#take buffer capacity from input param 5
ReturnValueCapacity clEnqueueMapBuffer {5}
diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c
index bf4cf1c9..f0ff3651 100644
--- a/resources/clImplCustomCode.c
+++ b/resources/clImplCustomCode.c
@@ -29,7 +29,7 @@ JNI_OnLoad(JavaVM * _jvm, void *reserved) {
jclass buildCBClassID = (*env)->FindClass(env, "com/jogamp/opencl/impl/BuildProgramCallback");
jclass errorHandlerClassID = (*env)->FindClass(env, "com/jogamp/opencl/CLErrorHandler");
jclass eventCBClassID = (*env)->FindClass(env, "com/jogamp/opencl/impl/CLEventCallback");
- jclass memObjCBClassID = (*env)->FindClass(env, "com/jogamp/opencl/CLMemObjectDestructorCallback");
+ jclass memObjCBClassID = (*env)->FindClass(env, "com/jogamp/opencl/impl/CLMemObjectDestructorCallback");
// throws even more reflection Exceptions
// IDs are unique and do not change
@@ -43,7 +43,7 @@ JNI_OnLoad(JavaVM * _jvm, void *reserved) {
eventCB_mid = (*env)->GetMethodID(env, eventCBClassID, "eventStateChanged", "(JI)V");
}
if (memObjCBClassID != NULL) {
- memObjCB_mid = (*env)->GetMethodID(env, memObjCBClassID, "memoryDeallocated", "(Lcom/jogamp/opencl/CLMemory;)V");
+ memObjCB_mid = (*env)->GetMethodID(env, memObjCBClassID, "memoryDeallocated", "(J)V");
}
return JNI_VERSION_1_2;
@@ -98,7 +98,7 @@ CL_CALLBACK void eventCallback(cl_event event, cl_int status, void * object) {
(*jvm)->DetachCurrentThread(jvm);
}
-/*
+
CL_CALLBACK void memObjDestructorCallback(cl_mem mem, void * object) {
JNIEnv *env;
@@ -106,9 +106,12 @@ CL_CALLBACK void memObjDestructorCallback(cl_mem mem, void * object) {
(*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL);
+ (*env)->CallVoidMethod(env, obj, memObjCB_mid, mem);
+ (*env)->DeleteGlobalRef(env, obj);
+
(*jvm)->DetachCurrentThread(jvm);
}
-*/
+
/* Java->C glue code:
* Java package: com.jogamp.opencl.impl.CLImpl
@@ -391,3 +394,18 @@ Java_com_jogamp_opencl_impl_CLImpl_clSetEventCallback0(JNIEnv *env, jobject _unu
return _res;
}
+
+JNIEXPORT jint JNICALL
+Java_com_jogamp_opencl_impl_CLImpl_clSetMemObjectDestructorCallback0(JNIEnv *env, jobject _unused,
+ jlong mem, jobject listener, jlong procAddress) {
+
+ cl_mem _mem = mem;
+ cl_int _res;
+ typedef int32_t (*function)(cl_mem, void (*pfn_event_notify) (cl_mem, void *), void *);
+ function clSetMemObjectDestructorCallback = (function)(intptr_t) procAddress;
+
+ jobject cb = (*env)->NewGlobalRef(env, listener);
+ _res = (*clSetMemObjectDestructorCallback)(_mem, &memObjDestructorCallback, cb);
+
+ return _res;
+}