diff options
Diffstat (limited to 'src/com/jogamp/opencl')
-rw-r--r-- | src/com/jogamp/opencl/CLBuffer.java | 19 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLCommandQueue.java | 10 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLContext.java | 6 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLDevice.java | 9 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLEvent.java | 11 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLImage.java | 14 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLImage2d.java | 4 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLImage3d.java | 4 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLKernel.java | 18 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLMemory.java | 56 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLObject.java | 7 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLPlatform.java | 8 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLProgram.java | 45 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLSampler.java | 10 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLUserEvent.java | 7 | ||||
-rw-r--r-- | src/com/jogamp/opencl/gl/CLGLBuffer.java | 2 | ||||
-rw-r--r-- | src/com/jogamp/opencl/impl/CLTLAccessorFactory.java | 7 | ||||
-rw-r--r-- | src/com/jogamp/opencl/spi/CLAccessorFactory.java | 3 |
18 files changed, 139 insertions, 101 deletions
diff --git a/src/com/jogamp/opencl/CLBuffer.java b/src/com/jogamp/opencl/CLBuffer.java index dfdfd2d0..03e07477 100644 --- a/src/com/jogamp/opencl/CLBuffer.java +++ b/src/com/jogamp/opencl/CLBuffer.java @@ -33,6 +33,7 @@ import java.util.List; import com.jogamp.common.nio.NativeSizeBuffer; import com.jogamp.opencl.CLMemory.Mem; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLBufferBinding; import java.nio.Buffer; import java.util.ArrayList; import java.util.Collections; @@ -58,14 +59,13 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { @SuppressWarnings("unchecked") static CLBuffer<?> create(CLContext context, int size, int flags) { - CL cl = context.cl; - int[] result = new int[1]; - if(isHostPointerFlag(flags)) { throw new IllegalArgumentException("no host pointer defined"); } - long id = cl.clCreateBuffer(context.ID, flags, size, null, result, 0); + CLBufferBinding binding = context.getPlatform().getBufferBinding(); + int[] result = new int[1]; + long id = binding.clCreateBuffer(context.ID, flags, size, null, result, 0); checkForError(result[0], "can not create cl buffer"); return new CLBuffer(context, size, id, flags); @@ -77,14 +77,14 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { throw new IllegalArgumentException("buffer is not direct"); B host_ptr = null; - CL cl = context.cl; - int[] result = new int[1]; - if(isHostPointerFlag(flags)) { host_ptr = directBuffer; } + + CLBufferBinding binding = context.getPlatform().getBufferBinding(); + int[] result = new int[1]; int size = Buffers.sizeOfBufferElem(directBuffer) * directBuffer.capacity(); - long id = cl.clCreateBuffer(context.ID, flags, size, host_ptr, result, 0); + long id = binding.clCreateBuffer(context.ID, flags, size, host_ptr, result, 0); checkForError(result[0], "can not create cl buffer"); return new CLBuffer<B>(context, directBuffer, size, id, flags); @@ -113,8 +113,9 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { info.put(offset).put(size).rewind(); int bitset = Mem.flagsToInt(flags); + CLBufferBinding binding = getPlatform().getBufferBinding(); int[] err = new int[1]; - long subID = cl.clCreateSubBuffer(ID, bitset, CL.CL_BUFFER_CREATE_TYPE_REGION, info.getBuffer(), err, 0); + long subID = binding.clCreateSubBuffer(ID, bitset, CL.CL_BUFFER_CREATE_TYPE_REGION, info.getBuffer(), err, 0); checkForError(err[0], "can not create sub buffer"); CLSubBuffer<B> clSubBuffer = new CLSubBuffer<B>(this, offset, size, slice, subID, bitset); diff --git a/src/com/jogamp/opencl/CLCommandQueue.java b/src/com/jogamp/opencl/CLCommandQueue.java index b97466d4..858a3a5b 100644 --- a/src/com/jogamp/opencl/CLCommandQueue.java +++ b/src/com/jogamp/opencl/CLCommandQueue.java @@ -32,6 +32,7 @@ import com.jogamp.common.nio.CachedBufferFactory; import com.jogamp.opencl.llb.gl.CLGL; import com.jogamp.common.nio.NativeSizeBuffer; import com.jogamp.opencl.gl.CLGLObject; +import com.jogamp.opencl.llb.CLCommandQueueBinding; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -59,6 +60,7 @@ import static com.jogamp.opencl.util.CLUtil.*; */ public class CLCommandQueue extends CLObject implements CLResource { + private final CLCommandQueueBinding cl; private final CLDevice device; private long properties; @@ -75,21 +77,23 @@ public class CLCommandQueue extends CLObject implements CLResource { this.device = device; this.properties = properties; + this.cl = context.getPlatform().getCommandQueueBinding(); int pbsize = NativeSizeBuffer.elementSize(); 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.pbA = factory.newDirectIntBuffer(1); } static CLCommandQueue create(CLContext context, CLDevice device, long properties) { int[] status = new int[1]; - long id = context.cl.clCreateCommandQueue(context.ID, device.ID, properties, status, 0); + CLCommandQueueBinding binding = context.getPlatform().getCommandQueueBinding(); + long id = binding.clCreateCommandQueue(context.ID, device.ID, properties, status, 0); if(status[0] != CL_SUCCESS) { throw newException(status[0], "can not create command queue on " + device +" with properties: " + Mode.valuesOf(properties)); diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index c66b111a..96478c27 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -96,7 +96,7 @@ public class CLContext extends CLObject implements CLResource { private final ErrorDispatcher errorHandler; protected CLContext(CLPlatform platform, long contextID, ErrorDispatcher dispatcher) { - super(CLPlatform.getLowLevelCLInterface(), contextID); + super(contextID); this.platform = platform; this.programs = synchronizedSet(new HashSet<CLProgram>()); @@ -540,7 +540,7 @@ public class CLContext extends CLObject implements CLResource { CLImageFormat[] formats = new CLImageFormat[count]; CLImageFormatImpl impl = CLImageFormatImpl.create(newDirectByteBuffer(count * CLImageFormatImpl.size())); - ret = binding.clGetSupportedImageFormats(ID, flags, type, count, impl, null, 0); + ret = binding.clGetSupportedImageFormats(ID, flags, type, count, impl, null); if(ret != CL_SUCCESS) { throw newException(ret, "error calling clGetSupportedImageFormats"); } @@ -640,7 +640,7 @@ public class CLContext extends CLObject implements CLResource { * Return the low level OpenCL interface. */ public CL getCL() { - return cl; + return getPlatform().getCLBinding(); } CLDevice getDevice(long dID) { diff --git a/src/com/jogamp/opencl/CLDevice.java b/src/com/jogamp/opencl/CLDevice.java index abfb3a07..4705d482 100644 --- a/src/com/jogamp/opencl/CLDevice.java +++ b/src/com/jogamp/opencl/CLDevice.java @@ -28,7 +28,6 @@ package com.jogamp.opencl; -import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.util.CLUtil; import com.jogamp.opencl.spi.CLInfoAccessor; import java.nio.ByteOrder; @@ -58,16 +57,16 @@ public class CLDevice extends CLObject { private final CLInfoAccessor deviceInfo; private final CLPlatform platform; - protected CLDevice(CL cl, CLPlatform platform, long id) { - super(cl, id); + protected CLDevice(CLPlatform platform, long id) { + super(id); this.platform = platform; - this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(cl, id); + this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(platform.getDeviceBinding(), id); } protected CLDevice(CLContext context, long id) { super(context, id); this.platform = context.getPlatform(); - this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(cl, id); + this.deviceInfo = platform.getAccessorFactory().createDeviceInfoAccessor(platform.getDeviceBinding(), id); } public CLCommandQueue createCommandQueue() { diff --git a/src/com/jogamp/opencl/CLEvent.java b/src/com/jogamp/opencl/CLEvent.java index 0b2c1eb7..95b82ab8 100644 --- a/src/com/jogamp/opencl/CLEvent.java +++ b/src/com/jogamp/opencl/CLEvent.java @@ -29,6 +29,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.impl.CLTLInfoAccessor; +import com.jogamp.opencl.llb.CLEventBinding; import com.jogamp.opencl.llb.impl.CLEventCallback; import com.jogamp.common.nio.NativeSizeBuffer; import java.nio.Buffer; @@ -48,9 +49,11 @@ public class CLEvent extends CLObject implements CLResource { private final CLEventInfoAccessor eventInfo; private final CLEventProfilingInfoAccessor eventProfilingInfo; + private final CLEventBinding binding; CLEvent(CLContext context, long id) { super(context, id); + binding = context.getPlatform().getEventBinding(); this.eventInfo = new CLEventInfoAccessor(); this.eventProfilingInfo = new CLEventProfilingInfoAccessor(); } @@ -64,7 +67,7 @@ public class CLEvent extends CLObject implements CLResource { // apparently only ExecutionStatus.COMPLETE is allowed -> private private void registerCallback(final CLEventListener callback, ExecutionStatus trigger) { - cl.clSetEventCallback(ID, trigger.STATUS, new CLEventCallback() { + binding.clSetEventCallback(ID, trigger.STATUS, new CLEventCallback() { @Override public void eventStateChanged(long event, int status) { callback.eventStateChanged(CLEvent.this, status); } @@ -73,7 +76,7 @@ public class CLEvent extends CLObject implements CLResource { @Override public void release() { - int ret = cl.clReleaseEvent(ID); + int ret = binding.clReleaseEvent(ID); checkForError(ret, "can not release event"); } @@ -144,7 +147,7 @@ public class CLEvent extends CLObject implements CLResource { @Override protected int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet) { - return cl.clGetEventInfo(ID, name, valueSize, value, valueSizeRet); + return binding.clGetEventInfo(ID, name, valueSize, value, valueSizeRet); } } @@ -153,7 +156,7 @@ public class CLEvent extends CLObject implements CLResource { @Override protected int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet) { - return cl.clGetEventProfilingInfo(ID, name, valueSize, value, valueSizeRet); + return binding.clGetEventProfilingInfo(ID, name, valueSize, value, valueSizeRet); } } diff --git a/src/com/jogamp/opencl/CLImage.java b/src/com/jogamp/opencl/CLImage.java index 82c29f7f..09b92b00 100644 --- a/src/com/jogamp/opencl/CLImage.java +++ b/src/com/jogamp/opencl/CLImage.java @@ -30,7 +30,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.impl.CLTLInfoAccessor; import com.jogamp.common.nio.NativeSizeBuffer; -import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLImageBinding; import java.nio.Buffer; import static com.jogamp.opencl.llb.CL.*; @@ -49,17 +49,21 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> { public final int height; protected CLImage(CLContext context, B directBuffer, CLImageFormat format, int width, int height, long id, int flags) { - this(context, directBuffer, format, new CLImageInfoAccessor(context.cl, id), width, height, id, flags); + this(context, directBuffer, format, createAccessor(context, id), width, height, id, flags); } protected CLImage(CLContext context, B directBuffer, CLImageFormat format, CLImageInfoAccessor accessor, int width, int height, long id, int flags) { - super(context, directBuffer, getSizeImpl(context.cl, id), id, flags); + super(context, directBuffer, getSizeImpl(context, id), id, flags); this.imageInfo = accessor; this.format = format; this.width = width; this.height = height; } + private static CLImageInfoAccessor createAccessor(CLContext context, long id) { + return new CLImageInfoAccessor(context.getPlatform().getImageBinding(), id); + } + protected static CLImageFormat createUninitializedImageFormat() { return new CLImageFormat(); } @@ -105,9 +109,9 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> { protected final static class CLImageInfoAccessor extends CLTLInfoAccessor { private final long id; - private final CL cl; + private final CLImageBinding cl; - public CLImageInfoAccessor(CL cl, long id) { + public CLImageInfoAccessor(CLImageBinding cl, long id) { this.cl = cl; this.id = id; } diff --git a/src/com/jogamp/opencl/CLImage2d.java b/src/com/jogamp/opencl/CLImage2d.java index 9a5d5edc..05ac966a 100644 --- a/src/com/jogamp/opencl/CLImage2d.java +++ b/src/com/jogamp/opencl/CLImage2d.java @@ -29,7 +29,7 @@ package com.jogamp.opencl; import com.jogamp.common.nio.Buffers; -import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLImageBinding; import java.nio.Buffer; import java.nio.IntBuffer; @@ -52,7 +52,7 @@ public class CLImage2d<B extends Buffer> extends CLImage<B> { static <B extends Buffer> CLImage2d<B> createImage(CLContext context, B directBuffer, int width, int height, int rowPitch, CLImageFormat format, int flags) { - CL cl = context.cl; + CLImageBinding cl = context.getPlatform().getImageBinding(); IntBuffer err = Buffers.newDirectIntBuffer(1); B host_ptr = null; if(isHostPointerFlag(flags)) { diff --git a/src/com/jogamp/opencl/CLImage3d.java b/src/com/jogamp/opencl/CLImage3d.java index 718f78e9..cdea61ad 100644 --- a/src/com/jogamp/opencl/CLImage3d.java +++ b/src/com/jogamp/opencl/CLImage3d.java @@ -28,8 +28,8 @@ package com.jogamp.opencl; -import com.jogamp.opencl.llb.CL; import com.jogamp.common.nio.Buffers; +import com.jogamp.opencl.llb.CLImageBinding; import java.nio.Buffer; import java.nio.IntBuffer; @@ -58,7 +58,7 @@ public class CLImage3d<B extends Buffer> extends CLImage<B> { static <B extends Buffer> CLImage3d<B> createImage(CLContext context, B directBuffer, int width, int height, int depth, int rowPitch, int slicePitch, CLImageFormat format, int flags) { - CL cl = context.cl; + CLImageBinding cl = context.getPlatform().getImageBinding(); IntBuffer err = Buffers.newDirectIntBuffer(1); B host_ptr = null; if(isHostPointerFlag(flags)) { diff --git a/src/com/jogamp/opencl/CLKernel.java b/src/com/jogamp/opencl/CLKernel.java index d833eca6..2c982f0f 100644 --- a/src/com/jogamp/opencl/CLKernel.java +++ b/src/com/jogamp/opencl/CLKernel.java @@ -31,6 +31,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.opencl.llb.CLKernelBinding; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -55,6 +56,7 @@ public class CLKernel extends CLObject implements CLResource, Cloneable { public final int numArgs; private final CLProgram program; + private final CLKernelBinding binding; private final ByteBuffer buffer; @@ -71,15 +73,17 @@ public class CLKernel extends CLObject implements CLResource, Cloneable { this.program = program; this.buffer = Buffers.newDirectByteBuffer((is32Bit()?4:8)*3); + binding = program.getPlatform().getKernelBinding(); + if(name == null) { // get function name NativeSizeBuffer size = NativeSizeBuffer.wrap(buffer); - int ret = cl.clGetKernelInfo(ID, CL_KERNEL_FUNCTION_NAME, 0, null, size); + int ret = binding.clGetKernelInfo(ID, CL_KERNEL_FUNCTION_NAME, 0, null, size); checkForError(ret, "error while asking for kernel function name"); ByteBuffer bb = Buffers.newDirectByteBuffer((int)size.get(0)); - ret = cl.clGetKernelInfo(ID, CL_KERNEL_FUNCTION_NAME, bb.capacity(), bb, null); + ret = binding.clGetKernelInfo(ID, CL_KERNEL_FUNCTION_NAME, bb.capacity(), bb, null); checkForError(ret, "error while asking for kernel function name"); this.name = CLUtil.clString2JavaString(bb, bb.capacity()); @@ -88,7 +92,7 @@ public class CLKernel extends CLObject implements CLResource, Cloneable { } // get number of arguments - int ret = cl.clGetKernelInfo(ID, CL_KERNEL_NUM_ARGS, buffer.capacity(), buffer, null); + int ret = binding.clGetKernelInfo(ID, CL_KERNEL_NUM_ARGS, buffer.capacity(), buffer, null); checkForError(ret, "error while asking for number of function arguments."); numArgs = buffer.getInt(0); @@ -221,7 +225,7 @@ public class CLKernel extends CLObject implements CLResource, Cloneable { " arguments for a not executable program. "+program); } - int ret = cl.clSetKernelArg(ID, argumentIndex, size, value); + int ret = binding.clSetKernelArg(ID, argumentIndex, size, value); if(ret != CL_SUCCESS) { throw newException(ret, "error setting arg "+argumentIndex+" to value "+value+" of size "+size+" of "+this); } @@ -293,7 +297,7 @@ public class CLKernel extends CLObject implements CLResource, Cloneable { * The returned array has always three elements. */ public long[] getCompileWorkGroupSize(CLDevice device) { - int ret = cl.clGetKernelWorkGroupInfo(ID, device.ID, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, (is32Bit()?4:8)*3, buffer, null); + int ret = binding.clGetKernelWorkGroupInfo(ID, device.ID, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, (is32Bit()?4:8)*3, buffer, null); if(ret != CL_SUCCESS) { throw newException(ret, "error while asking for CL_KERNEL_COMPILE_WORK_GROUP_SIZE of "+this+" on "+device); } @@ -306,7 +310,7 @@ public class CLKernel extends CLObject implements CLResource, Cloneable { } private long getWorkGroupInfo(CLDevice device, int flag) { - int ret = cl.clGetKernelWorkGroupInfo(ID, device.ID, flag, 8, buffer, null); + int ret = binding.clGetKernelWorkGroupInfo(ID, device.ID, flag, 8, buffer, null); if(ret != CL_SUCCESS) { throw newException(ret, "error while asking for clGetKernelWorkGroupInfo of "+this+" on "+device); } @@ -318,7 +322,7 @@ public class CLKernel extends CLObject implements CLResource, Cloneable { */ @Override public void release() { - int ret = cl.clReleaseKernel(ID); + int ret = binding.clReleaseKernel(ID); program.onKernelReleased(this); if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); diff --git a/src/com/jogamp/opencl/CLMemory.java b/src/com/jogamp/opencl/CLMemory.java index ee8a7bf3..d87129a4 100644 --- a/src/com/jogamp/opencl/CLMemory.java +++ b/src/com/jogamp/opencl/CLMemory.java @@ -28,10 +28,10 @@ package com.jogamp.opencl; -import com.jogamp.opencl.llb.CL; -import com.jogamp.opencl.llb.gl.CLGL; +import com.jogamp.opencl.llb.CLMemObjBinding; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.llb.impl.CLMemObjectDestructorCallback; import java.nio.Buffer; import java.nio.IntBuffer; @@ -56,6 +56,8 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL // depends on the nio buffer type protected int elementSize; protected int clCapacity; + + private final CLMemObjBinding binding; protected <Buffer> CLMemory(CLContext context, long size, long id, int flags) { this(context, null, size, id, flags); @@ -66,6 +68,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL this.buffer = directBuffer; this.FLAGS = flags; this.size = size; + this.binding = context.getPlatform().getMemObjectBinding(); initElementSize(); initCLCapacity(); } @@ -86,15 +89,16 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL || (flags & CL_MEM_USE_HOST_PTR) != 0; } - protected static long getSizeImpl(CL cl, long id) { + protected static long getSizeImpl(CLContext context, long id) { NativeSizeBuffer pb = NativeSizeBuffer.allocateDirect(1); - int ret = cl.clGetMemObjectInfo(id, CL_MEM_SIZE, NativeSizeBuffer.elementSize(), pb.getBuffer(), null); + CLMemObjBinding binding = context.getPlatform().getMemObjectBinding(); + int ret = binding.clGetMemObjectInfo(id, CL_MEM_SIZE, NativeSizeBuffer.elementSize(), pb.getBuffer(), null); checkForError(ret, "can not obtain buffer info"); return pb.get(); } protected static CL getCL(CLContext context) { - return context.cl; + return context.getCL(); } /** @@ -102,7 +106,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL * when the memory object is released. */ public void registerDestructorCallback(final CLMemObjectListener listener) { - cl.clSetMemObjectDestructorCallback(ID, new CLMemObjectDestructorCallback() { + binding.clSetMemObjectDestructorCallback(ID, new CLMemObjectDestructorCallback() { @Override public void memoryDeallocated(long memObjID) { listener.memoryDeallocated(CLMemory.this); @@ -190,7 +194,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL */ public int getMapCount() { IntBuffer value = Buffers.newDirectIntBuffer(1); - int ret = cl.clGetMemObjectInfo(ID, CL_MEM_MAP_COUNT, 4, value, null); + int ret = binding.clGetMemObjectInfo(ID, CL_MEM_MAP_COUNT, 4, value, null); checkForError(ret, "can not obtain buffer map count."); return value.get(); } @@ -218,7 +222,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL @Override public void release() { - int ret = cl.clReleaseMemObject(ID); + int ret = binding.clReleaseMemObject(ID); context.onMemoryReleased(this); if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); @@ -229,24 +233,24 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL /** * Returns the OpenGL buffer type of this shared buffer. */ - @Deprecated - /*public*/ final GLObjectType _getGLObjectType() { - int[] array = new int[1]; - int ret = ((CLGL)cl).clGetGLObjectInfo(ID, array, 0, null, 0); - CLException.checkForError(ret, "error while asking for gl object info"); - return GLObjectType.valueOf(array[0]); - } - - /** - * Returns the OpenGL object id of this shared buffer. - */ - @Deprecated - /*public*/ final int _getGLObjectID() { - int[] array = new int[1]; - int ret = ((CLGL)cl).clGetGLObjectInfo(ID, null, 0, array, 0); - CLException.checkForError(ret, "error while asking for gl object info"); - return array[0]; - } +// @Deprecated +// /*public*/ final GLObjectType _getGLObjectType() { +// int[] array = new int[1]; +// int ret = ((CLGL)cl).clGetGLObjectInfo(ID, array, 0, null, 0); +// CLException.checkForError(ret, "error while asking for gl object info"); +// return GLObjectType.valueOf(array[0]); +// } +// +// /** +// * Returns the OpenGL object id of this shared buffer. +// */ +// @Deprecated +// /*public*/ final int _getGLObjectID() { +// int[] array = new int[1]; +// int ret = ((CLGL)cl).clGetGLObjectInfo(ID, null, 0, array, 0); +// CLException.checkForError(ret, "error while asking for gl object info"); +// return array[0]; +// } @Override public boolean equals(Object obj) { diff --git a/src/com/jogamp/opencl/CLObject.java b/src/com/jogamp/opencl/CLObject.java index eb1f0abf..3273c4db 100644 --- a/src/com/jogamp/opencl/CLObject.java +++ b/src/com/jogamp/opencl/CLObject.java @@ -29,7 +29,6 @@ package com.jogamp.opencl; import com.jogamp.common.AutoCloseable; -import com.jogamp.opencl.llb.CL; /** * Common superclass for all OpenCL objects. @@ -44,16 +43,12 @@ abstract class CLObject implements AutoCloseable { protected CLContext context; - protected final CL cl; - - CLObject(CL cl, long ID) { - this.cl = cl; + CLObject(long ID) { this.context = null; this.ID = ID; } CLObject(CLContext context, long ID) { - this.cl = context.cl; this.context = context; this.ID = ID; } diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index 3b65b41f..9e5308f9 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -358,7 +358,7 @@ public class CLPlatform { } protected CLDevice createDevice(long id) { - return new CLDevice(cl, this, id); + return new CLDevice(this, id); } private static <I> void addIfAccepted(I item, List<I> list, Filter<I>[] filters) { @@ -594,9 +594,13 @@ public class CLPlatform { return cl; } + protected CL getCLBinding() { + return cl; + } + @Override public String toString() { - return "CLPlatform [name: " + getName() + return getClass().getSimpleName()+" [name: " + getName() +", vendor: "+getVendor() +", profile: "+getProfile() +", version: "+getVersion()+"]"; diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java index b991c1e9..18c981f2 100644 --- a/src/com/jogamp/opencl/CLProgram.java +++ b/src/com/jogamp/opencl/CLProgram.java @@ -29,11 +29,13 @@ package com.jogamp.opencl; import com.jogamp.common.nio.CachedBufferFactory; +import com.jogamp.opencl.llb.CLProgramBinding; 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.opencl.llb.CLKernelBinding; import com.jogamp.opencl.llb.impl.BuildProgramCallback; import com.jogamp.opencl.util.CLBuildListener; import java.nio.ByteBuffer; @@ -62,6 +64,7 @@ import static com.jogamp.common.nio.Buffers.*; public class CLProgram extends CLObject implements CLResource { private final static ReentrantLock buildLock = new ReentrantLock(); + private final CLProgramBinding binding; private final Set<CLKernel> kernels; private Map<CLDevice, Status> buildStatusMap; @@ -72,6 +75,7 @@ public class CLProgram extends CLObject implements CLResource { private CLProgram(CLContext context, long id) { super(context, id); this.kernels = new HashSet<CLKernel>(); + this.binding = context.getPlatform().getProgramBinding(); } static CLProgram create(CLContext context, String src) { @@ -82,7 +86,8 @@ public class CLProgram extends CLObject implements CLResource { String[] srcArray = new String[] {src}; // Create the program - long id = context.cl.clCreateProgramWithSource(context.ID, 1, srcArray, length, status); + CLProgramBinding binding = context.getPlatform().getProgramBinding(); + long id = binding.clCreateProgramWithSource(context.ID, 1, srcArray, length, status); int err = status.get(); if(err != CL_SUCCESS) { @@ -127,7 +132,8 @@ public class CLProgram extends CLObject implements CLResource { IntBuffer errBuffer = bf.newDirectIntBuffer(1); // IntBuffer status = newDirectByteBuffer(binaries.size()*4).asIntBuffer(); - long id = context.cl.clCreateProgramWithBinary(context.ID, devices.capacity(), devices, lengths, codeBuffers, /*status*/null, errBuffer); + CLProgramBinding binding = context.getPlatform().getProgramBinding(); + long id = binding.clCreateProgramWithBinary(context.ID, devices.capacity(), devices, lengths, codeBuffers, /*status*/null, errBuffer); // while(status.remaining() != 0) { // checkForError(status.get(), "unable to load binaries on all devices"); @@ -167,14 +173,14 @@ public class CLProgram extends CLObject implements CLResource { NativeSizeBuffer size = NativeSizeBuffer.allocateDirect(1); - int ret = cl.clGetProgramBuildInfo(ID, device.ID, flag, 0, null, size); + int ret = binding.clGetProgramBuildInfo(ID, device.ID, flag, 0, null, size); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramBuildInfo with "+device); } ByteBuffer buffer = newDirectByteBuffer((int)size.get(0)); - ret = cl.clGetProgramBuildInfo(ID, device.ID, flag, buffer.capacity(), buffer, null); + ret = binding.clGetProgramBuildInfo(ID, device.ID, flag, buffer.capacity(), buffer, null); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramBuildInfo with "+device); } @@ -190,12 +196,12 @@ public class CLProgram extends CLObject implements CLResource { NativeSizeBuffer size = NativeSizeBuffer.allocateDirect(1); - int ret = cl.clGetProgramInfo(ID, flag, 0, null, size); + int ret = binding.clGetProgramInfo(ID, flag, 0, null, size); checkForError(ret, "on clGetProgramInfo"); ByteBuffer buffer = newDirectByteBuffer((int)size.get(0)); - ret = cl.clGetProgramInfo(ID, flag, buffer.capacity(), buffer, null); + ret = binding.clGetProgramInfo(ID, flag, buffer.capacity(), buffer, null); checkForError(ret, "on clGetProgramInfo"); return CLUtil.clString2JavaString(buffer, (int)size.get(0)); @@ -205,12 +211,15 @@ public class CLProgram extends CLObject implements CLResource { ByteBuffer buffer = newDirectByteBuffer(4); - int ret = cl.clGetProgramBuildInfo(ID, device.ID, flag, buffer.capacity(), buffer, null); + int ret = binding.clGetProgramBuildInfo(ID, device.ID, flag, buffer.capacity(), buffer, null); checkForError(ret, "error on clGetProgramBuildInfo"); return buffer.getInt(); } + private CLKernelBinding getKernelBinding() { + return getPlatform().getKernelBinding(); + } /** * Builds this program for all devices associated with the context. @@ -369,7 +378,7 @@ public class CLProgram extends CLObject implements CLResource { buildLock.lock(); boolean exception = true; try{ - ret = cl.clBuildProgram(ID, count, deviceIDs, options, callback); + ret = binding.clBuildProgram(ID, count, deviceIDs, options, callback); exception = false; }finally{ if(callback == null || exception) { @@ -402,7 +411,7 @@ public class CLProgram extends CLObject implements CLResource { } int[] err = new int[1]; - long id = cl.clCreateKernel(ID, kernelName, err, 0); + long id = getKernelBinding().clCreateKernel(ID, kernelName, err, 0); if(err[0] != CL_SUCCESS) { throw newException(err[0], "unable to create Kernel with name: "+kernelName); } @@ -424,7 +433,8 @@ public class CLProgram extends CLObject implements CLResource { HashMap<String, CLKernel> newKernels = new HashMap<String, CLKernel>(); IntBuffer numKernels = newDirectByteBuffer(4).asIntBuffer(); - int ret = cl.clCreateKernelsInProgram(ID, 0, null, numKernels); + CLKernelBinding kernelBinding = getKernelBinding(); + int ret = kernelBinding.clCreateKernelsInProgram(ID, 0, null, numKernels); if(ret != CL_SUCCESS) { throw newException(ret, "can not create kernels for "+this); } @@ -432,7 +442,7 @@ public class CLProgram extends CLObject implements CLResource { if(numKernels.get(0) > 0) { NativeSizeBuffer kernelIDs = NativeSizeBuffer.allocateDirect(numKernels.get(0)); - ret = cl.clCreateKernelsInProgram(ID, kernelIDs.capacity(), kernelIDs, null); + ret = kernelBinding.clCreateKernelsInProgram(ID, kernelIDs.capacity(), kernelIDs, null); if(ret != CL_SUCCESS) { throw newException(ret, "can not create "+kernelIDs.capacity()+" kernels for "+this); } @@ -470,8 +480,8 @@ public class CLProgram extends CLObject implements CLResource { executable = false; released = true; buildStatusMap = null; - - int ret = cl.clReleaseProgram(ID); + + int ret = binding.clReleaseProgram(ID); context.onProgramReleased(this); if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); @@ -495,14 +505,15 @@ public class CLProgram extends CLObject implements CLResource { if(released) { return new CLDevice[0]; } + NativeSizeBuffer size = NativeSizeBuffer.allocateDirect(1); - int ret = cl.clGetProgramInfo(ID, CL_PROGRAM_DEVICES, 0, null, size); + int ret = binding.clGetProgramInfo(ID, CL_PROGRAM_DEVICES, 0, null, size); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo of "+this); } ByteBuffer bb = newDirectByteBuffer((int) size.get(0)); - ret = cl.clGetProgramInfo(ID, CL_PROGRAM_DEVICES, bb.capacity(), bb, null); + ret = binding.clGetProgramInfo(ID, CL_PROGRAM_DEVICES, bb.capacity(), bb, null); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo of "+this); } @@ -606,7 +617,7 @@ 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); + int ret = binding.clGetProgramInfo(ID, CL_PROGRAM_BINARY_SIZES, sizes.capacity()*NativeSizeBuffer.elementSize(), sizes.getBuffer(), null); if(ret != CL_SUCCESS) { throw newException(ret, "on clGetProgramInfo(CL_PROGRAM_BINARY_SIZES) of "+this); } @@ -628,7 +639,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 = binding.clGetProgramInfo(ID, CL_PROGRAM_BINARIES, addresses.capacity()*NativeSizeBuffer.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 04751be2..141deb5a 100644 --- a/src/com/jogamp/opencl/CLSampler.java +++ b/src/com/jogamp/opencl/CLSampler.java @@ -30,6 +30,7 @@ package com.jogamp.opencl; import com.jogamp.opencl.impl.CLTLInfoAccessor; import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.opencl.llb.CLSamplerBinding; import java.nio.Buffer; @@ -45,16 +46,19 @@ import static com.jogamp.opencl.util.CLUtil.*; public class CLSampler extends CLObject implements CLResource { private final CLSamplerInfoAccessor samplerInfo; + private final CLSamplerBinding binding; private CLSampler(CLContext context, long id, AddressingMode addrMode, FilteringMode filtMode, boolean normalizedCoords) { super(context, id); + this.binding = context.getPlatform().getSamplerBinding(); this.samplerInfo = new CLSamplerInfoAccessor(); } static CLSampler create(CLContext context, AddressingMode addrMode, FilteringMode filtMode, boolean normalizedCoords) { int[] error = new int[1]; - long id = context.cl.clCreateSampler(context.ID, clBoolean(normalizedCoords), addrMode.MODE, filtMode.MODE, error, 0); + CLSamplerBinding binding = context.getPlatform().getSamplerBinding(); + long id = binding.clCreateSampler(context.ID, clBoolean(normalizedCoords), addrMode.MODE, filtMode.MODE, error, 0); checkForError(error[0], "can not create sampler"); return new CLSampler(context, id, addrMode, filtMode, normalizedCoords); @@ -76,7 +80,7 @@ public class CLSampler extends CLObject implements CLResource { @Override public void release() { - int ret = cl.clReleaseSampler(ID); + int ret = binding.clReleaseSampler(ID); context.onSamplerReleased(this); if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); @@ -87,7 +91,7 @@ public class CLSampler extends CLObject implements CLResource { @Override protected int getInfo(int name, long valueSize, Buffer value, NativeSizeBuffer valueSizeRet) { - return cl.clGetSamplerInfo(ID, name, valueSize, value, valueSizeRet); + return binding.clGetSamplerInfo(ID, name, valueSize, value, valueSizeRet); } } diff --git a/src/com/jogamp/opencl/CLUserEvent.java b/src/com/jogamp/opencl/CLUserEvent.java index 22839b0a..d1a9da70 100644 --- a/src/com/jogamp/opencl/CLUserEvent.java +++ b/src/com/jogamp/opencl/CLUserEvent.java @@ -34,6 +34,7 @@ package com.jogamp.opencl; import static com.jogamp.opencl.CLException.*; import static com.jogamp.opencl.llb.CL.*; +import com.jogamp.opencl.llb.CLEventBinding; /** * Custom, user controlled event. @@ -50,8 +51,9 @@ public class CLUserEvent extends CLEvent { * Creates a new user event. */ public static CLUserEvent create(CLContext context) { + CLEventBinding binding = context.getPlatform().getEventBinding(); int[] error = new int[1]; - long ID = context.cl.clCreateUserEvent(context.ID, error, 0); + long ID = binding.clCreateUserEvent(context.ID, error, 0); checkForError(error[0], "can not create user event."); return new CLUserEvent(context, ID); } @@ -61,7 +63,8 @@ public class CLUserEvent extends CLEvent { * Calls {@native clSetUserEventStatus}. */ public CLUserEvent setStatus(CLEvent.ExecutionStatus status) { - int err = cl.clSetUserEventStatus(ID, status.STATUS); + CLEventBinding binding = getPlatform().getEventBinding(); + int err = binding.clSetUserEventStatus(ID, status.STATUS); if(err != CL_SUCCESS) { newException(err, "can not set status "+status); } diff --git a/src/com/jogamp/opencl/gl/CLGLBuffer.java b/src/com/jogamp/opencl/gl/CLGLBuffer.java index 55cede88..7d41b0eb 100644 --- a/src/com/jogamp/opencl/gl/CLGLBuffer.java +++ b/src/com/jogamp/opencl/gl/CLGLBuffer.java @@ -83,7 +83,7 @@ public final class CLGLBuffer<B extends Buffer> extends CLBuffer<B> implements C * {@link CLCommandQueue#putAcquireGLObject(com.jogamp.opencl.gl.CLGLObject)}. */ public void updateSize() { - size = getSizeImpl(cl, ID); + size = getSizeImpl(context, ID); initCLCapacity(); } diff --git a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java index b5ad1d8a..ab4fcca6 100644 --- a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java +++ b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java @@ -6,6 +6,7 @@ package com.jogamp.opencl.impl; import java.nio.IntBuffer; import com.jogamp.common.nio.NativeSizeBuffer; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLDeviceBinding; import com.jogamp.opencl.spi.CLAccessorFactory; import com.jogamp.opencl.spi.CLInfoAccessor; import com.jogamp.opencl.spi.CLPlatformInfoAccessor; @@ -20,7 +21,7 @@ import static com.jogamp.opencl.CLException.*; public class CLTLAccessorFactory implements CLAccessorFactory { @Override - public CLInfoAccessor createDeviceInfoAccessor(CL cl, long id) { + public CLInfoAccessor createDeviceInfoAccessor(CLDeviceBinding cl, long id) { return new CLDeviceInfoAccessor(cl, id); } @@ -31,10 +32,10 @@ public class CLTLAccessorFactory implements CLAccessorFactory { private final static class CLDeviceInfoAccessor extends CLTLInfoAccessor { - private final CL cl; + private final CLDeviceBinding cl; private final long ID; - private CLDeviceInfoAccessor(CL cl, long id) { + private CLDeviceInfoAccessor(CLDeviceBinding cl, long id) { this.cl = cl; this.ID = id; } diff --git a/src/com/jogamp/opencl/spi/CLAccessorFactory.java b/src/com/jogamp/opencl/spi/CLAccessorFactory.java index 752891b4..4bafe933 100644 --- a/src/com/jogamp/opencl/spi/CLAccessorFactory.java +++ b/src/com/jogamp/opencl/spi/CLAccessorFactory.java @@ -4,6 +4,7 @@ package com.jogamp.opencl.spi; import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLDeviceBinding; /** * Implementations of this interface are factories responsible for creating CLAccessors. @@ -11,7 +12,7 @@ import com.jogamp.opencl.llb.CL; */ public interface CLAccessorFactory { - CLInfoAccessor createDeviceInfoAccessor(CL cl, long id); + CLInfoAccessor createDeviceInfoAccessor(CLDeviceBinding cl, long id); CLPlatformInfoAccessor createPlatformInfoAccessor(CL cl, long id); |