diff options
-rw-r--r-- | nbproject/project.properties | 4 | ||||
-rw-r--r-- | resources/cl-impl.cfg | 64 | ||||
-rw-r--r-- | resources/clImplCustomCode.c | 112 | ||||
-rw-r--r-- | resources/clImplCustomCode.java | 2 | ||||
-rw-r--r-- | src/com/jogamp/opencl/impl/CLImpl.java | 78 |
5 files changed, 170 insertions, 90 deletions
diff --git a/nbproject/project.properties b/nbproject/project.properties index ae86051f..4e1a1cbd 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -104,7 +104,9 @@ src.native.dir=gensrc/native test.src.dir=test #crosscompile=true -static.binding=true + +#enable compiletime linking +#static.binding=true #overwrite lib path for static linking #use only if static.binding is true diff --git a/resources/cl-impl.cfg b/resources/cl-impl.cfg index 58c550f5..f42b814c 100644 --- a/resources/cl-impl.cfg +++ b/resources/cl-impl.cfg @@ -21,29 +21,29 @@ GetProcAddressTableExpr addressTable ProcAddressNameExpr $UpperCase(arg) #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 +#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__ +ForceProcAddressGen __ALL__ Unignore clGetExtensionFunctionAddress RenameJavaMethod clGetExtensionFunctionAddress clGetExtensionFunctionAddressImpl @@ -57,21 +57,29 @@ CustomCCode #include <GL3/gl3.h> CustomCCode #include <inttypes.h> # implement manually via custom code -Ignore clCreateContext -Ignore clCreateContextFromType -Ignore clBuildProgram -Ignore clEnqueueNativeKernel -Ignore clReleaseContext +Ignore clCreateContext +ForceProcAddressGen clCreateContext + +Ignore clCreateContextFromType +ForceProcAddressGen clCreateContextFromType + +Ignore clBuildProgram +ForceProcAddressGen clBuildProgram + +Ignore clEnqueueNativeKernel +ForceProcAddressGen clEnqueueNativeKernel + +Ignore clReleaseContext +ForceProcAddressGen clReleaseContext #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 CLAbstractImpl clImplCustomCode.java IncludeAs CustomCCode clImplCustomCode.c -#JavaEpilogue clCreateKernelsInProgram if(kernels!=null && CPU.is32Bit() && kernels.lenght > 1) { convert32To64(kernels); } - diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c index 678ad35d..bca6cb1c 100644 --- a/resources/clImplCustomCode.c +++ b/resources/clImplCustomCode.c @@ -74,16 +74,15 @@ void createContextCallback(const char * errinfo, const void * private_info, size /* 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( 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 ); + * 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_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject _unused, - jobject props, jint props_byte_offset, jlong 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, jlong procAddress) { cl_context_properties* _props_ptr = NULL; cl_int * _errcode_ptr = NULL; @@ -91,6 +90,9 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject void (*_pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data) = 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); } @@ -106,7 +108,7 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject } */ - _ctx = clCreateContextFromType(_props_ptr, (uint64_t) device_type, _pfn_notify, globalCB, _errcode_ptr); + _ctx = (*clCreateContextFromType)(_props_ptr, (uint64_t) device_type, _pfn_notify, globalCB, _errcode_ptr); /* if(globalCB != NULL) { @@ -137,7 +139,7 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject */ JNIEXPORT jlong JNICALL 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) { + 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; @@ -146,6 +148,9 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContext0(JNIEnv *env, jobject _unused void (*_pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data) = 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 *); + function clCreateContext = (function)(intptr_t) procAddress; + if (props != NULL) { _props_ptr = (cl_context_properties*) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset); } @@ -163,7 +168,7 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContext0(JNIEnv *env, jobject _unused } */ - _ctx = clCreateContext(_props_ptr, numDevices, _deviceListPtr, _pfn_notify, globalCB, _errcode_ptr); + _ctx = (*clCreateContext)(_props_ptr, numDevices, _deviceListPtr, _pfn_notify, globalCB, _errcode_ptr); /* if(globalCB != NULL) { @@ -188,9 +193,13 @@ Java_com_jogamp_opencl_impl_CLImpl_clCreateContext0(JNIEnv *env, jobject _unused * C function: int32_t clReleaseContextImpl(cl_context context); */ JNIEXPORT jint JNICALL -Java_com_jogamp_opencl_impl_CLImpl_clReleaseContextImpl(JNIEnv *env, jobject _unused, jlong context, jlong global) { +Java_com_jogamp_opencl_impl_CLImpl_clReleaseContextImpl(JNIEnv *env, jobject _unused, jlong context, jlong global, jlong procAddress) { + int32_t _res; - _res = clReleaseContext((cl_context) (intptr_t) context); + 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) { @@ -213,7 +222,7 @@ Java_com_jogamp_opencl_impl_CLImpl_clReleaseContextImpl(JNIEnv *env, jobject _un */ JNIEXPORT jint JNICALL Java_com_jogamp_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused, - jlong program, jint deviceCount, jobject deviceList, jint device_type_offset, jstring options, jobject cb) { + jlong program, jint deviceCount, jobject deviceList, jint device_type_offset, jstring options, jobject cb, jlong procAddress) { const char* _strchars_options = NULL; cl_int _res; @@ -221,6 +230,9 @@ Java_com_jogamp_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused, void (*_pfn_notify)(cl_program, void *) = 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 *); + function clBuildProgram = (function)(intptr_t)procAddress; + if (options != NULL) { _strchars_options = (*env)->GetStringUTFChars(env, options, (jboolean*)NULL); if (_strchars_options == NULL) { @@ -241,7 +253,7 @@ Java_com_jogamp_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused, } */ - _res = clBuildProgram((cl_program)(intptr_t)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 @@ -263,21 +275,34 @@ Java_com_jogamp_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused, * 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_impl_CLImpl_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) { - - 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; - - void * _res; +Java_com_jogamp_opencl_impl_CLImpl_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; + + 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; + + void * _res; if (origin != NULL) { _origin_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, origin)) + origin_byte_offset); @@ -301,21 +326,26 @@ Java_com_jogamp_opencl_impl_CLImpl_clEnqueueMapImage0__JJIJLjava_lang_Object_2IL _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; + _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); + // 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(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]; - } + 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)); } diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java index 17e0b888..1826da86 100644 --- a/resources/clImplCustomCode.java +++ b/resources/clImplCustomCode.java @@ -1,5 +1,5 @@ - private final CLProcAddressTable addressTable; + protected final CLProcAddressTable addressTable; public CLAbstractImpl(CLProcAddressTable addressTable) { this.addressTable = addressTable; diff --git a/src/com/jogamp/opencl/impl/CLImpl.java b/src/com/jogamp/opencl/impl/CLImpl.java index 16b882ac..abec3597 100644 --- a/src/com/jogamp/opencl/impl/CLImpl.java +++ b/src/com/jogamp/opencl/impl/CLImpl.java @@ -14,7 +14,7 @@ import java.nio.IntBuffer; import static com.jogamp.common.nio.Buffers.*; /** - * Java bindings to OpenCL, the Open Computing Language. + * Java bindings to OpenCL, the Open Computing Language. * @author Michael Bien */ public class CLImpl extends CLAbstractImpl { @@ -38,11 +38,16 @@ public class CLImpl extends CLAbstractImpl { throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); } + final long address = addressTable._addressof_clCreateContext; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } + long[] global = new long[1]; long ctx = this.clCreateContext0( properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), devices != null ? devices.remaining() : 0, devices != null ? devices.getBuffer() : null, getDirectBufferByteOffset(devices), - pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret)); + pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); if (pfn_notify != null && global[0] != 0) { synchronized (contextCallbackMap) { @@ -52,7 +57,7 @@ public class CLImpl extends CLAbstractImpl { return ctx; } - 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); + 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, long address); public long clCreateContextFromType(PointerBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { @@ -64,10 +69,15 @@ public class CLImpl extends CLAbstractImpl { throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); } + final long address = addressTable._addressof_clCreateContextFromType; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } + long[] global = new long[1]; long ctx = this.clCreateContextFromType0( properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), - device_type, pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret)); + device_type, pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); if (pfn_notify != null && global[0] != 0) { synchronized (contextCallbackMap) { @@ -77,18 +87,23 @@ public class CLImpl extends CLAbstractImpl { return ctx; } - private native long clCreateContextFromType0(Object properties, int props_offset, long device_type, Object 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, long address); public int clReleaseContext(long context) { long global = 0; synchronized (contextCallbackMap) { global = contextCallbackMap.remove(context); } - return clReleaseContextImpl(context, global); + + final long address = addressTable._addressof_clReleaseContext; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } + return clReleaseContextImpl(context, global, address); } /** Interface to C language function: <br> <code> int32_t {@native clReleaseContext}(cl_context context); </code> */ - public native int clReleaseContextImpl(long context, long global); + public native int clReleaseContextImpl(long context, long global, long address); /** Interface to C language function: <br> <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); </code> */ public int clBuildProgram(long program, int deviceCount, PointerBuffer deviceList, String options, BuildProgramCallback cb) { @@ -97,12 +112,16 @@ public class CLImpl extends CLAbstractImpl { throw new RuntimeException("Argument \"properties\" was not a direct buffer"); } + final long address = addressTable._addressof_clBuildProgram; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } return clBuildProgram0(program, deviceCount, deviceList != null ? deviceList.getBuffer() : null, - getDirectBufferByteOffset(deviceList), options, cb); + getDirectBufferByteOffset(deviceList), options, cb, address); } /** Entry point to C language function: <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); </code> */ - private native int clBuildProgram0(long program, int deviceCount, Object deviceList, int deviceListOffset, String options, BuildProgramCallback cb); + private native int clBuildProgram0(long program, int deviceCount, Object deviceList, int deviceListOffset, String options, BuildProgramCallback cb, long address); /** Interface to C language function: <br> <code> void * {@native 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); </code> @param origin a direct {@link com.jogamp.common.nio.PointerBuffer} @@ -140,6 +159,14 @@ public class CLImpl extends CLAbstractImpl { throw new CLException("Argument \"errcode_ret\" was not a direct buffer"); } + final long mapImageAddress = addressTable._addressof_clEnqueueMapImage; + if (mapImageAddress == 0) { + throw new UnsupportedOperationException("Method not available"); + } + final long getImageInfoAddress = addressTable._addressof_clGetImageInfo; + if (getImageInfoAddress == 0) { + throw new UnsupportedOperationException("Method not available"); + } java.nio.ByteBuffer _res; _res = clEnqueueMapImage0(command_queue, image, blocking_map, map_flags, origin != null ? origin.getBuffer() : null, getDirectBufferByteOffset(origin), range != null ? range.getBuffer() : null, @@ -164,30 +191,43 @@ public class CLImpl extends CLAbstractImpl { @param event_wait_list a direct {@link com.jogamp.gluegen.runtime.PointerBuffer} @param event a direct {@link com.jogamp.gluegen.runtime.PointerBuffer} @param errcode_ret a direct {@link java.nio.IntBuffer} */ - private native ByteBuffer clEnqueueMapImage0(long command_queue, long image, int blocking_map, long map_flags, Object origin, int origin_byte_offset, Object range, int range_byte_offset, Object image_row_pitch, int image_row_pitch_byte_offset, Object image_slice_pitch, int image_slice_pitch_byte_offset, int num_events_in_wait_list, Object event_wait_list, int event_wait_list_byte_offset, Object event, int event_byte_offset, Object errcode_ret, int errcode_ret_byte_offset); + private native ByteBuffer clEnqueueMapImage0(long command_queue, long image, int blocking_map, long map_flags, + Object origin, int origin_byte_offset, Object range, int range_byte_offset, Object image_row_pitch, + int image_row_pitch_byte_offset, Object image_slice_pitch, int image_slice_pitch_byte_offset, + int num_events_in_wait_list, Object event_wait_list, int event_wait_list_byte_offset, Object event, + int event_byte_offset, Object errcode_ret, int errcode_ret_byte_offset); /** * Returns the extension function address for the given function name. */ public long clGetExtensionFunctionAddress(String name) { ByteBuffer res = super.clGetExtensionFunctionAddressImpl(name); - if (Platform.is32Bit()) { + if(res == null) { + return 0; + }else if (Platform.is32Bit()) { return res.getInt(); } else { return res.getLong(); } } + public CLProcAddressTable getAddressTable() { + return addressTable; + } + /* private static void convert32To64(long[] values) { - if (values.length % 2 == 1) { - values[values.length - 1] = values[values.length / 2] >>> 32; - } - for (int i = values.length - 1 - values.length % 2; i >= 0; i -= 2) { - long temp = values[i / 2]; - values[i - 1] = temp >>> 32; - values[i] = temp & 0x00000000FFFFFFFFL; - } + if (values.length % 2 == 1) { + values[values.length - 1] = values[values.length / 2] >>> 32; + } + for (int i = values.length - 1 - values.length % 2; i >= 0; i -= 2) { + long temp = values[i / 2]; + values[i - 1] = temp >>> 32; + values[i] = temp & 0x00000000FFFFFFFFL; + } } */ + + + } |