diff options
23 files changed, 209 insertions, 165 deletions
diff --git a/.classpath b/.classpath new file mode 100644 index 00000000..49ad63bd --- /dev/null +++ b/.classpath @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="test"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/jogamp"/> + <classpathentry kind="output" path="build"/> +</classpath> diff --git a/.externalToolBuilders/jocl-ant.launch b/.externalToolBuilders/jocl-ant.launch new file mode 100644 index 00000000..f6b6cd6f --- /dev/null +++ b/.externalToolBuilders/jocl-ant.launch @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> +<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="clean,"/> +<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="jar,"/> +<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> +<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> +<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> +<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> +<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="jocl"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/jocl/build.xml}"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/> +<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/jocl}"/> +</launchConfiguration> diff --git a/.project b/.project new file mode 100644 index 00000000..7059a171 --- /dev/null +++ b/.project @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>jocl</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + <dictionary> + <key>LaunchConfigHandle</key> + <value><project>/.externalToolBuilders/jocl-ant.launch</value> + </dictionary> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/resources/cl-if.cfg b/resources/cl-if.cfg index aa7de799..f65a417b 100644 --- a/resources/cl-if.cfg +++ b/resources/cl-if.cfg @@ -23,17 +23,17 @@ Ignore CL_GL_.*|cl.*GL.* Ignore clCreateContext CustomJavaCode CL CustomJavaCode CL /** Interface to C language function: <br> <code> cl_context {@native clCreateContext}(intptr_t * , uint32_t, cl_device_id * , void (*pfn_notify)(const char *, const void *, size_t, void *), void *, int32_t * ); </code> */ -CustomJavaCode CL public long clCreateContext(NativeSizeBuffer properties, NativeSizeBuffer devices, CLErrorHandler pfn_notify, IntBuffer errcode_ret); +CustomJavaCode CL public long clCreateContext(PointerBuffer properties, PointerBuffer devices, CLErrorHandler pfn_notify, IntBuffer errcode_ret); Ignore clCreateContextFromType CustomJavaCode CL CustomJavaCode CL /** Interface to C language function: <br> <code> cl_context {@native clCreateContextFromType}(cl_context_properties *properties, cl_device_type device_type, void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data), void *user_data, cl_int *errcode_ret) ; </code> */ -CustomJavaCode CL public long clCreateContextFromType(NativeSizeBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret); +CustomJavaCode CL public long clCreateContextFromType(PointerBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret); Ignore clBuildProgram CustomJavaCode CL CustomJavaCode CL /** Interface to C language function: <br> <code> int32_t {@native clBuildProgram}(cl_program, uint32_t, cl_device_id * , const char * , void (*pfn_notify)(cl_program, void *user_data), void * ); </code> */ -CustomJavaCode CL public int clBuildProgram(long program, int deviceCount, NativeSizeBuffer devices, String options, BuildProgramCallback cb); +CustomJavaCode CL public int clBuildProgram(long program, int deviceCount, PointerBuffer devices, String options, BuildProgramCallback cb); Ignore clSetEventCallback CustomJavaCode CL diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c index 789491c6..bdce55a5 100644 --- a/resources/clImplCustomCode.c +++ b/resources/clImplCustomCode.c @@ -299,7 +299,7 @@ Java_com_jogamp_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused, /* 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.NativeSizeBuffer origin, com.jogamp.gluegen.common.nio.NativeSizeBuffer range, com.jogamp.gluegen.common.nio.NativeSizeBuffer image_row_pitch, com.jogamp.gluegen.common.nio.NativeSizeBuffer image_slice_pitch, int num_events_in_wait_list, com.jogamp.gluegen.common.nio.NativeSizeBuffer event_wait_list, com.jogamp.gluegen.common.nio.NativeSizeBuffer event, java.nio.IntBuffer errcode_ret) + * 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 diff --git a/src/com/jogamp/opencl/CLBuffer.java b/src/com/jogamp/opencl/CLBuffer.java index 6f00247c..57fba461 100644 --- a/src/com/jogamp/opencl/CLBuffer.java +++ b/src/com/jogamp/opencl/CLBuffer.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import com.jogamp.common.nio.Buffers; import java.util.List; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.CLMemory.Mem; import java.nio.Buffer; import java.util.ArrayList; @@ -108,7 +108,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { size *= elemSize; } - NativeSizeBuffer info = NativeSizeBuffer.allocateDirect(2); + PointerBuffer info = PointerBuffer.allocateDirect(2); info.put(offset).put(size).rewind(); int bitset = Mem.flagsToInt(flags); diff --git a/src/com/jogamp/opencl/CLCommandQueue.java b/src/com/jogamp/opencl/CLCommandQueue.java index d578738b..7f3a4292 100644 --- a/src/com/jogamp/opencl/CLCommandQueue.java +++ b/src/com/jogamp/opencl/CLCommandQueue.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import com.jogamp.common.nio.CachedBufferFactory; import com.jogamp.opencl.gl.CLGLI; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.gl.CLGLObject; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -66,9 +66,9 @@ public class CLCommandQueue extends CLObject implements CLResource { * Those direct memory buffers are used to move data between the JVM and OpenCL. */ private final IntBuffer pbA; - private final NativeSizeBuffer ibA; - private final NativeSizeBuffer ibB; - private final NativeSizeBuffer ibC; + private final PointerBuffer ibA; + private final PointerBuffer ibB; + private final PointerBuffer ibC; private CLCommandQueue(CLContext context, long id, CLDevice device, long properties) { super(context, id); @@ -76,12 +76,12 @@ public class CLCommandQueue extends CLObject implements CLResource { this.device = device; this.properties = properties; - int pbsize = NativeSizeBuffer.elementSize(); + int pbsize = PointerBuffer.ELEMENT_SIZE; CachedBufferFactory factory = CachedBufferFactory.create(9*pbsize + 4, true); - this.ibA = NativeSizeBuffer.wrap(factory.newDirectByteBuffer(3*pbsize)); - this.ibB = NativeSizeBuffer.wrap(factory.newDirectByteBuffer(3*pbsize)); - this.ibC = NativeSizeBuffer.wrap(factory.newDirectByteBuffer(3*pbsize)); + this.ibA = PointerBuffer.wrap(factory.newDirectByteBuffer(3*pbsize)); + this.ibB = PointerBuffer.wrap(factory.newDirectByteBuffer(3*pbsize)); + this.ibC = PointerBuffer.wrap(factory.newDirectByteBuffer(3*pbsize)); this.pbA = factory.newDirectIntBuffer(1); @@ -117,7 +117,7 @@ public class CLCommandQueue extends CLObject implements CLResource { */ public CLCommandQueue putWriteBuffer(CLBuffer<?> writeBuffer, boolean blockingWrite, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -161,7 +161,7 @@ public class CLCommandQueue extends CLObject implements CLResource { */ public CLCommandQueue putReadBuffer(CLBuffer<?> readBuffer, boolean blockingRead, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -210,7 +210,7 @@ public class CLCommandQueue extends CLObject implements CLResource { */ public CLCommandQueue putCopyBuffer(CLBuffer<?> src, CLBuffer<?> dest, int srcOffset, int destOffset, long bytesToCopy, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -280,7 +280,7 @@ public class CLCommandQueue extends CLObject implements CLResource { long rowPitch, long slicePitch, long hostRowPitch, long hostSlicePitch, boolean blockingWrite, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -358,7 +358,7 @@ public class CLCommandQueue extends CLObject implements CLResource { long rowPitch, long slicePitch, long hostRowPitch, long hostSlicePitch, boolean blockingRead, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -439,7 +439,7 @@ public class CLCommandQueue extends CLObject implements CLResource { long srcRowPitch, long srcSlicePitch, long destRowPitch, long destSlicePitch, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -507,7 +507,7 @@ public class CLCommandQueue extends CLObject implements CLResource { public CLCommandQueue putWriteImage(CLImage2d<?> writeImage, int inputRowPitch, int originX, int originY, int rangeX, int rangeY, boolean blockingWrite, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -569,7 +569,7 @@ public class CLCommandQueue extends CLObject implements CLResource { public CLCommandQueue putWriteImage(CLImage3d<?> writeImage, int inputRowPitch, int inputSlicePitch, int originX, int originY, int originZ, int rangeX, int rangeY, int rangeZ, boolean blockingWrite, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -630,7 +630,7 @@ public class CLCommandQueue extends CLObject implements CLResource { public CLCommandQueue putReadImage(CLImage2d<?> readImage, int inputRowPitch, int originX, int originY, int rangeX, int rangeY, boolean blockingRead, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -692,7 +692,7 @@ public class CLCommandQueue extends CLObject implements CLResource { public CLCommandQueue putReadImage(CLImage3d<?> readImage, int inputRowPitch, int inputSlicePitch, int originX, int originY, int originZ, int rangeX, int rangeY, int rangeZ, boolean blockingRead, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -756,7 +756,7 @@ public class CLCommandQueue extends CLObject implements CLResource { int dstOriginX, int dstOriginY, int rangeX, int rangeY, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -825,7 +825,7 @@ public class CLCommandQueue extends CLObject implements CLResource { int dstOriginX, int dstOriginY, int dstOriginZ, int rangeX, int rangeY, int rangeZ, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -889,7 +889,7 @@ public class CLCommandQueue extends CLObject implements CLResource { long srcOffset, int dstOriginX, int dstOriginY, int rangeX, int rangeY, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -956,7 +956,7 @@ public class CLCommandQueue extends CLObject implements CLResource { long srcOffset, int dstOriginX, int dstOriginY, int dstOriginZ, int rangeX, int rangeY, int rangeZ, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1020,7 +1020,7 @@ public class CLCommandQueue extends CLObject implements CLResource { int srcOriginX, int srcOriginY, int rangeX, int rangeY, long dstOffset, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1087,7 +1087,7 @@ public class CLCommandQueue extends CLObject implements CLResource { int srcOriginX, int srcOriginY, int srcOriginZ, int rangeX, int rangeY, int rangeZ, long dstOffset, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1145,7 +1145,7 @@ public class CLCommandQueue extends CLObject implements CLResource { */ public ByteBuffer putMapBuffer(CLBuffer<?> buffer, CLMemory.Map flag, long offset, long length, boolean blockingMap, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1205,7 +1205,7 @@ public class CLCommandQueue extends CLObject implements CLResource { int offsetX, int offsetY, int rangeX, int rangeY, boolean blockingMap, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1271,7 +1271,7 @@ public class CLCommandQueue extends CLObject implements CLResource { int offsetX, int offsetY, int offsetZ, int rangeX, int rangeY, int rangeZ, boolean blockingMap, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1315,7 +1315,7 @@ public class CLCommandQueue extends CLObject implements CLResource { */ public CLCommandQueue putUnmapMemory(CLMemory<?> memory, Buffer mapped, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1351,8 +1351,7 @@ public class CLCommandQueue extends CLObject implements CLResource { */ public CLCommandQueue putWaitForEvent(CLEventList list, int index, boolean blockingWait) { - NativeSizeBuffer ids = NativeSizeBuffer.wrap(list.IDs.getBuffer().duplicate()).position(index); - + PointerBuffer ids = list.IDs.duplicate().position(index); int ret = blockingWait ? cl.clWaitForEvents(1, ids) : cl.clEnqueueWaitForEvents(ID, 1, ids); if(ret != CL_SUCCESS) { @@ -1408,7 +1407,7 @@ public class CLCommandQueue extends CLObject implements CLResource { */ public CLCommandQueue putTask(CLKernel kernel, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1445,9 +1444,9 @@ public class CLCommandQueue extends CLObject implements CLResource { * Calls {@native clEnqueueNDRangeKernel}. */ public CLCommandQueue put1DRangeKernel(CLKernel kernel, long globalWorkOffset, long globalWorkSize, long localWorkSize, CLEventList condition, CLEventList events) { - NativeSizeBuffer globWO = null; - NativeSizeBuffer globWS = null; - NativeSizeBuffer locWS = null; + PointerBuffer globWO = null; + PointerBuffer globWS = null; + PointerBuffer locWS = null; if(globalWorkOffset != 0) { globWO = copy2NIO(ibA, globalWorkOffset); @@ -1496,9 +1495,9 @@ public class CLCommandQueue extends CLObject implements CLResource { public CLCommandQueue put2DRangeKernel(CLKernel kernel, long globalWorkOffsetX, long globalWorkOffsetY, long globalWorkSizeX, long globalWorkSizeY, long localWorkSizeX, long localWorkSizeY, CLEventList condition, CLEventList events) { - NativeSizeBuffer globalWorkOffset = null; - NativeSizeBuffer globalWorkSize = null; - NativeSizeBuffer localWorkSize = null; + PointerBuffer globalWorkOffset = null; + PointerBuffer globalWorkSize = null; + PointerBuffer localWorkSize = null; if(globalWorkOffsetX != 0 || globalWorkOffsetY != 0) { globalWorkOffset = copy2NIO(ibA, globalWorkOffsetX, globalWorkOffsetY); @@ -1546,9 +1545,9 @@ public class CLCommandQueue extends CLObject implements CLResource { public CLCommandQueue put3DRangeKernel(CLKernel kernel, long globalWorkOffsetX, long globalWorkOffsetY, long globalWorkOffsetZ, long globalWorkSizeX, long globalWorkSizeY, long globalWorkSizeZ, long localWorkSizeX, long localWorkSizeY, long localWorkSizeZ, CLEventList condition, CLEventList events) { - NativeSizeBuffer globalWorkOffset = null; - NativeSizeBuffer globalWorkSize = null; - NativeSizeBuffer localWorkSize = null; + PointerBuffer globalWorkOffset = null; + PointerBuffer globalWorkSize = null; + PointerBuffer localWorkSize = null; if(globalWorkOffsetX != 0 || globalWorkOffsetY != 0 || globalWorkOffsetZ != 0) { globalWorkOffset = copy2NIO(ibA, globalWorkOffsetX, globalWorkOffsetY, globalWorkOffsetZ); @@ -1566,7 +1565,7 @@ public class CLCommandQueue extends CLObject implements CLResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, NativeSizeBuffer globalWorkOffset, NativeSizeBuffer globalWorkSize, NativeSizeBuffer localWorkSize) { + public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, PointerBuffer globalWorkOffset, PointerBuffer globalWorkSize, PointerBuffer localWorkSize) { this.putNDRangeKernel(kernel, workDimension, globalWorkOffset, globalWorkSize, localWorkSize, null, null); return this; } @@ -1574,7 +1573,7 @@ public class CLCommandQueue extends CLObject implements CLResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, NativeSizeBuffer globalWorkOffset, NativeSizeBuffer globalWorkSize, NativeSizeBuffer localWorkSize, CLEventList events) { + public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, PointerBuffer globalWorkOffset, PointerBuffer globalWorkSize, PointerBuffer localWorkSize, CLEventList events) { this.putNDRangeKernel(kernel, workDimension, globalWorkOffset, globalWorkSize, localWorkSize, null, events); return this; } @@ -1582,10 +1581,10 @@ public class CLCommandQueue extends CLObject implements CLResource { /** * Calls {@native clEnqueueNDRangeKernel}. */ - public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, NativeSizeBuffer globalWorkOffset, - NativeSizeBuffer globalWorkSize, NativeSizeBuffer localWorkSize, CLEventList condition, CLEventList events) { + public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, PointerBuffer globalWorkOffset, + PointerBuffer globalWorkSize, PointerBuffer localWorkSize, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1658,9 +1657,9 @@ public class CLCommandQueue extends CLObject implements CLResource { /** * Calls {@native clEnqueueAcquireGLObjects}. */ - public CLCommandQueue putAcquireGLObjects(NativeSizeBuffer glObjectIDs, CLEventList condition, CLEventList events) { + public CLCommandQueue putAcquireGLObjects(PointerBuffer glObjectIDs, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1727,9 +1726,9 @@ public class CLCommandQueue extends CLObject implements CLResource { /** * Calls {@native clEnqueueReleaseGLObjects}. */ - public CLCommandQueue putReleaseGLObjects(NativeSizeBuffer glObjectIDs, CLEventList condition, CLEventList events) { + public CLCommandQueue putReleaseGLObjects(PointerBuffer glObjectIDs, CLEventList condition, CLEventList events) { - NativeSizeBuffer conditionIDs = null; + PointerBuffer conditionIDs = null; int conditions = 0; if(condition != null) { conditionIDs = condition.IDsView; @@ -1793,19 +1792,19 @@ public class CLCommandQueue extends CLObject implements CLResource { } } - private static NativeSizeBuffer copy2NIO(NativeSizeBuffer buffer, long a) { + private static PointerBuffer copy2NIO(PointerBuffer buffer, long a) { return buffer.put(2, a).position(2); } - private static NativeSizeBuffer copy2NIO(NativeSizeBuffer buffer, long a, long b) { + private static PointerBuffer copy2NIO(PointerBuffer buffer, long a, long b) { return buffer.position(1).put(a).put(b).position(1); } - private static NativeSizeBuffer copy2NIO(NativeSizeBuffer buffer, long a, long b, long c) { + private static PointerBuffer copy2NIO(PointerBuffer buffer, long a, long b, long c) { return buffer.rewind().put(a).put(b).put(c).rewind(); } - private static String toStr(NativeSizeBuffer buffer) { + private static String toStr(PointerBuffer buffer) { if(buffer == null) { return null; } diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index 147fc2ae..43755c37 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -32,7 +32,7 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.opencl.CLDevice.Type; import com.jogamp.opencl.CLSampler.AddressingMode; import com.jogamp.opencl.CLSampler.FilteringMode; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.impl.CLImageFormatImpl; import java.io.BufferedReader; import java.io.IOException; @@ -119,7 +119,7 @@ public class CLContext extends CLObject implements CLResource { if (devices == null) { - NativeSizeBuffer deviceCount = NativeSizeBuffer.allocateDirect(1); + PointerBuffer deviceCount = PointerBuffer.allocateDirect(1); int ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, 0, null, deviceCount); checkForError(ret, "can not enumerate devices"); @@ -170,7 +170,7 @@ public class CLContext extends CLObject implements CLResource { long type = toDeviceBitmap(deviceTypes); - NativeSizeBuffer properties = setupContextProperties(platform); + PointerBuffer properties = setupContextProperties(platform); ErrorDispatcher dispatcher = new ErrorDispatcher(); return new CLContext(platform, createContextFromType(dispatcher, properties, type), dispatcher); } @@ -188,7 +188,7 @@ public class CLContext extends CLObject implements CLResource { CLPlatform platform = devices[0].getPlatform(); - NativeSizeBuffer properties = setupContextProperties(platform); + PointerBuffer properties = setupContextProperties(platform); ErrorDispatcher dispatcher = new ErrorDispatcher(); CLContext context = new CLContext(platform, createContext(dispatcher, properties, devices), dispatcher); if(devices != null) { @@ -199,7 +199,7 @@ public class CLContext extends CLObject implements CLResource { return context; } - protected static long createContextFromType(CLErrorHandler handler, NativeSizeBuffer properties, long deviceType) { + protected static long createContextFromType(CLErrorHandler handler, PointerBuffer properties, long deviceType) { IntBuffer status = newDirectIntBuffer(1); long context = CLPlatform.getLowLevelCLInterface().clCreateContextFromType(properties, deviceType, handler, status); @@ -209,12 +209,12 @@ public class CLContext extends CLObject implements CLResource { return context; } - protected static long createContext(CLErrorHandler handler, NativeSizeBuffer properties, CLDevice... devices) { + protected static long createContext(CLErrorHandler handler, PointerBuffer properties, CLDevice... devices) { IntBuffer status = newDirectIntBuffer(1); - NativeSizeBuffer pb = null; + PointerBuffer pb = null; if(devices != null && devices.length != 0) { - pb = NativeSizeBuffer.allocateDirect(devices.length); + pb = PointerBuffer.allocateDirect(devices.length); for (int i = 0; i < devices.length; i++) { CLDevice device = devices[i]; if(device == null) { @@ -230,13 +230,13 @@ public class CLContext extends CLObject implements CLResource { return context; } - private static NativeSizeBuffer setupContextProperties(CLPlatform platform) { + private static PointerBuffer setupContextProperties(CLPlatform platform) { if(platform == null) { throw new RuntimeException("no OpenCL installation found"); } - return NativeSizeBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM) + return PointerBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM) .put(platform.ID).put(0) // 0 terminated array .rewind(); } diff --git a/src/com/jogamp/opencl/CLDevice.java b/src/com/jogamp/opencl/CLDevice.java index 6ca4cf38..07f7c5f2 100644 --- a/src/com/jogamp/opencl/CLDevice.java +++ b/src/com/jogamp/opencl/CLDevice.java @@ -1,5 +1,5 @@ /* - * Copyright 2009 - 2010 JogAmp Community. All rights reserved. + * Copyright (c) 2009 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: diff --git a/src/com/jogamp/opencl/CLEvent.java b/src/com/jogamp/opencl/CLEvent.java index 52b316da..928d0d92 100644 --- a/src/com/jogamp/opencl/CLEvent.java +++ b/src/com/jogamp/opencl/CLEvent.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.impl.CLTLInfoAccessor; import com.jogamp.opencl.impl.CLEventCallback; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import java.nio.Buffer; import static com.jogamp.opencl.CL.*; @@ -143,7 +143,7 @@ public class CLEvent extends CLObject implements CLResource { private class CLEventInfoAccessor extends CLTLInfoAccessor { @Override - protected int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet) { + protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { return cl.clGetEventInfo(ID, name, valueSize, value, valueSizeRet); } @@ -152,7 +152,7 @@ public class CLEvent extends CLObject implements CLResource { private class CLEventProfilingInfoAccessor extends CLTLInfoAccessor { @Override - protected int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet) { + protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { return cl.clGetEventProfilingInfo(ID, name, valueSize, value, valueSizeRet); } diff --git a/src/com/jogamp/opencl/CLEventList.java b/src/com/jogamp/opencl/CLEventList.java index 3642d915..1e882221 100644 --- a/src/com/jogamp/opencl/CLEventList.java +++ b/src/com/jogamp/opencl/CLEventList.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import com.jogamp.common.AutoCloseable; import com.jogamp.common.nio.CachedBufferFactory; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import java.util.Iterator; /** @@ -44,12 +44,12 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL /** * stores event ids for fast access. */ - final NativeSizeBuffer IDs; + final PointerBuffer IDs; /** * Points always to the first element of the id buffer. */ - final NativeSizeBuffer IDsView; + final PointerBuffer IDsView; int size; @@ -64,13 +64,13 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL public CLEventList(CachedBufferFactory factory, int capacity) { this.events = new CLEvent[capacity]; this.IDs = initIDBuffer(factory, capacity); - this.IDsView = NativeSizeBuffer.wrap(IDs.getBuffer().duplicate()); + this.IDsView = IDs.duplicate(); } public CLEventList(CachedBufferFactory factory, CLEvent... events) { this.events = events; this.IDs = initIDBuffer(factory, events.length); - this.IDsView = NativeSizeBuffer.wrap(IDs.getBuffer().duplicate()); + this.IDsView = IDs.duplicate(); for (CLEvent event : events) { if(event == null) { @@ -82,11 +82,11 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL size = events.length; } - private NativeSizeBuffer initIDBuffer(CachedBufferFactory factory, int size) { + private PointerBuffer initIDBuffer(CachedBufferFactory factory, int size) { if(factory == null) { - return NativeSizeBuffer.allocateDirect(size); + return PointerBuffer.allocateDirect(size); }else{ - return NativeSizeBuffer.wrap(factory.newDirectByteBuffer(size*NativeSizeBuffer.elementSize())); + return PointerBuffer.wrap(factory.newDirectByteBuffer(size*PointerBuffer.ELEMENT_SIZE)); } } diff --git a/src/com/jogamp/opencl/CLImage.java b/src/com/jogamp/opencl/CLImage.java index 76993d62..fa3ab800 100644 --- a/src/com/jogamp/opencl/CLImage.java +++ b/src/com/jogamp/opencl/CLImage.java @@ -1,5 +1,5 @@ /* - * Copyright 2009 - 2010 JogAmp Community. All rights reserved. + * Copyright (c) 2009 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: @@ -28,8 +28,8 @@ package com.jogamp.opencl; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.impl.CLTLInfoAccessor; -import com.jogamp.common.nio.NativeSizeBuffer; import java.nio.Buffer; import static com.jogamp.opencl.CL.*; @@ -111,7 +111,7 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> { this.id = id; } @Override - public int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet) { + public int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { return cl.clGetImageInfo(id, name, valueSize, value, valueSizeRet); } } diff --git a/src/com/jogamp/opencl/CLKernel.java b/src/com/jogamp/opencl/CLKernel.java index 4c898b4b..b2d783ee 100644 --- a/src/com/jogamp/opencl/CLKernel.java +++ b/src/com/jogamp/opencl/CLKernel.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.util.CLUtil; import com.jogamp.common.nio.Buffers; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -73,7 +73,7 @@ public class CLKernel extends CLObject implements CLResource, Cloneable { if(name == null) { // get function name - NativeSizeBuffer size = NativeSizeBuffer.wrap(buffer); + PointerBuffer size = PointerBuffer.wrap(buffer); int ret = cl.clGetKernelInfo(ID, CL_KERNEL_FUNCTION_NAME, 0, null, size); checkForError(ret, "error while asking for kernel function name"); diff --git a/src/com/jogamp/opencl/CLMemory.java b/src/com/jogamp/opencl/CLMemory.java index f299439d..a1ca4848 100644 --- a/src/com/jogamp/opencl/CLMemory.java +++ b/src/com/jogamp/opencl/CLMemory.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.gl.CLGLI; import com.jogamp.common.nio.Buffers; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.impl.CLMemObjectDestructorCallback; import java.nio.Buffer; import java.nio.IntBuffer; @@ -86,8 +86,8 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL } protected static long getSizeImpl(CL cl, long id) { - NativeSizeBuffer pb = NativeSizeBuffer.allocateDirect(1); - int ret = cl.clGetMemObjectInfo(id, CL_MEM_SIZE, NativeSizeBuffer.elementSize(), pb.getBuffer(), null); + PointerBuffer pb = PointerBuffer.allocateDirect(1); + int ret = cl.clGetMemObjectInfo(id, CL_MEM_SIZE, pb.elementSize(), pb.getBuffer(), null); checkForError(ret, "can not obtain buffer info"); return pb.get(); } diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index 4a87b43d..ab2e32b0 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -1,5 +1,5 @@ /* - * Copyright 2009 - 2010 JogAmp Community. All rights reserved. + * Copyright (c) 2009 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: @@ -33,7 +33,7 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.DynamicLookupHelper; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.os.NativeLibrary; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.opencl.spi.CLPlatformInfoAccessor; import com.jogamp.opencl.util.CLUtil; @@ -262,7 +262,7 @@ public class CLPlatform { checkForError(ret, "can not enumerate platforms"); // receive platform ids - NativeSizeBuffer platformId = NativeSizeBuffer.allocateDirect(ib.get(0)); + PointerBuffer platformId = PointerBuffer.allocateDirect(ib.get(0)); ret = cl.clGetPlatformIDs(platformId.capacity(), platformId, null); checkForError(ret, "can not enumerate platforms"); diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java index e8706a73..53c2e1d9 100644 --- a/src/com/jogamp/opencl/CLProgram.java +++ b/src/com/jogamp/opencl/CLProgram.java @@ -32,7 +32,7 @@ import com.jogamp.common.nio.CachedBufferFactory; import com.jogamp.opencl.util.CLProgramConfiguration; import com.jogamp.opencl.util.CLUtil; import com.jogamp.common.os.Platform; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.impl.BuildProgramCallback; import com.jogamp.opencl.util.CLBuildListener; @@ -78,7 +78,7 @@ public class CLProgram extends CLObject implements CLResource { IntBuffer status = newDirectIntBuffer(1); - NativeSizeBuffer length = NativeSizeBuffer.allocateDirect(1).put(0, src.length()); + PointerBuffer length = PointerBuffer.allocateDirect(1).put(0, src.length()); String[] srcArray = new String[] {src}; // Create the program @@ -102,13 +102,13 @@ public class CLProgram extends CLObject implements CLResource { binarySize += entry.getValue().length; } - int pbSize = NativeSizeBuffer.elementSize(); + int pbSize = PointerBuffer.ELEMENT_SIZE; int deviceCount = binaries.size(); CachedBufferFactory bf = CachedBufferFactory.create(binarySize + pbSize*deviceCount*3 + 4, true); - NativeSizeBuffer devices = NativeSizeBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); + PointerBuffer devices = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); PointerBuffer codeBuffers = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); - NativeSizeBuffer lengths = NativeSizeBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); + PointerBuffer lengths = PointerBuffer.wrap(bf.newDirectByteBuffer(deviceCount*pbSize)); int i = 0; for (Map.Entry<CLDevice, byte[]> entry : entries) { @@ -165,7 +165,7 @@ public class CLProgram extends CLObject implements CLResource { return ""; } - NativeSizeBuffer size = NativeSizeBuffer.allocateDirect(1); + PointerBuffer size = PointerBuffer.allocateDirect(1); int ret = cl.clGetProgramBuildInfo(ID, device.ID, flag, 0, null, size); if(ret != CL_SUCCESS) { @@ -188,7 +188,7 @@ public class CLProgram extends CLObject implements CLResource { return ""; } - NativeSizeBuffer size = NativeSizeBuffer.allocateDirect(1); + PointerBuffer size = PointerBuffer.allocateDirect(1); int ret = cl.clGetProgramInfo(ID, flag, 0, null, size); checkForError(ret, "on clGetProgramInfo"); @@ -329,10 +329,10 @@ public class CLProgram extends CLObject implements CLResource { releaseKernels(); } - NativeSizeBuffer deviceIDs = null; + PointerBuffer deviceIDs = null; int count = 0; if(devices != null && devices.length != 0) { - deviceIDs = NativeSizeBuffer.allocateDirect(devices.length); + deviceIDs = PointerBuffer.allocateDirect(devices.length); for (int i = 0; i < devices.length; i++) { deviceIDs.put(i, devices[i].ID); } @@ -431,7 +431,7 @@ public class CLProgram extends CLObject implements CLResource { if(numKernels.get(0) > 0) { - NativeSizeBuffer kernelIDs = NativeSizeBuffer.allocateDirect(numKernels.get(0)); + PointerBuffer kernelIDs = PointerBuffer.allocateDirect(numKernels.get(0)); ret = cl.clCreateKernelsInProgram(ID, kernelIDs.capacity(), kernelIDs, null); if(ret != CL_SUCCESS) { throw newException(ret, "can not create "+kernelIDs.capacity()+" kernels for "+this); @@ -495,7 +495,7 @@ public class CLProgram extends CLObject implements CLResource { if(released) { return new CLDevice[0]; } - NativeSizeBuffer size = NativeSizeBuffer.allocateDirect(1); + PointerBuffer size = PointerBuffer.allocateDirect(1); int ret = cl.clGetProgramInfo(ID, CL_PROGRAM_DEVICES, 0, null, size); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo of "+this); @@ -605,8 +605,8 @@ public class CLProgram extends CLObject implements CLResource { CLDevice[] devices = getCLDevices(); - NativeSizeBuffer sizes = NativeSizeBuffer.allocateDirect(devices.length); - int ret = cl.clGetProgramInfo(ID, CL_PROGRAM_BINARY_SIZES, sizes.capacity()*NativeSizeBuffer.elementSize(), sizes.getBuffer(), null); + PointerBuffer sizes = PointerBuffer.allocateDirect(devices.length); + int ret = cl.clGetProgramInfo(ID, CL_PROGRAM_BINARY_SIZES, sizes.capacity()*sizes.elementSize(), sizes.getBuffer(), null); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo(CL_PROGRAM_BINARY_SIZES) of "+this); } @@ -620,7 +620,7 @@ public class CLProgram extends CLObject implements CLResource { long address = InternalBufferUtil.getDirectBufferAddress(binaries); - NativeSizeBuffer addresses = NativeSizeBuffer.allocateDirect(sizes.capacity()); + PointerBuffer addresses = PointerBuffer.allocateDirect(sizes.capacity()); sizes.rewind(); while(sizes.remaining() != 0) { addresses.put(address); @@ -628,7 +628,7 @@ public class CLProgram extends CLObject implements CLResource { } addresses.rewind(); - ret = cl.clGetProgramInfo(ID, CL_PROGRAM_BINARIES, addresses.capacity()*NativeSizeBuffer.elementSize(), addresses.getBuffer(), null); + ret = cl.clGetProgramInfo(ID, CL_PROGRAM_BINARIES, addresses.capacity()*addresses.elementSize(), addresses.getBuffer(), null); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo(CL_PROGRAM_BINARIES) of "+this); } diff --git a/src/com/jogamp/opencl/CLSampler.java b/src/com/jogamp/opencl/CLSampler.java index 015445e3..8632143b 100644 --- a/src/com/jogamp/opencl/CLSampler.java +++ b/src/com/jogamp/opencl/CLSampler.java @@ -1,5 +1,5 @@ /* - * Copyright 2009 - 2010 JogAmp Community. All rights reserved. + * Copyright (c) 2009 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: @@ -28,8 +28,8 @@ package com.jogamp.opencl; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.impl.CLTLInfoAccessor; -import com.jogamp.common.nio.NativeSizeBuffer; import java.nio.Buffer; @@ -86,7 +86,7 @@ public class CLSampler extends CLObject implements CLResource { private class CLSamplerInfoAccessor extends CLTLInfoAccessor { @Override - protected int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet) { + protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { return cl.clGetSamplerInfo(ID, name, valueSize, value, valueSizeRet); } diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java index ee6c2108..5f12d033 100644 --- a/src/com/jogamp/opencl/gl/CLGLContext.java +++ b/src/com/jogamp/opencl/gl/CLGLContext.java @@ -33,7 +33,7 @@ import com.jogamp.opencl.CLDevice; import java.nio.Buffer; import com.jogamp.opencl.CLMemory.Mem; import com.jogamp.opencl.CLPlatform; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import jogamp.opengl.GLContextImpl; import jogamp.opengl.egl.EGLContext; import jogamp.opengl.macosx.cgl.MacOSXCGLContext; @@ -96,7 +96,7 @@ public final class CLGLContext extends CLContext { } long[] glID = new long[1]; - NativeSizeBuffer properties = setupContextProperties(platform, glContext, glID); + PointerBuffer properties = setupContextProperties(platform, glContext, glID); ErrorDispatcher dispatcher = createErrorHandler(); long clID = createContextFromType(dispatcher, properties, toDeviceBitmap(deviceTypes)); @@ -120,7 +120,7 @@ public final class CLGLContext extends CLContext { CLPlatform platform = devices[0].getPlatform(); long[] glID = new long[1]; - NativeSizeBuffer properties = setupContextProperties(platform, glContext, glID); + PointerBuffer properties = setupContextProperties(platform, glContext, glID); ErrorDispatcher dispatcher = createErrorHandler(); long clID = createContext(dispatcher, properties, devices); @@ -134,7 +134,7 @@ public final class CLGLContext extends CLContext { } - private static NativeSizeBuffer setupContextProperties(CLPlatform platform, GLContext glContext, long[] glID) { + private static PointerBuffer setupContextProperties(CLPlatform platform, GLContext glContext, long[] glID) { if(platform == null) { throw new RuntimeException("no OpenCL installation found"); @@ -152,14 +152,14 @@ public final class CLGLContext extends CLContext { GLContextImpl ctxImpl = (GLContextImpl)glContext; glID[0] = glContext.getHandle(); - NativeSizeBuffer properties; + PointerBuffer properties; if(glContext instanceof X11GLXContext) { // spec: "When the GLX binding API is supported, the attribute // CL_GL_CONTEXT_KHR should be set to a GLXContext handle to an // OpenGL context, and the attribute CL_GLX_DISPLAY_KHR should be // set to the Display handle of the X Window System display used to // create the OpenGL context." - properties = NativeSizeBuffer.allocateDirect(7); + properties = PointerBuffer.allocateDirect(7); long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); properties.put(CL_GL_CONTEXT_KHR).put(glID[0]) .put(CL_GLX_DISPLAY_KHR).put(displayHandle) @@ -169,7 +169,7 @@ public final class CLGLContext extends CLContext { // CL_GL_CONTEXT_KHR should be set to an HGLRC handle to an OpenGL // context, and the attribute CL_WGL_HDC_KHR should be set to the // HDC handle of the display used to create the OpenGL context." - properties = NativeSizeBuffer.allocateDirect(7); + properties = PointerBuffer.allocateDirect(7); long surfaceHandle = ctxImpl.getDrawableImpl().getNativeSurface().getSurfaceHandle(); properties.put(CL_GL_CONTEXT_KHR).put(glID[0]) .put(CL_WGL_HDC_KHR).put(surfaceHandle) @@ -180,7 +180,7 @@ public final class CLGLContext extends CLContext { // a CGL share group object." long cgl = CGL.getCGLContext(glID[0]); long group = CGL.CGLGetShareGroup(cgl); - properties = NativeSizeBuffer.allocateDirect(5); + properties = PointerBuffer.allocateDirect(5); properties.put(CL_CGL_SHAREGROUP_KHR).put(group) .put(CL_CONTEXT_PLATFORM).put(platform.ID); }else if(glContext instanceof EGLContext) { @@ -190,7 +190,7 @@ public final class CLGLContext extends CLContext { // OpenGL ES or OpenGL context, and the attribute // CL_EGL_DISPLAY_KHR should be set to the EGLDisplay handle of the // display used to create the OpenGL ES or OpenGL context." - properties = NativeSizeBuffer.allocateDirect(7); + properties = PointerBuffer.allocateDirect(7); long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); properties.put(CL_GL_CONTEXT_KHR).put(glID[0]) .put(CL_EGL_DISPLAY_KHR).put(displayHandle) diff --git a/src/com/jogamp/opencl/impl/CLImpl.java b/src/com/jogamp/opencl/impl/CLImpl.java index 8ea44201..e7f034af 100644 --- a/src/com/jogamp/opencl/impl/CLImpl.java +++ b/src/com/jogamp/opencl/impl/CLImpl.java @@ -31,7 +31,7 @@ */ package com.jogamp.opencl.impl; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.Platform; import com.jogamp.common.util.LongLongHashMap; import com.jogamp.opencl.CLErrorHandler; @@ -56,7 +56,7 @@ public class CLImpl extends CLAbstractImpl { this.contextCallbackMap.setKeyNotFoundValue(0); } - public long clCreateContext(NativeSizeBuffer properties, NativeSizeBuffer devices, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { + public long clCreateContext(PointerBuffer properties, PointerBuffer devices, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { if (properties != null && !properties.isDirect()) { throw new RuntimeException("Argument \"properties\" was not a direct buffer"); @@ -87,7 +87,7 @@ public class CLImpl extends CLAbstractImpl { 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(NativeSizeBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { + public long clCreateContextFromType(PointerBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { if (properties != null && !properties.isDirect()) { throw new RuntimeException("Argument \"properties\" was not a direct buffer"); @@ -134,7 +134,7 @@ public class CLImpl extends CLAbstractImpl { 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, NativeSizeBuffer deviceList, String options, BuildProgramCallback cb) { + public int clBuildProgram(long program, int deviceCount, PointerBuffer deviceList, String options, BuildProgramCallback cb) { if (deviceList != null && !deviceList.isDirect()) { throw new RuntimeException("Argument \"properties\" was not a direct buffer"); @@ -175,18 +175,18 @@ public class CLImpl extends CLAbstractImpl { /** 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.gluegen.common.nio.NativeSizeBuffer} - @param range a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param image_row_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param image_slice_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param event_wait_list a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param event a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param origin a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param range a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param image_row_pitch a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param image_slice_pitch a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param event_wait_list a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param event a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} @param errcode_ret a direct {@link java.nio.IntBuffer} */ public ByteBuffer clEnqueueMapImage(long command_queue, long image, int blocking_map, long map_flags, - NativeSizeBuffer origin, NativeSizeBuffer range, - NativeSizeBuffer image_row_pitch, NativeSizeBuffer image_slice_pitch, + PointerBuffer origin, PointerBuffer range, + PointerBuffer image_row_pitch, PointerBuffer image_slice_pitch, int num_events_in_wait_list, - NativeSizeBuffer event_wait_list, NativeSizeBuffer event, IntBuffer errcode_ret) { + PointerBuffer event_wait_list, PointerBuffer event, IntBuffer errcode_ret) { if (origin != null && !origin.isDirect()) { throw new CLException("Argument \"origin\" was not a direct buffer"); @@ -235,12 +235,12 @@ public class CLImpl extends CLAbstractImpl { } /** Entry point to C language function: <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.gluegen.common.nio.NativeSizeBuffer} - @param range a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param image_row_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param image_slice_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param event_wait_list a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param event a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param origin a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param range a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param image_row_pitch a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param image_slice_pitch a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param event_wait_list a direct {@link com.jogamp.gluegen.common.nio.PointerBuffer} + @param event a direct {@link com.jogamp.gluegen.common.nio.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, diff --git a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java index 1c7f9526..2f34fec5 100644 --- a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java +++ b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java @@ -4,7 +4,7 @@ package com.jogamp.opencl.impl; import java.nio.IntBuffer; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.CL; import com.jogamp.opencl.spi.CLAccessorFactory; import com.jogamp.opencl.spi.CLInfoAccessor; @@ -40,7 +40,7 @@ public class CLTLAccessorFactory implements CLAccessorFactory { } @Override - public int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet) { + public int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { return cl.clGetDeviceInfo(ID, name, valueSize, value, valueSizeRet); } @@ -57,7 +57,7 @@ public class CLTLAccessorFactory implements CLAccessorFactory { } @Override - public int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet) { + public int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { return cl.clGetPlatformInfo(ID, name, valueSize, value, valueSizeRet); } @@ -74,7 +74,7 @@ public class CLTLAccessorFactory implements CLAccessorFactory { }else{ checkForError(ret, "error while enumerating devices"); - NativeSizeBuffer deviceIDs = NativeSizeBuffer.wrap(getBB(count*NativeSizeBuffer.elementSize())); + PointerBuffer deviceIDs = PointerBuffer.wrap(getBB(count*PointerBuffer.ELEMENT_SIZE)); ret = cl.clGetDeviceIDs(ID, type, count, deviceIDs, null); checkForError(ret, "error while enumerating devices"); diff --git a/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java b/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java index ee5d0e47..c31b22a6 100644 --- a/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java +++ b/src/com/jogamp/opencl/impl/CLTLInfoAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2009 - 2010 JogAmp Community. All rights reserved. + * Copyright (c) 2009 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: @@ -29,7 +29,7 @@ package com.jogamp.opencl.impl; import com.jogamp.opencl.spi.CLInfoAccessor; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.Platform; import com.jogamp.opencl.util.CLUtil; import java.nio.Buffer; @@ -55,11 +55,11 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor { } }; - protected final static ThreadLocal<NativeSizeBuffer> localNSB = new ThreadLocal<NativeSizeBuffer>() { + protected final static ThreadLocal<PointerBuffer> localNSB = new ThreadLocal<PointerBuffer>() { @Override - protected NativeSizeBuffer initialValue() { - return NativeSizeBuffer.allocateDirect(1); + protected PointerBuffer initialValue() { + return PointerBuffer.allocateDirect(1); } }; @@ -77,7 +77,7 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor { @Override public final String getString(int key) { - NativeSizeBuffer sizeBuffer = getNSB(); + PointerBuffer sizeBuffer = getNSB(); int ret = getInfo(key, 0, null, sizeBuffer); checkForError(ret, "error while asking for info string"); @@ -122,11 +122,11 @@ public abstract class CLTLInfoAccessor implements CLInfoAccessor { } } - protected NativeSizeBuffer getNSB() { + protected PointerBuffer getNSB() { return localNSB.get(); } - protected abstract int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet); + protected abstract int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet); } diff --git a/src/com/jogamp/opencl/util/CLBuildListener.java b/src/com/jogamp/opencl/util/CLBuildListener.java index 9a520582..cec4d391 100644 --- a/src/com/jogamp/opencl/util/CLBuildListener.java +++ b/src/com/jogamp/opencl/util/CLBuildListener.java @@ -40,7 +40,7 @@ import com.jogamp.opencl.CLProgram; * Note1: registering a build callback can make {@link com.jogamp.opencl.CL#clBuildProgram} non blocking (OpenCL implementation dependent).<br/> * Note2: the thread which calls this method is unspecified. The Application should ensure propper synchronization. * @author Michael Bien - * @see com.jogamp.opencl.CL#clBuildProgram(long, int, com.jogamp.common.nio.NativeSizeBuffer, java.lang.String, com.jogamp.opencl.impl.BuildProgramCallback) + * @see com.jogamp.opencl.CL#clBuildProgram(long, int, com.jogamp.common.nio.PointerBuffer, java.lang.String, com.jogamp.opencl.impl.BuildProgramCallback) */ public interface CLBuildListener { diff --git a/test/com/jogamp/opencl/LowLevelBindingTest.java b/test/com/jogamp/opencl/LowLevelBindingTest.java index 9e603879..43e3b931 100644 --- a/test/com/jogamp/opencl/LowLevelBindingTest.java +++ b/test/com/jogamp/opencl/LowLevelBindingTest.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import java.util.Random; import com.jogamp.opencl.impl.BuildProgramCallback; -import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.nio.PointerBuffer; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -109,12 +109,12 @@ public class LowLevelBindingTest { checkForError(ret); out.println("#platforms: "+intBuffer.get(0)); - NativeSizeBuffer platformId = NativeSizeBuffer.allocateDirect(intBuffer.get(0)); + PointerBuffer platformId = PointerBuffer.allocateDirect(intBuffer.get(0)); ret = cl.clGetPlatformIDs(platformId.capacity(), platformId, null); checkForError(ret); // print platform info - NativeSizeBuffer longBuffer = NativeSizeBuffer.allocateDirect(1); + PointerBuffer longBuffer = PointerBuffer.allocateDirect(1); ByteBuffer bb = newDirectByteBuffer(128); for (int i = 0; i < platformId.capacity(); i++) { @@ -143,7 +143,7 @@ public class LowLevelBindingTest { checkForError(ret); out.println("#devices: "+intBuffer.get(0)); - NativeSizeBuffer devices = NativeSizeBuffer.allocateDirect(intBuffer.get(0)); + PointerBuffer devices = PointerBuffer.allocateDirect(intBuffer.get(0)); ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, devices.capacity(), devices, null); //print device info @@ -176,7 +176,7 @@ public class LowLevelBindingTest { checkForError(ret); out.println("#platforms: "+intBuffer.get(0)); - NativeSizeBuffer pb = NativeSizeBuffer.allocateDirect(intBuffer.get(0)); + PointerBuffer pb = PointerBuffer.allocateDirect(intBuffer.get(0)); ret = cl.clGetPlatformIDs(pb.capacity(), pb, null); checkForError(ret); @@ -187,14 +187,14 @@ public class LowLevelBindingTest { checkForError(ret); out.println("#devices: "+intBuffer.get(0)); - NativeSizeBuffer devices = NativeSizeBuffer.allocateDirect(intBuffer.get(0)); + PointerBuffer devices = PointerBuffer.allocateDirect(intBuffer.get(0)); ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, devices.capacity(), devices, null); long context = cl.clCreateContext(null, devices, null, intBuffer); checkError("on clCreateContext", intBuffer.get()); //get number of devices - NativeSizeBuffer longBuffer = NativeSizeBuffer.allocateDirect(1); + PointerBuffer longBuffer = PointerBuffer.allocateDirect(1); ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_DEVICES, 0, null, longBuffer); checkError("on clGetContextInfo", ret); @@ -223,19 +223,19 @@ public class LowLevelBindingTest { checkForError(ret); assertTrue(intBuffer.get(0) > 0); - NativeSizeBuffer pb = NativeSizeBuffer.allocateDirect(intBuffer.get(0)); + PointerBuffer pb = PointerBuffer.allocateDirect(intBuffer.get(0)); ret = cl.clGetPlatformIDs(pb.capacity(), pb, null); checkForError(ret); long platform = pb.get(0); - NativeSizeBuffer properties = NativeSizeBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM) + PointerBuffer properties = PointerBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM) .put(platform).put(0) // 0 terminated array .rewind(); long context = cl.clCreateContextFromType(properties, CL.CL_DEVICE_TYPE_ALL, null, null); out.println("context handle: "+context); checkError("on clCreateContextFromType", ret); - NativeSizeBuffer longBuffer = NativeSizeBuffer.allocateDirect(1); + PointerBuffer longBuffer = PointerBuffer.allocateDirect(1); ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_DEVICES, 0, null, longBuffer); checkError("on clGetContextInfo", ret); @@ -284,7 +284,7 @@ public class LowLevelBindingTest { // Create the program - NativeSizeBuffer lengths = NativeSizeBuffer.allocateDirect(1).put(programSource.length()).rewind(); + PointerBuffer lengths = PointerBuffer.allocateDirect(1).put(programSource.length()).rewind(); final long program = cl.clCreateProgramWithSource(context, 1, new String[] {programSource}, lengths, intBuffer); out.println("program id: "+program); checkError("on clCreateProgramWithSource", intBuffer.get(0)); @@ -370,8 +370,8 @@ public class LowLevelBindingTest { checkError("on clEnqueueWriteBuffer", ret); // Launch kernel - NativeSizeBuffer gWS = NativeSizeBuffer.allocateDirect(1).put(globalWorkSize).rewind(); - NativeSizeBuffer lWS = NativeSizeBuffer.allocateDirect(1).put(localWorkSize).rewind(); + PointerBuffer gWS = PointerBuffer.allocateDirect(1).put(globalWorkSize).rewind(); + PointerBuffer lWS = PointerBuffer.allocateDirect(1).put(localWorkSize).rewind(); ret = cl.clEnqueueNDRangeKernel(commandQueue, kernel, 1, null, gWS, lWS, 0, null, null); checkError("on clEnqueueNDRangeKernel", ret); @@ -463,4 +463,4 @@ public class LowLevelBindingTest { } -}
\ No newline at end of file +} |