From 569726132f622e290bebc5d40c96f8115dbcb5da Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Feb 2014 02:30:52 +0100 Subject: Fix Bug 920 - JOCL does not work on windows with 32 bit vm (1/2) The 'clGetExtensionFunctionAddress' function pointer declaration was faulty, i.e. using CL_API_ENTRY instead of CL_API_CALL. CL_API_CALL on windows is defined as '__stdcall' which impacts Window 32bit platforms. Fixed same issue w/: - clCreateContext - clBuildProgram Same issue occurs with _all_ gluegen generated native function wrappers, i.e. CL_API_CALL is missing in the function declarations! I will follow-up w/ this fix in a bit .. --- make/config/clImplCustomCode.c | 8 ++++---- make/scripts/tests-win.bat | 14 +++++++++++++- make/scripts/tests.sh | 10 +++++++--- .../jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java | 4 ++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/make/config/clImplCustomCode.c b/make/config/clImplCustomCode.c index 751f819b..6a5da4f0 100644 --- a/make/config/clImplCustomCode.c +++ b/make/config/clImplCustomCode.c @@ -116,7 +116,7 @@ CL_CALLBACK void memObjDestructorCallback(cl_mem mem, void * object) { JNIEXPORT jlong JNICALL Java_com_jogamp_opencl_llb_impl_CLAbstractImpl_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) { - typedef void* (CL_API_ENTRY*_local_LPCLGETPROCADDRESS)(const char * fname); + typedef void* (CL_API_CALL * _local_LPCLGETPROCADDRESS)(const char * fname); _local_LPCLGETPROCADDRESS ptr_clGetExtensionFunctionAddress; const char* _strchars_fname = NULL; void* _res; @@ -130,7 +130,7 @@ Java_com_jogamp_opencl_llb_impl_CLAbstractImpl_dispatch_1clGetExtensionFunctionA } ptr_clGetExtensionFunctionAddress = (_local_LPCLGETPROCADDRESS) (intptr_t) procAddress; assert(ptr_clGetExtensionFunctionAddress != NULL); - _res = (* ptr_clGetExtensionFunctionAddress) ((char *) _strchars_fname); + _res = (* ptr_clGetExtensionFunctionAddress) (_strchars_fname); if ( NULL != fname ) { (*env)->ReleaseStringUTFChars(env, fname, _strchars_fname); } @@ -210,7 +210,7 @@ Java_com_jogamp_opencl_llb_impl_CLImpl_clCreateContext0(JNIEnv *env, jobject _un cccallback _pfn_notify = NULL; jobject globalCB = NULL; - typedef cl_context (*function)(cl_context_properties *, cl_uint, const cl_device_id *, void (*pfn_notify)(const char *, const void *, size_t, void *), void *, cl_int *); + typedef cl_context (CL_API_CALL * function)(cl_context_properties *, cl_uint, const cl_device_id *, void (*pfn_notify)(const char *, const void *, size_t, void *), void *, cl_int *); function clCreateContext = (function)(intptr_t) procAddress; if (props != NULL) { @@ -286,7 +286,7 @@ Java_com_jogamp_opencl_llb_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unu bpcallback _pfn_notify = NULL; jobject globalCB = NULL; - typedef cl_int (*function)(cl_program, cl_uint, const cl_device_id *, const char *, void (CL_CALLBACK *)(cl_program, void *), void *); + typedef cl_int (CL_API_CALL * function)(cl_program, cl_uint, const cl_device_id *, const char *, void (CL_CALLBACK *)(cl_program, void *), void *); function clBuildProgram = (function)(intptr_t)procAddress; if (options != NULL) { diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 583b5cde..ad4daf9a 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -1 +1,13 @@ -scripts\java-win.bat com.jogamp.opencl.JoclVersion %* +REM scripts\java-win.bat com.jogamp.opencl.JoclVersion %* + +scripts\java-win.bat com.jogamp.opencl.CLBufferTest %* +REM scripts\java-win.bat com.jogamp.opencl.CLCommandQueueTest %* +REM scripts\java-win.bat com.jogamp.opencl.CLExceptionTest %* +REM scripts\java-win.bat com.jogamp.opencl.CLImageTest %* +REM scripts\java-win.bat com.jogamp.opencl.CLProgramTest %* +REM scripts\java-win.bat com.jogamp.opencl.HighLevelBindingTest %* +REM scripts\java-win.bat com.jogamp.opencl.LowLevelBindingTest %* +REM scripts\java-win.bat com.jogamp.opencl.TestJoclVersion %* +REM scripts\java-win.bat com.jogamp.opencl.TestUtils %* +REM scripts\java-win.bat com.jogamp.opencl.gl.CLGLTest %* +REM scripts\java-win.bat com.jogamp.opencl.util.concurrent.CLMultiContextTest %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3b69eac0..bc718c4f 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -60,8 +60,12 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug=all" #D_ARGS="-Dnewt.debug=all" - #D_ARGS="-Djocl=all" + #D_ARGS="-Djocl.debug=all" + #D_ARGS="-Djogamp.debug=all -Djocl.debug=all" + #D_ARGS="-Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djocl.debug=all" + D_ARGS="-Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader" + #X_ARGS="-Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true" #X_ARGS="-verbose:jni" #X_ARGS="-Xrs" @@ -107,11 +111,11 @@ function testawt() { # # Version # -testnoawt com.jogamp.opencl.JoclVersion $* +#testnoawt com.jogamp.opencl.JoclVersion $* # # -#testnoawt com.jogamp.opencl.CLBufferTest $* +testnoawt com.jogamp.opencl.CLBufferTest $* #testnoawt com.jogamp.opencl.CLCommandQueueTest $* #testnoawt com.jogamp.opencl.CLExceptionTest $* #testnoawt com.jogamp.opencl.CLImageTest $* diff --git a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java index 36bc26f9..19d89fc1 100644 --- a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java +++ b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java @@ -135,12 +135,12 @@ public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInf private static int Impl_len = Impl_str.length(); @Override - public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) { + public final long toolGetProcAddress(final long toolGetProcAddressHandle, String funcName) { //FIXME workaround to fix a gluegen issue if( funcName.endsWith(Impl_str) ) { funcName = funcName.substring(0, funcName.length() - Impl_len); } - if(funcName.endsWith("KHR") || funcName.endsWith("EXT")) { + if( funcName.endsWith("KHR") || funcName.endsWith("EXT") ) { return CLImpl.clGetExtensionFunctionAddress(toolGetProcAddressHandle, funcName); } return 0; // on libs .. -- cgit v1.2.3