diff options
author | Sven Gothel <[email protected]> | 2013-10-19 06:47:48 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-19 06:47:48 +0200 |
commit | 6be41a8e457ec2881f4ce351395ba84748a737b6 (patch) | |
tree | 057311ecf74b576f0dd5187f8d44e507ff2cc07e /resources/clImplCustomCode.c | |
parent | 412dd81be138c49f8c683f9d350aa16322605281 (diff) |
Bug 773 - Device specific JOCL dynamic library look-up on Android - Part 1/2
Use DynamicLibraryBundleInfo w/ alternative native library names,
drop manual coding of loading and binding, i.e. JOCLJNILibLoader.
After trying opencl native libs (and failing), try GL libs ..
We use a manual impl. to CL's 'clGetExtensionFunctionAddress' similar to JOAL, JOGL ...
Diffstat (limited to 'resources/clImplCustomCode.c')
-rw-r--r-- | resources/clImplCustomCode.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c index 4a43ae3b..751f819b 100644 --- a/resources/clImplCustomCode.c +++ b/resources/clImplCustomCode.c @@ -112,6 +112,30 @@ CL_CALLBACK void memObjDestructorCallback(cl_mem mem, void * object) { (*jvm)->DetachCurrentThread(jvm); } +// extern CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddress(const char * /* func_name */) CL_API_SUFFIX__VERSION_1_0; + +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); + _local_LPCLGETPROCADDRESS ptr_clGetExtensionFunctionAddress; + const char* _strchars_fname = NULL; + void* _res; + if ( NULL != fname ) { + _strchars_fname = (*env)->GetStringUTFChars(env, fname, (jboolean*)NULL); + if ( NULL == _strchars_fname ) { + (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), + "Failed to get UTF-8 chars for argument \"fname\" in native dispatcher for \"dispatch_clGetExtensionFunctionAddress\""); + return 0; + } + } + ptr_clGetExtensionFunctionAddress = (_local_LPCLGETPROCADDRESS) (intptr_t) procAddress; + assert(ptr_clGetExtensionFunctionAddress != NULL); + _res = (* ptr_clGetExtensionFunctionAddress) ((char *) _strchars_fname); + if ( NULL != fname ) { + (*env)->ReleaseStringUTFChars(env, fname, _strchars_fname); + } + return (jlong) (intptr_t) _res; +} /* Java->C glue code: * Java package: com.jogamp.opencl.impl.CLImpl |