diff options
-rw-r--r-- | build.xml | 9 | ||||
-rw-r--r-- | nbproject/project.properties | 5 | ||||
-rw-r--r-- | resources/clImplCustomCode.c | 42 | ||||
-rw-r--r-- | resources/clImplCustomCode.java | 10 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLContext.java | 2 | ||||
-rw-r--r-- | test/com/jogamp/opencl/CLProgramTest.java | 1 | ||||
-rw-r--r-- | test/com/jogamp/opencl/LowLevelBindingTest.java | 1 | ||||
-rw-r--r-- | test/com/jogamp/opencl/gl/CLGLTest.java | 2 |
8 files changed, 52 insertions, 20 deletions
@@ -88,7 +88,7 @@ <target name="-post-compile" depends="c.compile.default" /> - <target name="-post-jar"> + <target name="-post-jar" depends="jar.natives"> <!-- TODO temporary codebase --> <property name="jnlp.codebase" value="http://people.fh-landshut.de/~mbien/jogamp/jocl/"/> @@ -99,15 +99,20 @@ </filterchain> </copy> + </target> + + <target name="jar.natives" unless="c.dont.compile"> + <jar basedir="${natives.jocl.dir}/${namespace}" excludes="*.xml" destfile="${dist.jar.dir}/jocl-natives-${os.and.arch}.jar" manifest="${basedir}/manifest.mf" /> </target> + <target name="c.compile.default" depends="gluegen.cpptasks.detect.os, gluegen.cpptasks.detect.compiler, jocl.c.compile, c.rename.lib.mingw" /> - <target name="jocl.c.compile" depends="c.setup.build"> + <target name="jocl.c.compile" depends="c.setup.build" unless="c.dont.compile"> <echo message=" - - - compiling JOCL natives - - - "/> <echo message="${compiler.cfg.id}"/> diff --git a/nbproject/project.properties b/nbproject/project.properties index ea1f7c80..dadb96be 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -109,4 +109,7 @@ static.binding=true #overwrite lib path for static linking #use only if static.binding is true #opencl.lib.dir=C:/Program Files (x86)/ATI Stream/lib/x86 -#opencl.lib.dir=C:/NVIDIAComputingSDK/OpenCL/common/lib/Win32
\ No newline at end of file +#opencl.lib.dir=C:/NVIDIAComputingSDK/OpenCL/common/lib/Win32 + +#disable the build build the native part of the bindings +#c.dont.compile=true diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c index 1314e7b8..678ad35d 100644 --- a/resources/clImplCustomCode.c +++ b/resources/clImplCustomCode.c @@ -47,7 +47,7 @@ void buildProgramCallback(cl_program id, void * object) { (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL); - (*env)->CallVoidMethod(env, obj, bcb_mid, (jlong)id); + (*env)->CallVoidMethod(env, obj, bcb_mid, (jlong)(intptr_t)id); (*env)->DeleteGlobalRef(env, obj); (*jvm)->DetachCurrentThread(jvm); @@ -83,12 +83,12 @@ void createContextCallback(const char * errinfo, const void * private_info, size */ JNIEXPORT jlong JNICALL Java_com_jogamp_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject _unused, - jobject props, jint props_byte_offset, jobject device_type, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset) { + jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset) { cl_context_properties* _props_ptr = NULL; - int32_t * _errcode_ptr = NULL; + cl_int * _errcode_ptr = NULL; cl_context _ctx = NULL; - void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data) = NULL; + void (*_pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data) = NULL; jobject globalCB = NULL; if (props != NULL) { @@ -99,13 +99,16 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject _errcode_ptr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset); } +/* if (cb != NULL) { pfn_notify = &createContextCallback; globalCB = (*env)->NewGlobalRef(env, cb); } +*/ - _ctx = clCreateContextFromType(_props_ptr, (uint64_t) device_type, pfn_notify, globalCB, (int32_t *) _errcode_ptr); + _ctx = clCreateContextFromType(_props_ptr, (uint64_t) device_type, _pfn_notify, globalCB, _errcode_ptr); +/* if(globalCB != NULL) { jlong *g = (*env)->GetPrimitiveArrayCritical(env, global, NULL); // if something went wrong @@ -117,6 +120,7 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject } (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0); } +*/ return (jlong) (intptr_t)_ctx; } @@ -136,10 +140,10 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContext0(JNIEnv *env, jobject _unused jobject props, jint props_byte_offset, jint numDevices, jobject deviceList, jint device_type_offset, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset) { cl_context_properties* _props_ptr = NULL; - int32_t * _errcode_ptr = NULL; - size_t * _deviceListPtr = NULL; + cl_int * _errcode_ptr = NULL; + cl_device_id * _deviceListPtr = NULL; cl_context _ctx = NULL; - void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data) = NULL; + void (*_pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data) = NULL; jobject globalCB = NULL; if (props != NULL) { @@ -152,13 +156,16 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContext0(JNIEnv *env, jobject _unused _errcode_ptr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset); } +/* if (cb != NULL) { - pfn_notify = &createContextCallback; + _pfn_notify = &createContextCallback; globalCB = (*env)->NewGlobalRef(env, cb); } +*/ - _ctx = clCreateContext(_props_ptr, numDevices, (cl_device_id *)_deviceListPtr, pfn_notify, globalCB, (int32_t *) _errcode_ptr); + _ctx = clCreateContext(_props_ptr, numDevices, _deviceListPtr, _pfn_notify, globalCB, _errcode_ptr); +/* if(globalCB != NULL) { jlong *g = (*env)->GetPrimitiveArrayCritical(env, global, NULL); // if something went wrong @@ -170,6 +177,7 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContext0(JNIEnv *env, jobject _unused } (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0); } +*/ return (jlong) (intptr_t)_ctx; } @@ -183,10 +191,12 @@ JNIEXPORT jint JNICALL Java_com_jogamp_opencl_impl_CLImpl_clReleaseContextImpl(JNIEnv *env, jobject _unused, jlong context, jlong global) { int32_t _res; _res = clReleaseContext((cl_context) (intptr_t) context); +/* // TODO deal with retains if (global != 0) { (*env)->DeleteGlobalRef(env, (jobject) global); } +*/ return _res; } @@ -207,8 +217,8 @@ Java_com_jogamp_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused, const char* _strchars_options = NULL; cl_int _res; - size_t * _deviceListPtr = NULL; - void (*pfn_notify)(cl_program, void *user_data) = NULL; + cl_device_id * _deviceListPtr = NULL; + void (*_pfn_notify)(cl_program, void *) = NULL; jobject globalCB = NULL; if (options != NULL) { @@ -224,17 +234,21 @@ Java_com_jogamp_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused, _deviceListPtr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, deviceList)) + device_type_offset); } +/* if (cb != NULL) { - pfn_notify = &buildProgramCallback; + _pfn_notify = &buildProgramCallback; globalCB = (*env)->NewGlobalRef(env, cb); } +*/ - _res = clBuildProgram((cl_program)program, (cl_uint)deviceCount, (cl_device_id *)_deviceListPtr, _strchars_options, pfn_notify, globalCB); + _res = clBuildProgram((cl_program)(intptr_t)program, (cl_uint)deviceCount, (cl_device_id *)_deviceListPtr, _strchars_options, _pfn_notify, globalCB); +/* // if something went wrong if(_res != CL_SUCCESS && globalCB != NULL) { (*env)->DeleteGlobalRef(env, globalCB); } +*/ if (options != NULL) { (*env)->ReleaseStringUTFChars(env, options, _strchars_options); diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java index d2993f96..4f9f4c2e 100644 --- a/resources/clImplCustomCode.java +++ b/resources/clImplCustomCode.java @@ -15,6 +15,9 @@ if(properties!=null && !properties.isDirect()) throw new RuntimeException("Argument \"properties\" was not a direct buffer"); + if(errcode_ret!=null && !errcode_ret.isDirect()) + throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); + long[] global = new long[1]; long ctx = this.clCreateContext0( properties!=null?properties.getBuffer():null, Buffers.getDirectBufferByteOffset(properties), @@ -28,7 +31,7 @@ } return ctx; } - private native long clCreateContext0(Object cl_context_properties, int props_offset, int numDevices, Object devices, int devices_offset, CLErrorHandler pfn_notify, long[] global, Object errcode_ret, int err_offset); + private native long clCreateContext0(Object cl_context_properties, int props_offset, int numDevices, Object devices, int devices_offset, Object pfn_notify, long[] global, Object errcode_ret, int err_offset); public long clCreateContextFromType(PointerBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { @@ -36,6 +39,9 @@ if(properties!=null && !properties.isDirect()) throw new RuntimeException("Argument \"properties\" was not a direct buffer"); + if(errcode_ret!=null && !errcode_ret.isDirect()) + throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); + long[] global = new long[1]; long ctx = this.clCreateContextFromType0( properties!=null?properties.getBuffer():null, Buffers.getDirectBufferByteOffset(properties), @@ -48,7 +54,7 @@ } return ctx; } - private native long clCreateContextFromType0(Object properties, int props_offset, long device_type, CLErrorHandler pfn_notify, long[] global, Object errcode_ret, int err_offset); + private native long clCreateContextFromType0(Object properties, int props_offset, long device_type, Object pfn_notify, long[] global, Object errcode_ret, int err_offset); public int clReleaseContext(long context) { diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index c904a37c..b200e3a5 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -159,7 +159,7 @@ public class CLContext extends CLObject implements CLResource { protected static long createContextFromType(CLErrorHandler handler, PointerBuffer properties, long deviceType) { - IntBuffer status = IntBuffer.allocate(1); + IntBuffer status = newDirectIntBuffer(1); long context = CLPlatform.getLowLevelCLInterface().clCreateContextFromType(properties, deviceType, handler, status); checkForError(status.get(), "can not create CL context"); diff --git a/test/com/jogamp/opencl/CLProgramTest.java b/test/com/jogamp/opencl/CLProgramTest.java index ec238fb5..b25230f8 100644 --- a/test/com/jogamp/opencl/CLProgramTest.java +++ b/test/com/jogamp/opencl/CLProgramTest.java @@ -203,6 +203,7 @@ public class CLProgramTest { }; builder.setProgram(program).build(buildCallback); + countdown.countDown(); // TODO remove if callbacks are enabled again countdown.await(); } diff --git a/test/com/jogamp/opencl/LowLevelBindingTest.java b/test/com/jogamp/opencl/LowLevelBindingTest.java index 2d6ea08f..9e4082aa 100644 --- a/test/com/jogamp/opencl/LowLevelBindingTest.java +++ b/test/com/jogamp/opencl/LowLevelBindingTest.java @@ -264,6 +264,7 @@ public class LowLevelBindingTest { // Build the program ret = cl.clBuildProgram(program, 0, null, null, callback); + latch.countDown(); // TODO remove if callbacks are enabled again checkError("on clBuildProgram", ret); out.println("waiting for program to build..."); diff --git a/test/com/jogamp/opencl/gl/CLGLTest.java b/test/com/jogamp/opencl/gl/CLGLTest.java index 278206cf..c91ac439 100644 --- a/test/com/jogamp/opencl/gl/CLGLTest.java +++ b/test/com/jogamp/opencl/gl/CLGLTest.java @@ -76,6 +76,8 @@ public class CLGLTest { if(device == null) { out.println("Aborting test: no GLCL capable devices found."); return; + }else{ + out.println("isGLMemorySharingSupported==true on: \n "+device); } CLContext context = CLGLContext.create(glcontext, device); |