aboutsummaryrefslogtreecommitdiffstats
path: root/make/config
diff options
context:
space:
mode:
authorWade Walker <[email protected]>2015-09-07 14:46:52 -0500
committerWade Walker <[email protected]>2015-11-08 14:05:28 -0600
commite56a17d6d7780b8597c78ce50808c8da68d094b5 (patch)
treea37f9d5f351dd0b85844521ad7d6897fcecc062c /make/config
parent85dc2b1357470d2a51a69080d33aac442eae291f (diff)
Add OpenCL 1.2 and 2.0 headers and CLImpl classes
Added stub includes for OpenCL 1.2 and 2.0. Added new CLImpl versions for 1.2 and 2.0 to the build, but left them unused for now. The CL bindings used by JOCL are still generated from OpenCL 1.1, so the existing Java code will be able to stay mostly unchanged in the future.
Diffstat (limited to 'make/config')
-rw-r--r--make/config/cl-common.cfg25
-rw-r--r--make/config/cl-impl-12.cfg105
-rw-r--r--make/config/cl-impl-20.cfg105
-rw-r--r--make/config/cl-impl.cfg1
-rw-r--r--make/config/clImplCustomCode12.c328
-rw-r--r--make/config/clImplCustomCode12.java60
-rw-r--r--make/config/clImplCustomCode20.c328
-rw-r--r--make/config/clImplCustomCode20.java60
8 files changed, 1011 insertions, 1 deletions
diff --git a/make/config/cl-common.cfg b/make/config/cl-common.cfg
index 2310d2b5..bf08b025 100644
--- a/make/config/cl-common.cfg
+++ b/make/config/cl-common.cfg
@@ -1,5 +1,4 @@
JavaOutputDir gensrc/java
-NativeOutputDir gensrc/native/jocl
Package com.jogamp.opencl.llb
@@ -31,6 +30,9 @@ Ignore __GLsync
ArgumentIsString clCreateProgramWithSource 2
ArgumentIsString clBuildProgram 3
ArgumentIsString clCreateKernel 1
+ArgumentIsString clCompileProgram 3
+ArgumentIsString clCompileProgram 6
+ArgumentIsString clLinkProgram 3
#common ignore
Ignore clGetExtensionFunctionAddress
@@ -121,6 +123,27 @@ ClassJavadoc CLImageFormatImpl * Struct accessor for cl_image_format.
ClassJavadoc CLImageFormatImpl * @author Michael Bien, GlueGen, et al.
ClassJavadoc CLImageFormatImpl */
+#struct cl_image_desc
+RenameJavaType cl_image_desc CLImageDescImpl
+StructPackage cl_image_desc com.jogamp.opencl.llb.impl
+# ignore this field because it causes GlueGen to erroneously create JNI code
+IgnoreField CLImageDescImpl buffer
+
+#struct fields ([set|get]+FieldName())
+RenameJavaSymbol CLImageDescImpl.image_type imageType
+RenameJavaSymbol CLImageDescImpl.image_width imageWidth
+RenameJavaSymbol CLImageDescImpl.image_height imageHeight
+RenameJavaSymbol CLImageDescImpl.image_depth imageDepth
+RenameJavaSymbol CLImageDescImpl.image_array_size imageArraySize
+RenameJavaSymbol CLImageDescImpl.image_row_pitch imageRowPitch
+RenameJavaSymbol CLImageDescImpl.image_slice_pitch imageSlicePitch
+RenameJavaSymbol CLImageDescImpl.num_mip_levels numMipLevels
+RenameJavaSymbol CLImageDescImpl.num_samples numSamples
+
+ClassJavadoc CLImageDescImpl /**
+ClassJavadoc CLImageDescImpl * Struct accessor for cl_image_desc.
+ClassJavadoc CLImageDescImpl * @author Wade Walker, GlueGen, et al.
+ClassJavadoc CLImageDescImpl */
# Pick up on-line OpenCL doc and link it with the javadoc
TagNativeBinding true
diff --git a/make/config/cl-impl-12.cfg b/make/config/cl-impl-12.cfg
new file mode 100644
index 00000000..01b9ea28
--- /dev/null
+++ b/make/config/cl-impl-12.cfg
@@ -0,0 +1,105 @@
+Include cl-common.cfg
+NativeOutputDir gensrc/native/jocl12
+
+Style ImplOnly
+
+#imports for all generated java files
+Import com.jogamp.opencl.llb.gl.CLGL
+Import java.security.AccessController
+Import java.security.PrivilegedAction
+
+ClassJavadoc CLAbstractImpl12 /**
+ClassJavadoc CLAbstractImpl12 * Java bindings to OpenCL, the Open Computing Language (generated).
+ClassJavadoc CLAbstractImpl12 * @author Michael Bien, GlueGen, et al.
+ClassJavadoc CLAbstractImpl12 */
+
+ImplJavaClass CLAbstractImpl12
+AccessControl CLAbstractImpl12 PUBLIC_ABSTRACT
+Implements CLAbstractImpl12 CLGL
+
+LocalProcAddressCallingConvention __ALL__ CL_API_CALL
+
+EmitProcAddressTable true
+ProcAddressTableClassName CLProcAddressTable12
+GetProcAddressTableExpr addressTable
+ProcAddressNameExpr $UpperCase(arg)
+ForceProcAddressGen __ALL__
+
+#dynamic binding for OpenGL specific functions...
+#ForceProcAddressGen clGetGLContextInfoKHR
+#ForceProcAddressGen clCreateFromGLBuffer
+#ForceProcAddressGen clCreateFromGLRenderbuffer
+#ForceProcAddressGen clCreateFromGLTexture2D
+#ForceProcAddressGen clCreateFromGLTexture3D
+#ForceProcAddressGen clEnqueueAcquireGLObjects
+#ForceProcAddressGen clEnqueueReleaseGLObjects
+#ForceProcAddressGen clGetGLObjectInfo
+#ForceProcAddressGen clGetGLTextureInfo
+#ForceProcAddressGen clCreateEventFromGLsyncKHR
+#ForceProcAddressGen clIcdGetPlatformIDsKHR
+#ForceProcAddressGen clCreateSubBuffer
+#ForceProcAddressGen clCreateSubDevicesEXT
+#ForceProcAddressGen clCreateUserEvent
+#ForceProcAddressGen clEnqueueCopyBufferRect
+#ForceProcAddressGen clEnqueueReadBufferRect
+#ForceProcAddressGen clEnqueueWriteBufferRect
+#ForceProcAddressGen clReleaseDeviceEXT
+#ForceProcAddressGen clRetainDeviceEXT
+#ForceProcAddressGen clSetUserEventStatus
+
+#...or force all
+ForceProcAddressGen __ALL__
+
+#
+# extern CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddress(const char * /* func_name */) CL_API_SUFFIX__VERSION_1_0;
+#
+Ignore clGetExtensionFunctionAddress
+ForceProcAddressGen clGetExtensionFunctionAddress
+
+#append to generated c files
+CustomCCode #include <CL/cl.h>
+CustomCCode #include <CL/cl_ext.h>
+CustomCCode #include <CL/cl_gl.h>
+CustomCCode #include <GL/glcorearb.h>
+CustomCCode #include <inttypes.h>
+
+# implement manually via custom code
+Ignore clCreateContext
+ForceProcAddressGen clCreateContext
+
+Ignore clCreateContextFromType
+ForceProcAddressGen clCreateContextFromType
+
+Ignore clBuildProgram
+ForceProcAddressGen clBuildProgram
+
+Ignore clCompileProgram
+ForceProcAddressGen clCompileProgram
+
+Ignore clLinkProgram
+ForceProcAddressGen clLinkProgram
+
+Ignore clEnqueueNativeKernel
+ForceProcAddressGen clEnqueueNativeKernel
+
+Ignore clReleaseContext
+ForceProcAddressGen clReleaseContext
+
+Ignore clSetEventCallback
+ForceProcAddressGen clSetEventCallback
+
+Ignore clSetMemObjectDestructorCallback
+ForceProcAddressGen clSetMemObjectDestructorCallback
+
+#take buffer capacity from input param 5
+ReturnValueCapacity clEnqueueMapBuffer {5}
+
+#this one is more complicated, we have to calculate the capacity with custom code
+ManuallyImplement clEnqueueMapImage
+ForceProcAddressGen clEnqueueMapImage
+
+#include custom code
+IncludeAs CustomJavaCode CLAbstractImpl12 clImplCustomCode12.java
+ManualStaticInitCall CLAbstractImpl12
+IncludeAs CustomCCode clImplCustomCode12.c
+
diff --git a/make/config/cl-impl-20.cfg b/make/config/cl-impl-20.cfg
new file mode 100644
index 00000000..5b0a9125
--- /dev/null
+++ b/make/config/cl-impl-20.cfg
@@ -0,0 +1,105 @@
+Include cl-common.cfg
+NativeOutputDir gensrc/native/jocl20
+
+Style ImplOnly
+
+#imports for all generated java files
+Import com.jogamp.opencl.llb.gl.CLGL
+Import java.security.AccessController
+Import java.security.PrivilegedAction
+
+ClassJavadoc CLAbstractImpl20 /**
+ClassJavadoc CLAbstractImpl20 * Java bindings to OpenCL, the Open Computing Language (generated).
+ClassJavadoc CLAbstractImpl20 * @author Michael Bien, GlueGen, et al.
+ClassJavadoc CLAbstractImpl20 */
+
+ImplJavaClass CLAbstractImpl20
+AccessControl CLAbstractImpl20 PUBLIC_ABSTRACT
+Implements CLAbstractImpl20 CLGL
+
+LocalProcAddressCallingConvention __ALL__ CL_API_CALL
+
+EmitProcAddressTable true
+ProcAddressTableClassName CLProcAddressTable20
+GetProcAddressTableExpr addressTable
+ProcAddressNameExpr $UpperCase(arg)
+ForceProcAddressGen __ALL__
+
+#dynamic binding for OpenGL specific functions...
+#ForceProcAddressGen clGetGLContextInfoKHR
+#ForceProcAddressGen clCreateFromGLBuffer
+#ForceProcAddressGen clCreateFromGLRenderbuffer
+#ForceProcAddressGen clCreateFromGLTexture2D
+#ForceProcAddressGen clCreateFromGLTexture3D
+#ForceProcAddressGen clEnqueueAcquireGLObjects
+#ForceProcAddressGen clEnqueueReleaseGLObjects
+#ForceProcAddressGen clGetGLObjectInfo
+#ForceProcAddressGen clGetGLTextureInfo
+#ForceProcAddressGen clCreateEventFromGLsyncKHR
+#ForceProcAddressGen clIcdGetPlatformIDsKHR
+#ForceProcAddressGen clCreateSubBuffer
+#ForceProcAddressGen clCreateSubDevicesEXT
+#ForceProcAddressGen clCreateUserEvent
+#ForceProcAddressGen clEnqueueCopyBufferRect
+#ForceProcAddressGen clEnqueueReadBufferRect
+#ForceProcAddressGen clEnqueueWriteBufferRect
+#ForceProcAddressGen clReleaseDeviceEXT
+#ForceProcAddressGen clRetainDeviceEXT
+#ForceProcAddressGen clSetUserEventStatus
+
+#...or force all
+ForceProcAddressGen __ALL__
+
+#
+# extern CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddress(const char * /* func_name */) CL_API_SUFFIX__VERSION_1_0;
+#
+Ignore clGetExtensionFunctionAddress
+ForceProcAddressGen clGetExtensionFunctionAddress
+
+#append to generated c files
+CustomCCode #include <CL/cl.h>
+CustomCCode #include <CL/cl_ext.h>
+CustomCCode #include <CL/cl_gl.h>
+CustomCCode #include <GL/glcorearb.h>
+CustomCCode #include <inttypes.h>
+
+# implement manually via custom code
+Ignore clCreateContext
+ForceProcAddressGen clCreateContext
+
+Ignore clCreateContextFromType
+ForceProcAddressGen clCreateContextFromType
+
+Ignore clBuildProgram
+ForceProcAddressGen clBuildProgram
+
+Ignore clCompileProgram
+ForceProcAddressGen clCompileProgram
+
+Ignore clLinkProgram
+ForceProcAddressGen clLinkProgram
+
+Ignore clEnqueueNativeKernel
+ForceProcAddressGen clEnqueueNativeKernel
+
+Ignore clReleaseContext
+ForceProcAddressGen clReleaseContext
+
+Ignore clSetEventCallback
+ForceProcAddressGen clSetEventCallback
+
+Ignore clSetMemObjectDestructorCallback
+ForceProcAddressGen clSetMemObjectDestructorCallback
+
+#take buffer capacity from input param 5
+ReturnValueCapacity clEnqueueMapBuffer {5}
+
+#this one is more complicated, we have to calculate the capacity with custom code
+ManuallyImplement clEnqueueMapImage
+ForceProcAddressGen clEnqueueMapImage
+
+#include custom code
+IncludeAs CustomJavaCode CLAbstractImpl20 clImplCustomCode20.java
+ManualStaticInitCall CLAbstractImpl20
+IncludeAs CustomCCode clImplCustomCode20.c
+
diff --git a/make/config/cl-impl.cfg b/make/config/cl-impl.cfg
index d9423024..f7850662 100644
--- a/make/config/cl-impl.cfg
+++ b/make/config/cl-impl.cfg
@@ -1,4 +1,5 @@
Include cl-common.cfg
+NativeOutputDir gensrc/native/jocl11
Style ImplOnly
diff --git a/make/config/clImplCustomCode12.c b/make/config/clImplCustomCode12.c
new file mode 100644
index 00000000..bea531a1
--- /dev/null
+++ b/make/config/clImplCustomCode12.c
@@ -0,0 +1,328 @@
+// callbacks
+typedef void (CL_CALLBACK * cccallback)(const char *, const void *, size_t, void *);
+typedef void (CL_CALLBACK * bpcallback)(cl_program, void *);
+
+CL_CALLBACK void buildProgramCallback(cl_program id, void * object);
+CL_CALLBACK void createContextCallback(const char * errinfo, const void * private_info, size_t cb, void * object);
+CL_CALLBACK void eventCallback(cl_event event, cl_int status, void * object);
+CL_CALLBACK void memObjDestructorCallback(cl_mem mem, void * object);
+
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_opencl_llb_impl_CLAbstractImpl12_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) {
+ typedef void* (CL_API_CALL * _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) (_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
+ * Java method: long clCreateContextFromType(java.nio.IntBuffer props, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret)
+ * C function: cl_context clCreateContextFromType( const cl_context_properties * properties ,
+ * cl_device_type device_type ,
+ * void (CL_CALLBACK * pfn_notify )(const char *, const void *, size_t, void *),
+ * void * user_data ,
+ * cl_int * errcode_ret);
+ */
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl12_clCreateContextFromType0(JNIEnv *env, jobject _unused,
+ jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) {
+
+ cl_context_properties* _props_ptr = NULL;
+ cl_int * _errcode_ptr = NULL;
+ cl_context _ctx = NULL;
+ cccallback _pfn_notify = NULL;
+ jobject globalCB = NULL;
+
+ typedef cl_context (*function)(const cl_context_properties *, cl_device_type, void (*pfn_notify)(const char *, const void *, size_t, void *), void *, cl_int *);
+ function clCreateContextFromType = (function)(intptr_t) procAddress;
+
+ if (props != NULL) {
+ _props_ptr = (cl_context_properties*) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset);
+ }
+
+ if (errcode != NULL) {
+ _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, _errcode_ptr);
+
+ if(globalCB != NULL) {
+ jlong *g = (*env)->GetPrimitiveArrayCritical(env, global, NULL);
+ // if something went wrong
+ if(_ctx == NULL) {
+ g[0] = 0;
+ (*env)->DeleteGlobalRef(env, globalCB);
+ }else{
+ g[0] = (jlong)globalCB;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0);
+ }
+
+ return (jlong) (intptr_t)_ctx;
+}
+
+/*
+ * Entry point to C language function:
+ *extern CL_API_ENTRY cl_context CL_API_CALL
+ *clCreateContext(cl_context_properties * properties ,
+ * cl_uint num_devices ,
+ * const cl_device_id * devices ,
+ * void (*pfn_notify)(const char *, const void *, size_t, void *) pfn_notify ,
+ * void * user_data ,
+ * cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0;
+ */
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl12_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, jlong procAddress) {
+
+ cl_context_properties* _props_ptr = NULL;
+ cl_int * _errcode_ptr = NULL;
+ cl_device_id * _deviceListPtr = NULL;
+ cl_context _ctx = NULL;
+ cccallback _pfn_notify = NULL;
+ jobject globalCB = NULL;
+
+ 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) {
+ _props_ptr = (cl_context_properties*) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset);
+ }
+ if (deviceList != NULL) {
+ _deviceListPtr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, deviceList)) + device_type_offset);
+ }
+ if (errcode != NULL) {
+ _errcode_ptr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset);
+ }
+
+ if (cb != NULL) {
+ _pfn_notify = &createContextCallback;
+ globalCB = (*env)->NewGlobalRef(env, cb);
+ }
+
+ _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
+ if(_ctx == NULL) {
+ g[0] = 0;
+ (*env)->DeleteGlobalRef(env, globalCB);
+ }else{
+ g[0] = (jlong)globalCB;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0);
+ }
+
+ return (jlong) (intptr_t)_ctx;
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.opencl.impl.CLImpl
+ * Java method: int clReleaseContextImpl(long context)
+ * C function: int32_t clReleaseContextImpl(cl_context context);
+ */
+JNIEXPORT jint JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl12_clReleaseContextImpl(JNIEnv *env, jobject _unused, jlong context, jlong global, jlong procAddress) {
+
+ int32_t _res;
+ typedef int32_t (*function)(cl_context);
+ function clReleaseContext = (function)(intptr_t) procAddress;
+
+ _res = (*clReleaseContext)((cl_context) (intptr_t) context);
+ // TODO deal with retains
+ if (global != 0) {
+ (*env)->DeleteGlobalRef(env, (jobject) global);
+ }
+ return _res;
+}
+
+
+/**
+ * Entry point to C language function:
+ * extern CL_API_ENTRY cl_int CL_API_CALL
+ *clBuildProgram(cl_program program ,
+ * cl_uint num_devices ,
+ * const cl_device_id * device_list ,
+ * const char * options ,
+ * void (*pfn_notify)(cl_program program , void * user_data ),
+ * void * user_data ) CL_API_SUFFIX__VERSION_1_0;
+ */
+JNIEXPORT jint JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl12_clBuildProgram0(JNIEnv *env, jobject _unused,
+ jlong program, jint deviceCount, jobject deviceList, jint device_type_offset, jstring options, jobject cb, jlong procAddress) {
+
+ const char* _strchars_options = NULL;
+ cl_int _res;
+ cl_device_id * _deviceListPtr = NULL;
+ bpcallback _pfn_notify = NULL;
+ jobject globalCB = NULL;
+
+ 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) {
+ _strchars_options = (*env)->GetStringUTFChars(env, options, (jboolean*)NULL);
+ if (_strchars_options == NULL) {
+ (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"),
+ "Failed to get UTF-8 chars for argument \"options\" in native dispatcher for \"clBuildProgram\"");
+ return CL_FALSE;
+ }
+ }
+
+ if (deviceList != NULL) {
+ _deviceListPtr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, deviceList)) + device_type_offset);
+ }
+
+ if (cb != NULL) {
+ _pfn_notify = &buildProgramCallback;
+ globalCB = (*env)->NewGlobalRef(env, cb);
+ }
+
+ _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);
+ }
+
+ return (jint)_res;
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.opencl.impl.CLImpl
+ * Java method: java.nio.ByteBuffer clEnqueueMapImage(long command_queue, long image, int blocking_map, long map_flags, com.jogamp.gluegen.common.nio.PointerBuffer origin, com.jogamp.gluegen.common.nio.PointerBuffer range, com.jogamp.gluegen.common.nio.PointerBuffer image_row_pitch, com.jogamp.gluegen.common.nio.PointerBuffer image_slice_pitch, int num_events_in_wait_list, com.jogamp.gluegen.common.nio.PointerBuffer event_wait_list, com.jogamp.gluegen.common.nio.PointerBuffer event, java.nio.IntBuffer errcode_ret)
+ * C function: void * clEnqueueMapImage(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret);
+ */
+JNIEXPORT jobject JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl12_clEnqueueMapImage0__JJIJLjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2IILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2I(JNIEnv *env, jobject _unused,
+ jlong command_queue, jlong image, jint blocking_map, jlong map_flags,
+ jobject origin, jint origin_byte_offset, jobject range, jint range_byte_offset,
+ jobject image_row_pitch, jint image_row_pitch_byte_offset, jobject image_slice_pitch,
+ jint image_slice_pitch_byte_offset, jint num_events_in_wait_list, jobject event_wait_list,
+ jint event_wait_list_byte_offset, jobject event, jint event_byte_offset, jobject errcode_ret, jint errcode_ret_byte_offset,
+ jlong imageInfoAddress, jlong mapImageAddress) {
+
+ size_t * _origin_ptr = NULL;
+ size_t * _range_ptr = NULL;
+ size_t * _image_row_pitch_ptr = NULL;
+ size_t * _image_slice_pitch_ptr = NULL;
+ cl_event * _event_wait_list_ptr = NULL;
+ cl_event * _event_ptr = NULL;
+ int32_t * _errcode_ret_ptr = NULL;
+ size_t * elements = NULL;
+ size_t * depth = NULL;
+ size_t pixels;
+ cl_int status;
+
+ typedef int32_t (*imageInfoFunctionType)(cl_mem, uint32_t, size_t, void *, size_t *);
+ imageInfoFunctionType clGetImageInfo = (imageInfoFunctionType)(intptr_t)imageInfoAddress;
+
+ typedef void* (*mapInfoFunctionType)(cl_command_queue, cl_mem, uint32_t, uint64_t, const size_t *,
+ const size_t *, size_t *, size_t *, uint32_t, cl_event *, cl_event *, int32_t *);
+ mapInfoFunctionType clEnqueueMapImage = (mapInfoFunctionType)(intptr_t)mapImageAddress;
+
+ void * _res;
+
+ if (origin != NULL) {
+ _origin_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, origin)) + origin_byte_offset);
+ }
+ if (range != NULL) {
+ _range_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, range)) + range_byte_offset);
+ }
+ if (image_row_pitch != NULL) {
+ _image_row_pitch_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, image_row_pitch)) + image_row_pitch_byte_offset);
+ }
+ if (image_slice_pitch != NULL) {
+ _image_slice_pitch_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, image_slice_pitch)) + image_slice_pitch_byte_offset);
+ }
+ if (event_wait_list != NULL) {
+ _event_wait_list_ptr = (cl_event *) (((char*) (*env)->GetDirectBufferAddress(env, event_wait_list)) + event_wait_list_byte_offset);
+ }
+ if (event != NULL) {
+ _event_ptr = (cl_event *) (((char*) (*env)->GetDirectBufferAddress(env, event)) + event_byte_offset);
+ }
+ if (errcode_ret != NULL) {
+ _errcode_ret_ptr = (int32_t *) (((char*) (*env)->GetDirectBufferAddress(env, errcode_ret)) + errcode_ret_byte_offset);
+ }
+
+ _res = (*clEnqueueMapImage)((cl_command_queue) (intptr_t) command_queue, (cl_mem) (intptr_t) image,
+ (uint32_t) blocking_map, (uint64_t) map_flags, (size_t *) _origin_ptr, (size_t *) _range_ptr,
+ (size_t *) _image_row_pitch_ptr, (size_t *) _image_slice_pitch_ptr, (uint32_t) num_events_in_wait_list,
+ (cl_event *) _event_wait_list_ptr, (cl_event *) _event_ptr, (int32_t *) _errcode_ret_ptr);
+ if (_res == NULL) return NULL;
+
+ // calculate buffer size
+ status = (*clGetImageInfo)((cl_mem) (intptr_t) image, CL_IMAGE_ELEMENT_SIZE, sizeof(size_t), (void *) elements, NULL);
+ status |= (*clGetImageInfo)((cl_mem) (intptr_t) image, CL_IMAGE_DEPTH, sizeof(size_t), (void *) depth, NULL);
+
+ if(status != CL_SUCCESS) {
+ return NULL;
+ }
+
+ if(*depth == 0) { // 2D
+ pixels = (*_image_row_pitch_ptr) * _range_ptr[1] + _range_ptr[0];
+ }else{ // 3D
+ pixels = (*_image_slice_pitch_ptr) * _range_ptr[2]
+ + (*_image_row_pitch_ptr) * _range_ptr[1] + _range_ptr[0];
+ }
+
+ return (*env)->NewDirectByteBuffer(env, _res, pixels * (*elements));
+
+}
+
+JNIEXPORT jint JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl12_clSetEventCallback0(JNIEnv *env, jobject _unused,
+ jlong event, jint trigger, jobject listener, jlong procAddress) {
+
+ cl_event _event = (cl_event)event;
+ cl_int _trigger = trigger;
+ cl_int _res;
+ typedef int32_t (*function)(cl_event, cl_int, void (*pfn_event_notify) (cl_event, cl_int, void *), void *);
+ function clSetEventCallback = (function)(intptr_t) procAddress;
+
+ jobject cb = (*env)->NewGlobalRef(env, listener);
+ _res = (*clSetEventCallback)(_event, _trigger, &eventCallback, cb);
+
+ return _res;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl12_clSetMemObjectDestructorCallback0(JNIEnv *env, jobject _unused,
+ jlong mem, jobject listener, jlong procAddress) {
+
+ cl_mem _mem = (cl_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;
+}
diff --git a/make/config/clImplCustomCode12.java b/make/config/clImplCustomCode12.java
new file mode 100644
index 00000000..ff29d5e5
--- /dev/null
+++ b/make/config/clImplCustomCode12.java
@@ -0,0 +1,60 @@
+
+ /** If null, OpenCL is not available on this machine. */
+ static final DynamicLibraryBundle dynamicLookupHelper;
+ protected static final CLProcAddressTable12 addressTable;
+
+ static {
+ addressTable = new CLProcAddressTable12();
+ dynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() {
+ public DynamicLibraryBundle run() {
+ final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new CLDynamicLibraryBundleInfo());
+ if(!bundle.isToolLibLoaded()) {
+ // couldn't load native CL library
+ // TODO: log this?
+ return null;
+ }
+ if(!bundle.isLibComplete()) {
+ System.err.println("Couln't load native CL/JNI glue library");
+ return null;
+ }
+ addressTable.reset(bundle);
+ /** Not required nor forced
+ if( !initializeImpl() ) {
+ System.err.println("Native initialization failure of CL/JNI glue library");
+ return null;
+ } */
+ return bundle;
+ } } );
+ }
+
+ /**
+ * Accessor.
+ * @returns true if OpenCL is available on this machine.
+ */
+ public static boolean isAvailable() { return dynamicLookupHelper != null; }
+ public static CLProcAddressTable12 getCLProcAddressTable() { return addressTable; }
+
+ static long clGetExtensionFunctionAddress(long clGetExtensionFunctionAddressHandle, java.lang.String procname)
+ {
+ if (clGetExtensionFunctionAddressHandle == 0) {
+ throw new RuntimeException("Passed null pointer for method \"clGetExtensionFunctionAddress\"");
+ }
+ return dispatch_clGetExtensionFunctionAddressStatic(procname, clGetExtensionFunctionAddressHandle);
+ }
+
+ public CLAbstractImpl12() {
+ }
+
+ /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */
+ long clGetExtensionFunctionAddress(String fname) {
+
+ final long __addr_ = addressTable._addressof_clGetExtensionFunctionAddress;
+ if (__addr_ == 0) {
+ throw new UnsupportedOperationException("Method \"clGetExtensionFunctionAddress\" not available");
+ }
+ return dispatch_clGetExtensionFunctionAddressStatic(fname, __addr_);
+ }
+
+ /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */
+ private static native long dispatch_clGetExtensionFunctionAddressStatic(String fname, long procAddress);
+
diff --git a/make/config/clImplCustomCode20.c b/make/config/clImplCustomCode20.c
new file mode 100644
index 00000000..065aad31
--- /dev/null
+++ b/make/config/clImplCustomCode20.c
@@ -0,0 +1,328 @@
+// callbacks
+typedef void (CL_CALLBACK * cccallback)(const char *, const void *, size_t, void *);
+typedef void (CL_CALLBACK * bpcallback)(cl_program, void *);
+
+CL_CALLBACK void buildProgramCallback(cl_program id, void * object);
+CL_CALLBACK void createContextCallback(const char * errinfo, const void * private_info, size_t cb, void * object);
+CL_CALLBACK void eventCallback(cl_event event, cl_int status, void * object);
+CL_CALLBACK void memObjDestructorCallback(cl_mem mem, void * object);
+
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_opencl_llb_impl_CLAbstractImpl20_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) {
+ typedef void* (CL_API_CALL * _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) (_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
+ * Java method: long clCreateContextFromType(java.nio.IntBuffer props, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret)
+ * C function: cl_context clCreateContextFromType( const cl_context_properties * properties ,
+ * cl_device_type device_type ,
+ * void (CL_CALLBACK * pfn_notify )(const char *, const void *, size_t, void *),
+ * void * user_data ,
+ * cl_int * errcode_ret);
+ */
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl20_clCreateContextFromType0(JNIEnv *env, jobject _unused,
+ jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) {
+
+ cl_context_properties* _props_ptr = NULL;
+ cl_int * _errcode_ptr = NULL;
+ cl_context _ctx = NULL;
+ cccallback _pfn_notify = NULL;
+ jobject globalCB = NULL;
+
+ typedef cl_context (*function)(const cl_context_properties *, cl_device_type, void (*pfn_notify)(const char *, const void *, size_t, void *), void *, cl_int *);
+ function clCreateContextFromType = (function)(intptr_t) procAddress;
+
+ if (props != NULL) {
+ _props_ptr = (cl_context_properties*) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset);
+ }
+
+ if (errcode != NULL) {
+ _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, _errcode_ptr);
+
+ if(globalCB != NULL) {
+ jlong *g = (*env)->GetPrimitiveArrayCritical(env, global, NULL);
+ // if something went wrong
+ if(_ctx == NULL) {
+ g[0] = 0;
+ (*env)->DeleteGlobalRef(env, globalCB);
+ }else{
+ g[0] = (jlong)globalCB;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0);
+ }
+
+ return (jlong) (intptr_t)_ctx;
+}
+
+/*
+ * Entry point to C language function:
+ *extern CL_API_ENTRY cl_context CL_API_CALL
+ *clCreateContext(cl_context_properties * properties ,
+ * cl_uint num_devices ,
+ * const cl_device_id * devices ,
+ * void (*pfn_notify)(const char *, const void *, size_t, void *) pfn_notify ,
+ * void * user_data ,
+ * cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0;
+ */
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl20_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, jlong procAddress) {
+
+ cl_context_properties* _props_ptr = NULL;
+ cl_int * _errcode_ptr = NULL;
+ cl_device_id * _deviceListPtr = NULL;
+ cl_context _ctx = NULL;
+ cccallback _pfn_notify = NULL;
+ jobject globalCB = NULL;
+
+ 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) {
+ _props_ptr = (cl_context_properties*) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset);
+ }
+ if (deviceList != NULL) {
+ _deviceListPtr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, deviceList)) + device_type_offset);
+ }
+ if (errcode != NULL) {
+ _errcode_ptr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset);
+ }
+
+ if (cb != NULL) {
+ _pfn_notify = &createContextCallback;
+ globalCB = (*env)->NewGlobalRef(env, cb);
+ }
+
+ _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
+ if(_ctx == NULL) {
+ g[0] = 0;
+ (*env)->DeleteGlobalRef(env, globalCB);
+ }else{
+ g[0] = (jlong)globalCB;
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0);
+ }
+
+ return (jlong) (intptr_t)_ctx;
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.opencl.impl.CLImpl
+ * Java method: int clReleaseContextImpl(long context)
+ * C function: int32_t clReleaseContextImpl(cl_context context);
+ */
+JNIEXPORT jint JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl20_clReleaseContextImpl(JNIEnv *env, jobject _unused, jlong context, jlong global, jlong procAddress) {
+
+ int32_t _res;
+ typedef int32_t (*function)(cl_context);
+ function clReleaseContext = (function)(intptr_t) procAddress;
+
+ _res = (*clReleaseContext)((cl_context) (intptr_t) context);
+ // TODO deal with retains
+ if (global != 0) {
+ (*env)->DeleteGlobalRef(env, (jobject) global);
+ }
+ return _res;
+}
+
+
+/**
+ * Entry point to C language function:
+ * extern CL_API_ENTRY cl_int CL_API_CALL
+ *clBuildProgram(cl_program program ,
+ * cl_uint num_devices ,
+ * const cl_device_id * device_list ,
+ * const char * options ,
+ * void (*pfn_notify)(cl_program program , void * user_data ),
+ * void * user_data ) CL_API_SUFFIX__VERSION_1_0;
+ */
+JNIEXPORT jint JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl20_clBuildProgram0(JNIEnv *env, jobject _unused,
+ jlong program, jint deviceCount, jobject deviceList, jint device_type_offset, jstring options, jobject cb, jlong procAddress) {
+
+ const char* _strchars_options = NULL;
+ cl_int _res;
+ cl_device_id * _deviceListPtr = NULL;
+ bpcallback _pfn_notify = NULL;
+ jobject globalCB = NULL;
+
+ 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) {
+ _strchars_options = (*env)->GetStringUTFChars(env, options, (jboolean*)NULL);
+ if (_strchars_options == NULL) {
+ (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"),
+ "Failed to get UTF-8 chars for argument \"options\" in native dispatcher for \"clBuildProgram\"");
+ return CL_FALSE;
+ }
+ }
+
+ if (deviceList != NULL) {
+ _deviceListPtr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, deviceList)) + device_type_offset);
+ }
+
+ if (cb != NULL) {
+ _pfn_notify = &buildProgramCallback;
+ globalCB = (*env)->NewGlobalRef(env, cb);
+ }
+
+ _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);
+ }
+
+ return (jint)_res;
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.opencl.impl.CLImpl
+ * Java method: java.nio.ByteBuffer clEnqueueMapImage(long command_queue, long image, int blocking_map, long map_flags, com.jogamp.gluegen.common.nio.PointerBuffer origin, com.jogamp.gluegen.common.nio.PointerBuffer range, com.jogamp.gluegen.common.nio.PointerBuffer image_row_pitch, com.jogamp.gluegen.common.nio.PointerBuffer image_slice_pitch, int num_events_in_wait_list, com.jogamp.gluegen.common.nio.PointerBuffer event_wait_list, com.jogamp.gluegen.common.nio.PointerBuffer event, java.nio.IntBuffer errcode_ret)
+ * C function: void * clEnqueueMapImage(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret);
+ */
+JNIEXPORT jobject JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl20_clEnqueueMapImage0__JJIJLjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2IILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2I(JNIEnv *env, jobject _unused,
+ jlong command_queue, jlong image, jint blocking_map, jlong map_flags,
+ jobject origin, jint origin_byte_offset, jobject range, jint range_byte_offset,
+ jobject image_row_pitch, jint image_row_pitch_byte_offset, jobject image_slice_pitch,
+ jint image_slice_pitch_byte_offset, jint num_events_in_wait_list, jobject event_wait_list,
+ jint event_wait_list_byte_offset, jobject event, jint event_byte_offset, jobject errcode_ret, jint errcode_ret_byte_offset,
+ jlong imageInfoAddress, jlong mapImageAddress) {
+
+ size_t * _origin_ptr = NULL;
+ size_t * _range_ptr = NULL;
+ size_t * _image_row_pitch_ptr = NULL;
+ size_t * _image_slice_pitch_ptr = NULL;
+ cl_event * _event_wait_list_ptr = NULL;
+ cl_event * _event_ptr = NULL;
+ int32_t * _errcode_ret_ptr = NULL;
+ size_t * elements = NULL;
+ size_t * depth = NULL;
+ size_t pixels;
+ cl_int status;
+
+ typedef int32_t (*imageInfoFunctionType)(cl_mem, uint32_t, size_t, void *, size_t *);
+ imageInfoFunctionType clGetImageInfo = (imageInfoFunctionType)(intptr_t)imageInfoAddress;
+
+ typedef void* (*mapInfoFunctionType)(cl_command_queue, cl_mem, uint32_t, uint64_t, const size_t *,
+ const size_t *, size_t *, size_t *, uint32_t, cl_event *, cl_event *, int32_t *);
+ mapInfoFunctionType clEnqueueMapImage = (mapInfoFunctionType)(intptr_t)mapImageAddress;
+
+ void * _res;
+
+ if (origin != NULL) {
+ _origin_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, origin)) + origin_byte_offset);
+ }
+ if (range != NULL) {
+ _range_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, range)) + range_byte_offset);
+ }
+ if (image_row_pitch != NULL) {
+ _image_row_pitch_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, image_row_pitch)) + image_row_pitch_byte_offset);
+ }
+ if (image_slice_pitch != NULL) {
+ _image_slice_pitch_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, image_slice_pitch)) + image_slice_pitch_byte_offset);
+ }
+ if (event_wait_list != NULL) {
+ _event_wait_list_ptr = (cl_event *) (((char*) (*env)->GetDirectBufferAddress(env, event_wait_list)) + event_wait_list_byte_offset);
+ }
+ if (event != NULL) {
+ _event_ptr = (cl_event *) (((char*) (*env)->GetDirectBufferAddress(env, event)) + event_byte_offset);
+ }
+ if (errcode_ret != NULL) {
+ _errcode_ret_ptr = (int32_t *) (((char*) (*env)->GetDirectBufferAddress(env, errcode_ret)) + errcode_ret_byte_offset);
+ }
+
+ _res = (*clEnqueueMapImage)((cl_command_queue) (intptr_t) command_queue, (cl_mem) (intptr_t) image,
+ (uint32_t) blocking_map, (uint64_t) map_flags, (size_t *) _origin_ptr, (size_t *) _range_ptr,
+ (size_t *) _image_row_pitch_ptr, (size_t *) _image_slice_pitch_ptr, (uint32_t) num_events_in_wait_list,
+ (cl_event *) _event_wait_list_ptr, (cl_event *) _event_ptr, (int32_t *) _errcode_ret_ptr);
+ if (_res == NULL) return NULL;
+
+ // calculate buffer size
+ status = (*clGetImageInfo)((cl_mem) (intptr_t) image, CL_IMAGE_ELEMENT_SIZE, sizeof(size_t), (void *) elements, NULL);
+ status |= (*clGetImageInfo)((cl_mem) (intptr_t) image, CL_IMAGE_DEPTH, sizeof(size_t), (void *) depth, NULL);
+
+ if(status != CL_SUCCESS) {
+ return NULL;
+ }
+
+ if(*depth == 0) { // 2D
+ pixels = (*_image_row_pitch_ptr) * _range_ptr[1] + _range_ptr[0];
+ }else{ // 3D
+ pixels = (*_image_slice_pitch_ptr) * _range_ptr[2]
+ + (*_image_row_pitch_ptr) * _range_ptr[1] + _range_ptr[0];
+ }
+
+ return (*env)->NewDirectByteBuffer(env, _res, pixels * (*elements));
+
+}
+
+JNIEXPORT jint JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl20_clSetEventCallback0(JNIEnv *env, jobject _unused,
+ jlong event, jint trigger, jobject listener, jlong procAddress) {
+
+ cl_event _event = (cl_event)event;
+ cl_int _trigger = trigger;
+ cl_int _res;
+ typedef int32_t (*function)(cl_event, cl_int, void (*pfn_event_notify) (cl_event, cl_int, void *), void *);
+ function clSetEventCallback = (function)(intptr_t) procAddress;
+
+ jobject cb = (*env)->NewGlobalRef(env, listener);
+ _res = (*clSetEventCallback)(_event, _trigger, &eventCallback, cb);
+
+ return _res;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_jogamp_opencl_llb_impl_CLImpl20_clSetMemObjectDestructorCallback0(JNIEnv *env, jobject _unused,
+ jlong mem, jobject listener, jlong procAddress) {
+
+ cl_mem _mem = (cl_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;
+}
diff --git a/make/config/clImplCustomCode20.java b/make/config/clImplCustomCode20.java
new file mode 100644
index 00000000..e6c8071c
--- /dev/null
+++ b/make/config/clImplCustomCode20.java
@@ -0,0 +1,60 @@
+
+ /** If null, OpenCL is not available on this machine. */
+ static final DynamicLibraryBundle dynamicLookupHelper;
+ protected static final CLProcAddressTable20 addressTable;
+
+ static {
+ addressTable = new CLProcAddressTable20();
+ dynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() {
+ public DynamicLibraryBundle run() {
+ final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new CLDynamicLibraryBundleInfo());
+ if(!bundle.isToolLibLoaded()) {
+ // couldn't load native CL library
+ // TODO: log this?
+ return null;
+ }
+ if(!bundle.isLibComplete()) {
+ System.err.println("Couln't load native CL/JNI glue library");
+ return null;
+ }
+ addressTable.reset(bundle);
+ /** Not required nor forced
+ if( !initializeImpl() ) {
+ System.err.println("Native initialization failure of CL/JNI glue library");
+ return null;
+ } */
+ return bundle;
+ } } );
+ }
+
+ /**
+ * Accessor.
+ * @returns true if OpenCL is available on this machine.
+ */
+ public static boolean isAvailable() { return dynamicLookupHelper != null; }
+ public static CLProcAddressTable20 getCLProcAddressTable() { return addressTable; }
+
+ static long clGetExtensionFunctionAddress(long clGetExtensionFunctionAddressHandle, java.lang.String procname)
+ {
+ if (clGetExtensionFunctionAddressHandle == 0) {
+ throw new RuntimeException("Passed null pointer for method \"clGetExtensionFunctionAddress\"");
+ }
+ return dispatch_clGetExtensionFunctionAddressStatic(procname, clGetExtensionFunctionAddressHandle);
+ }
+
+ public CLAbstractImpl20() {
+ }
+
+ /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */
+ long clGetExtensionFunctionAddress(String fname) {
+
+ final long __addr_ = addressTable._addressof_clGetExtensionFunctionAddress;
+ if (__addr_ == 0) {
+ throw new UnsupportedOperationException("Method \"clGetExtensionFunctionAddress\" not available");
+ }
+ return dispatch_clGetExtensionFunctionAddressStatic(fname, __addr_);
+ }
+
+ /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */
+ private static native long dispatch_clGetExtensionFunctionAddressStatic(String fname, long procAddress);
+