aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/jogamp')
-rw-r--r--src/com/jogamp/opencl/CLBuffer.java20
-rw-r--r--src/com/jogamp/opencl/CLCommandQueue.java43
-rw-r--r--src/com/jogamp/opencl/CLContext.java55
-rw-r--r--src/com/jogamp/opencl/CLDevice.java10
-rw-r--r--src/com/jogamp/opencl/CLEvent.java18
-rw-r--r--src/com/jogamp/opencl/CLEventList.java45
-rw-r--r--src/com/jogamp/opencl/CLException.java2
-rw-r--r--src/com/jogamp/opencl/CLImage.java15
-rw-r--r--src/com/jogamp/opencl/CLImage2d.java3
-rw-r--r--src/com/jogamp/opencl/CLImage3d.java5
-rw-r--r--src/com/jogamp/opencl/CLImageFormat.java4
-rw-r--r--src/com/jogamp/opencl/CLKernel.java66
-rw-r--r--src/com/jogamp/opencl/CLMemory.java62
-rw-r--r--src/com/jogamp/opencl/CLObject.java22
-rw-r--r--src/com/jogamp/opencl/CLObjectResource.java51
-rw-r--r--src/com/jogamp/opencl/CLPlatform.java70
-rw-r--r--src/com/jogamp/opencl/CLProgram.java53
-rw-r--r--src/com/jogamp/opencl/CLResource.java4
-rw-r--r--src/com/jogamp/opencl/CLSampler.java17
-rw-r--r--src/com/jogamp/opencl/CLUserEvent.java9
-rw-r--r--src/com/jogamp/opencl/gl/CLGLBuffer.java8
-rw-r--r--src/com/jogamp/opencl/gl/CLGLContext.java11
-rw-r--r--src/com/jogamp/opencl/gl/CLGLImage2d.java10
-rw-r--r--src/com/jogamp/opencl/gl/CLGLTexture2d.java13
-rw-r--r--src/com/jogamp/opencl/gl/CLGLTexture3d.java13
-rw-r--r--src/com/jogamp/opencl/gl/package.html7
-rw-r--r--src/com/jogamp/opencl/impl/CLTLAccessorFactory.java9
-rw-r--r--src/com/jogamp/opencl/llb/gl/package.html7
-rw-r--r--src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java (renamed from src/com/jogamp/opencl/impl/BuildProgramCallback.java)8
-rw-r--r--src/com/jogamp/opencl/llb/impl/CLEventCallback.java (renamed from src/com/jogamp/opencl/impl/CLEventCallback.java)2
-rw-r--r--src/com/jogamp/opencl/llb/impl/CLImpl.java (renamed from src/com/jogamp/opencl/impl/CLImpl.java)35
-rw-r--r--src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java (renamed from src/com/jogamp/opencl/impl/CLMemObjectDestructorCallback.java)2
-rw-r--r--src/com/jogamp/opencl/llb/package.html7
-rw-r--r--src/com/jogamp/opencl/package.html7
-rw-r--r--src/com/jogamp/opencl/spi/CLAccessorFactory.java5
-rw-r--r--src/com/jogamp/opencl/spi/package.html7
-rw-r--r--src/com/jogamp/opencl/util/CLBuildListener.java4
-rw-r--r--src/com/jogamp/opencl/util/CLDeviceFilters.java8
-rw-r--r--src/com/jogamp/opencl/util/CLInfo.java2
-rw-r--r--src/com/jogamp/opencl/util/CLMultiContext.java21
-rw-r--r--src/com/jogamp/opencl/util/CLUtil.java2
-rw-r--r--src/com/jogamp/opencl/util/JOCLVersion.java6
-rw-r--r--src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java11
-rw-r--r--src/com/jogamp/opencl/util/concurrent/CLQueueContext.java6
-rw-r--r--src/com/jogamp/opencl/util/concurrent/package.html7
-rw-r--r--src/com/jogamp/opencl/util/package.html7
46 files changed, 574 insertions, 225 deletions
diff --git a/src/com/jogamp/opencl/CLBuffer.java b/src/com/jogamp/opencl/CLBuffer.java
index 57fba461..99721413 100644
--- a/src/com/jogamp/opencl/CLBuffer.java
+++ b/src/com/jogamp/opencl/CLBuffer.java
@@ -32,6 +32,8 @@ import com.jogamp.common.nio.Buffers;
import java.util.List;
import com.jogamp.common.nio.PointerBuffer;
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;
@@ -57,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);
@@ -76,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);
@@ -112,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 7f3a4292..eedb0bd4 100644
--- a/src/com/jogamp/opencl/CLCommandQueue.java
+++ b/src/com/jogamp/opencl/CLCommandQueue.java
@@ -29,9 +29,10 @@
package com.jogamp.opencl;
import com.jogamp.common.nio.CachedBufferFactory;
-import com.jogamp.opencl.gl.CLGLI;
+import com.jogamp.opencl.llb.gl.CLGL;
import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.opencl.gl.CLGLObject;
+import com.jogamp.opencl.llb.CLCommandQueueBinding;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
@@ -41,7 +42,7 @@ import java.util.EnumSet;
import java.util.List;
import static com.jogamp.opencl.CLException.*;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
import static com.jogamp.opencl.util.CLUtil.*;
/**
@@ -57,8 +58,9 @@ import static com.jogamp.opencl.util.CLUtil.*;
* @see CLDevice#createCommandQueue(com.jogamp.opencl.CLCommandQueue.Mode...)
* @author Michael Bien
*/
-public class CLCommandQueue extends CLObject implements CLResource {
+public class CLCommandQueue extends CLObjectResource {
+ private final CLCommandQueueBinding cl;
private final CLDevice device;
private long properties;
@@ -75,6 +77,7 @@ public class CLCommandQueue extends CLObject implements CLResource {
this.device = device;
this.properties = properties;
+ this.cl = context.getPlatform().getCommandQueueBinding();
int pbsize = PointerBuffer.ELEMENT_SIZE;
CachedBufferFactory factory = CachedBufferFactory.create(9*pbsize + 4, true);
@@ -89,7 +92,8 @@ public class CLCommandQueue extends CLObject implements CLResource {
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));
@@ -1351,12 +1355,16 @@ public class CLCommandQueue extends CLObject implements CLResource {
*/
public CLCommandQueue putWaitForEvent(CLEventList list, int index, boolean blockingWait) {
- PointerBuffer ids = list.IDs.duplicate().position(index);
- int ret = blockingWait ? cl.clWaitForEvents(1, ids)
- : cl.clEnqueueWaitForEvents(ID, 1, ids);
- if(ret != CL_SUCCESS) {
- throw newException(ret, "can not "+ (blockingWait?"blocking": "") +" wait for event #" + index+ " in "+list);
+ if(blockingWait) {
+ list.waitForEvent(index);
+ } else {
+ PointerBuffer ids = list.getEventBuffer(index);
+ int ret = cl.clEnqueueWaitForEvents(ID, 1, ids);
+ if(ret != CL_SUCCESS) {
+ throw newException(ret, "can not "+ (blockingWait?"blocking": "") +" wait for event #" + index+ " in "+list);
+ }
}
+
return this;
}
@@ -1364,10 +1372,13 @@ public class CLCommandQueue extends CLObject implements CLResource {
* Calls {@native clWaitForEvents} if blockingWait equals true otherwise {@native clEnqueueWaitForEvents}.
*/
public CLCommandQueue putWaitForEvents(CLEventList list, boolean blockingWait) {
- int ret = blockingWait ? cl.clWaitForEvents(list.size, list.IDsView)
- : cl.clEnqueueWaitForEvents(ID, list.size, list.IDsView);
- if(ret != CL_SUCCESS) {
- throw newException(ret, "can not "+ (blockingWait?"blocking": "") +" wait for events " + list);
+ if(blockingWait) {
+ list.waitForEvents();
+ }else{
+ int ret = cl.clEnqueueWaitForEvents(ID, list.size, list.IDsView);
+ if(ret != CL_SUCCESS) {
+ throw newException(ret, "can not "+ (blockingWait?"blocking": "") +" wait for events " + list);
+ }
}
return this;
}
@@ -1666,7 +1677,7 @@ public class CLCommandQueue extends CLObject implements CLResource {
conditions = condition.size;
}
- CLGLI xl = (CLGLI) cl;
+ CLGL xl = (CLGL) cl;
int ret = xl.clEnqueueAcquireGLObjects(ID, glObjectIDs.remaining(), glObjectIDs,
conditions, conditionIDs,
@@ -1735,7 +1746,7 @@ public class CLCommandQueue extends CLObject implements CLResource {
conditions = condition.size;
}
- CLGLI xl = (CLGLI) cl;
+ CLGL xl = (CLGL) cl;
int ret = xl.clEnqueueReleaseGLObjects(ID, glObjectIDs.remaining(), glObjectIDs,
conditions, conditionIDs,
@@ -1784,7 +1795,9 @@ public class CLCommandQueue extends CLObject implements CLResource {
return (Mode.OUT_OF_ORDER_MODE.QUEUE_MODE & properties) != 0;
}
+ @Override
public void release() {
+ super.release();
int ret = cl.clReleaseCommandQueue(ID);
context.onCommandQueueReleased(device, this);
if(ret != CL_SUCCESS) {
diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java
index 43755c37..7073e5d3 100644
--- a/src/com/jogamp/opencl/CLContext.java
+++ b/src/com/jogamp/opencl/CLContext.java
@@ -28,12 +28,14 @@
package com.jogamp.opencl;
+import com.jogamp.opencl.llb.CL;
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.PointerBuffer;
-import com.jogamp.opencl.impl.CLImageFormatImpl;
+import com.jogamp.opencl.llb.CLContextBinding;
+import com.jogamp.opencl.llb.impl.CLImageFormatImpl;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -57,7 +59,7 @@ import static java.lang.System.*;
import static com.jogamp.opencl.CLException.*;
import static com.jogamp.common.nio.Buffers.*;
import static com.jogamp.common.os.Platform.*;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
import static com.jogamp.opencl.CLBuffer.*;
import static java.util.Collections.*;
@@ -79,7 +81,7 @@ import static java.util.Collections.*;
*
* @author Michael Bien
*/
-public class CLContext extends CLObject implements CLResource {
+public class CLContext extends CLObjectResource {
protected CLDevice[] devices;
@@ -94,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>());
@@ -115,17 +117,17 @@ public class CLContext extends CLObject implements CLResource {
}
- private synchronized void initDevices() {
+ private synchronized void initDevices(CLContextBinding cl) {
if (devices == null) {
PointerBuffer deviceCount = PointerBuffer.allocateDirect(1);
- int ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, 0, null, deviceCount);
+ int ret = cl.clGetContextInfo(ID, CL_CONTEXT_DEVICES, 0, null, deviceCount);
checkForError(ret, "can not enumerate devices");
ByteBuffer deviceIDs = Buffers.newDirectByteBuffer((int)deviceCount.get());
- ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null);
+ ret = cl.clGetContextInfo(ID, CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null);
checkForError(ret, "can not enumerate devices");
devices = new CLDevice[deviceIDs.capacity() / (is32Bit() ? 4 : 8)];
@@ -172,7 +174,7 @@ public class CLContext extends CLObject implements CLResource {
PointerBuffer properties = setupContextProperties(platform);
ErrorDispatcher dispatcher = new ErrorDispatcher();
- return new CLContext(platform, createContextFromType(dispatcher, properties, type), dispatcher);
+ return new CLContext(platform, createContextFromType(platform, dispatcher, properties, type), dispatcher);
}
/**
@@ -190,7 +192,7 @@ public class CLContext extends CLObject implements CLResource {
PointerBuffer properties = setupContextProperties(platform);
ErrorDispatcher dispatcher = new ErrorDispatcher();
- CLContext context = new CLContext(platform, createContext(dispatcher, properties, devices), dispatcher);
+ CLContext context = new CLContext(platform, createContext(platform, dispatcher, properties, devices), dispatcher);
if(devices != null) {
for (int i = 0; i < devices.length; i++) {
devices[i].setContext(context);
@@ -199,18 +201,17 @@ public class CLContext extends CLObject implements CLResource {
return context;
}
- protected static long createContextFromType(CLErrorHandler handler, PointerBuffer properties, long deviceType) {
-
+ protected static long createContextFromType(CLPlatform platform, CLErrorHandler handler, PointerBuffer properties, long deviceType) {
IntBuffer status = newDirectIntBuffer(1);
- long context = CLPlatform.getLowLevelCLInterface().clCreateContextFromType(properties, deviceType, handler, status);
+ CLContextBinding cl = platform.getContextBinding();
+ long context = cl.clCreateContextFromType(properties, deviceType, handler, status);
checkForError(status.get(), "can not create CL context");
return context;
}
- protected static long createContext(CLErrorHandler handler, PointerBuffer properties, CLDevice... devices) {
-
+ protected static long createContext(CLPlatform platform, CLErrorHandler handler, PointerBuffer properties, CLDevice... devices) {
IntBuffer status = newDirectIntBuffer(1);
PointerBuffer pb = null;
if(devices != null && devices.length != 0) {
@@ -223,7 +224,8 @@ public class CLContext extends CLObject implements CLResource {
pb.put(i, device.ID);
}
}
- long context = CLPlatform.getLowLevelCLInterface().clCreateContext(properties, pb, handler, status);
+ CLContextBinding cl = platform.getContextBinding();
+ long context = cl.clCreateContext(properties, pb, handler, status);
checkForError(status.get(), "can not create CL context");
@@ -231,12 +233,11 @@ public class CLContext extends CLObject implements CLResource {
}
private static PointerBuffer setupContextProperties(CLPlatform platform) {
-
if(platform == null) {
throw new RuntimeException("no OpenCL installation found");
}
- return PointerBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM)
+ return PointerBuffer.allocateDirect(3).put(CL_CONTEXT_PLATFORM)
.put(platform.ID).put(0) // 0 terminated array
.rewind();
}
@@ -497,6 +498,7 @@ public class CLContext extends CLObject implements CLResource {
*/
@Override
public synchronized void release() {
+ super.release();
try{
//release all resources
@@ -504,15 +506,12 @@ public class CLContext extends CLObject implements CLResource {
release(memoryObjects);
release(samplers);
- for (CLDevice device : getDevices()) {
- Collection<CLCommandQueue> queues = queuesMap.get(device);
- if(queues != null) {
- release(queues);
- }
+ for (List<CLCommandQueue> queues : queuesMap.values()) {
+ release(queues);
}
}finally{
- int ret = cl.clReleaseContext(ID);
+ int ret = platform.getContextBinding().clReleaseContext(ID);
checkForError(ret, "error releasing context");
}
@@ -524,8 +523,10 @@ public class CLContext extends CLObject implements CLResource {
private CLImageFormat[] getSupportedImageFormats(int flags, int type) {
+ CLContextBinding binding = platform.getContextBinding();
+
int[] entries = new int[1];
- int ret = cl.clGetSupportedImageFormats(ID, flags, type, 0, null, entries, 0);
+ int ret = binding.clGetSupportedImageFormats(ID, flags, type, 0, null, entries, 0);
if(ret != CL_SUCCESS) {
throw newException(ret, "error calling clGetSupportedImageFormats");
}
@@ -537,7 +538,7 @@ public class CLContext extends CLObject implements CLResource {
CLImageFormat[] formats = new CLImageFormat[count];
CLImageFormatImpl impl = CLImageFormatImpl.create(newDirectByteBuffer(count * CLImageFormatImpl.size()));
- ret = cl.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");
}
@@ -629,7 +630,7 @@ public class CLContext extends CLObject implements CLResource {
* Returns all devices associated with this CLContext.
*/
public CLDevice[] getDevices() {
- initDevices();
+ initDevices(platform.getContextBinding());
return devices;
}
@@ -637,7 +638,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 07f7c5f2..b47deb2b 100644
--- a/src/com/jogamp/opencl/CLDevice.java
+++ b/src/com/jogamp/opencl/CLDevice.java
@@ -40,7 +40,7 @@ import java.util.Map;
import java.util.Scanner;
import java.util.Set;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
/**
* This object represents an OpenCL device.
@@ -57,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 928d0d92..d1bfeffc 100644
--- a/src/com/jogamp/opencl/CLEvent.java
+++ b/src/com/jogamp/opencl/CLEvent.java
@@ -29,11 +29,12 @@
package com.jogamp.opencl;
import com.jogamp.opencl.impl.CLTLInfoAccessor;
-import com.jogamp.opencl.impl.CLEventCallback;
+import com.jogamp.opencl.llb.CLEventBinding;
+import com.jogamp.opencl.llb.impl.CLEventCallback;
import com.jogamp.common.nio.PointerBuffer;
import java.nio.Buffer;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
import static com.jogamp.opencl.CLException.*;
/**
@@ -44,13 +45,15 @@ import static com.jogamp.opencl.CLException.*;
* {@link com.jogamp.opencl.CLCommandQueue.Mode#PROFILING_MODE}.
* @author Michael Bien
*/
-public class CLEvent extends CLObject implements CLResource {
+public class CLEvent extends CLObjectResource {
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,8 @@ public class CLEvent extends CLObject implements CLResource {
@Override
public void release() {
- int ret = cl.clReleaseEvent(ID);
+ super.release();
+ int ret = binding.clReleaseEvent(ID);
checkForError(ret, "can not release event");
}
@@ -144,7 +148,7 @@ public class CLEvent extends CLObject implements CLResource {
@Override
protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) {
- return cl.clGetEventInfo(ID, name, valueSize, value, valueSizeRet);
+ return binding.clGetEventInfo(ID, name, valueSize, value, valueSizeRet);
}
}
@@ -153,7 +157,7 @@ public class CLEvent extends CLObject implements CLResource {
@Override
protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) {
- return cl.clGetEventProfilingInfo(ID, name, valueSize, value, valueSizeRet);
+ return binding.clGetEventProfilingInfo(ID, name, valueSize, value, valueSizeRet);
}
}
diff --git a/src/com/jogamp/opencl/CLEventList.java b/src/com/jogamp/opencl/CLEventList.java
index 1e882221..53136e2a 100644
--- a/src/com/jogamp/opencl/CLEventList.java
+++ b/src/com/jogamp/opencl/CLEventList.java
@@ -98,10 +98,46 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL
events[size] = new CLEvent(context, IDs.get());
size++;
}
+
+ PointerBuffer getEventBuffer(int index) {
+ return IDs.duplicate();
+ }
+
+ /**
+ * Waits for all events in this list to occur.
+ * If this list is empty this method won't do anything.
+ */
+ public void waitForEvents() {
+ if(size > 0) {
+ events[0].getPlatform().getEventBinding().clWaitForEvents(size, IDsView);
+ }
+ }
+
+ /**
+ * Waits for all events of the specified region in this list to occur.
+ * Will throw IndexOutOfBoundsException if indices are out of bounds.
+ */
+ public void waitForEvents(int start, int range) {
+ if(start+range < size || range <= 0) {
+ throw new IndexOutOfBoundsException("args: [start: "+start+" range: "+range+"], eventcount: "+size);
+ }
+
+ final PointerBuffer view = getEventBuffer(start);
+ getEvent(start).getPlatform().getEventBinding().clWaitForEvents(range, view);
+ }
+
+ /**
+ * Waits for the event with the given index in this list to occur.
+ */
+ public void waitForEvent(int index) {
+ final PointerBuffer view = getEventBuffer(index);
+ getEvent(index).getPlatform().getEventBinding().clWaitForEvents(1, view);
+ }
/**
* Releases all CLEvents in this list.
*/
+ @Override
public void release() {
for (int i = 0; i < size; i++) {
events[i].release();
@@ -115,6 +151,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL
* @deprecated use {@link #release()} instead.
*/
@Deprecated
+ @Override
public final void close() throws Exception {
release();
}
@@ -139,6 +176,11 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL
return events.length;
}
+ public boolean isReleased() {
+ return size == 0;
+ }
+
+ @Override
public Iterator<CLEvent> iterator() {
return new EventIterator(events, size);
}
@@ -167,10 +209,12 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL
this.size = size;
}
+ @Override
public boolean hasNext() {
return index < size;
}
+ @Override
public CLEvent next() {
if(hasNext())
return events[index++];
@@ -178,6 +222,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL
return null;
}
+ @Override
public void remove() {
throw new UnsupportedOperationException("remove() not supported.");
}
diff --git a/src/com/jogamp/opencl/CLException.java b/src/com/jogamp/opencl/CLException.java
index 59eda198..f776730b 100644
--- a/src/com/jogamp/opencl/CLException.java
+++ b/src/com/jogamp/opencl/CLException.java
@@ -28,7 +28,7 @@
package com.jogamp.opencl;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.gl.CLGL.*;
/**
* Main Exception type for runtime OpenCL errors and failed function calls (e.g. returning not CL_SUCCESS).
diff --git a/src/com/jogamp/opencl/CLImage.java b/src/com/jogamp/opencl/CLImage.java
index fa3ab800..e2daff9c 100644
--- a/src/com/jogamp/opencl/CLImage.java
+++ b/src/com/jogamp/opencl/CLImage.java
@@ -30,9 +30,10 @@ package com.jogamp.opencl;
import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.opencl.impl.CLTLInfoAccessor;
+import com.jogamp.opencl.llb.CLImageBinding;
import java.nio.Buffer;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
/**
*
@@ -48,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();
}
@@ -104,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 9e43e4b2..05ac966a 100644
--- a/src/com/jogamp/opencl/CLImage2d.java
+++ b/src/com/jogamp/opencl/CLImage2d.java
@@ -29,6 +29,7 @@
package com.jogamp.opencl;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.opencl.llb.CLImageBinding;
import java.nio.Buffer;
import java.nio.IntBuffer;
@@ -51,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 4e29e06a..cdea61ad 100644
--- a/src/com/jogamp/opencl/CLImage3d.java
+++ b/src/com/jogamp/opencl/CLImage3d.java
@@ -29,10 +29,11 @@
package com.jogamp.opencl;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.opencl.llb.CLImageBinding;
import java.nio.Buffer;
import java.nio.IntBuffer;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
import static com.jogamp.opencl.CLException.*;
/**
@@ -57,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/CLImageFormat.java b/src/com/jogamp/opencl/CLImageFormat.java
index 5f014e0d..08fe7c7f 100644
--- a/src/com/jogamp/opencl/CLImageFormat.java
+++ b/src/com/jogamp/opencl/CLImageFormat.java
@@ -28,9 +28,9 @@
package com.jogamp.opencl;
-import com.jogamp.opencl.impl.CLImageFormatImpl;
+import com.jogamp.opencl.llb.impl.CLImageFormatImpl;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
/**
* Represents the OpenCL image format with its channeltype and order.
diff --git a/src/com/jogamp/opencl/CLKernel.java b/src/com/jogamp/opencl/CLKernel.java
index b2d783ee..135174c4 100644
--- a/src/com/jogamp/opencl/CLKernel.java
+++ b/src/com/jogamp/opencl/CLKernel.java
@@ -31,11 +31,12 @@ package com.jogamp.opencl;
import com.jogamp.opencl.util.CLUtil;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.opencl.llb.CLKernelBinding;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import static com.jogamp.opencl.CLException.*;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
import static com.jogamp.common.os.Platform.*;
/**
@@ -49,12 +50,13 @@ import static com.jogamp.common.os.Platform.*;
* @see CLProgram#createCLKernels()
* @author Michael Bien
*/
-public class CLKernel extends CLObject implements CLResource, Cloneable {
+public class CLKernel extends CLObjectResource implements Cloneable {
public final String name;
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
PointerBuffer size = PointerBuffer.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);
@@ -106,6 +110,12 @@ public class CLKernel extends CLObject implements CLResource, Cloneable {
return this;
}
+ public CLKernel putArg(short value) {
+ setArg(argIndex, value);
+ argIndex++;
+ return this;
+ }
+
public CLKernel putArg(int value) {
setArg(argIndex, value);
argIndex++;
@@ -167,6 +177,11 @@ public class CLKernel extends CLObject implements CLResource, Cloneable {
return this;
}
+ public CLKernel setArg(int argumentIndex, short value) {
+ setArgument(argumentIndex, 2, wrap(value));
+ return this;
+ }
+
public CLKernel setArg(int argumentIndex, int value) {
setArgument(argumentIndex, 4, wrap(value));
return this;
@@ -205,6 +220,31 @@ public class CLKernel extends CLObject implements CLResource, Cloneable {
return this;
}
+ public CLKernel setArgs(Object... values) {
+ if(values == null || values.length == 0) {
+ throw new IllegalArgumentException("values array was empty or null.");
+ }
+ for (int i = 0; i < values.length; i++) {
+ Object value = values[i];
+ if(value instanceof CLMemory<?>) {
+ setArg(i, (CLMemory<?>)value);
+ }else if(value instanceof Short) {
+ setArg(i, (Short)value);
+ }else if(value instanceof Integer) {
+ setArg(i, (Integer)value);
+ }else if(value instanceof Long) {
+ setArg(i, (Long)value);
+ }else if(value instanceof Float) {
+ setArg(i, (Float)value);
+ }else if(value instanceof Double) {
+ setArg(i, (Double)value);
+ }else{
+ throw new IllegalArgumentException(value + " is not a valid argument.");
+ }
+ }
+ return this;
+ }
+
private void setArgs(int startIndex, CLMemory<?>... values) {
for (int i = 0; i < values.length; i++) {
setArg(i+startIndex, values[i]);
@@ -221,7 +261,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);
}
@@ -255,6 +295,10 @@ public class CLKernel extends CLObject implements CLResource, Cloneable {
return buffer.putDouble(0, value);
}
+ private Buffer wrap(short value) {
+ return buffer.putShort(0, value);
+ }
+
private Buffer wrap(int value) {
return buffer.putInt(0, value);
}
@@ -293,7 +337,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 +350,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);
}
@@ -316,10 +360,12 @@ public class CLKernel extends CLObject implements CLResource, Cloneable {
/**
* Releases all resources of this kernel from its context.
*/
+ @Override
public void release() {
- int ret = cl.clReleaseKernel(ID);
+ super.release();
+ int ret = binding.clReleaseKernel(ID);
program.onKernelReleased(this);
- if(ret != CL.CL_SUCCESS) {
+ 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 a1ca4848..281d042f 100644
--- a/src/com/jogamp/opencl/CLMemory.java
+++ b/src/com/jogamp/opencl/CLMemory.java
@@ -28,10 +28,11 @@
package com.jogamp.opencl;
-import com.jogamp.opencl.gl.CLGLI;
+import com.jogamp.opencl.llb.CLMemObjBinding;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
-import com.jogamp.opencl.impl.CLMemObjectDestructorCallback;
+import com.jogamp.opencl.llb.CL;
+import com.jogamp.opencl.llb.impl.CLMemObjectDestructorCallback;
import java.nio.Buffer;
import java.nio.IntBuffer;
import java.util.ArrayList;
@@ -39,14 +40,14 @@ import java.util.EnumSet;
import java.util.List;
import static com.jogamp.opencl.CLException.*;
-import static com.jogamp.opencl.gl.CLGLI.*;
+import static com.jogamp.opencl.llb.gl.CLGL.*;
/**
* Common superclass for all OpenCL memory types.
* Represents an OpenCL memory object and wraps an optional NIO buffer.
* @author Michael Bien
*/
-public abstract class CLMemory <B extends Buffer> extends CLObject implements CLResource {
+public abstract class CLMemory <B extends Buffer> extends CLObjectResource {
B buffer;
protected final int FLAGS;
@@ -55,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);
@@ -65,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();
}
@@ -85,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) {
PointerBuffer pb = PointerBuffer.allocateDirect(1);
- int ret = cl.clGetMemObjectInfo(id, CL_MEM_SIZE, pb.elementSize(), pb.getBuffer(), null);
+ CLMemObjBinding binding = context.getPlatform().getMemObjectBinding(); // FIXME: CL separation makes this pretty complicated !
+ int ret = binding.clGetMemObjectInfo(id, CL_MEM_SIZE, pb.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();
}
/**
@@ -101,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);
@@ -189,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();
}
@@ -217,7 +222,8 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL
@Override
public void release() {
- int ret = cl.clReleaseMemObject(ID);
+ super.release();
+ int ret = binding.clReleaseMemObject(ID);
context.onMemoryReleased(this);
if(ret != CL_SUCCESS) {
throw newException(ret, "can not release "+this);
@@ -228,24 +234,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 = ((CLGLI)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 = ((CLGLI)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 54031884..58a6333c 100644
--- a/src/com/jogamp/opencl/CLObject.java
+++ b/src/com/jogamp/opencl/CLObject.java
@@ -28,13 +28,12 @@
package com.jogamp.opencl;
-import com.jogamp.common.AutoCloseable;
/**
* Common superclass for all OpenCL objects.
* @author Michael Bien
*/
-abstract class CLObject implements AutoCloseable {
+public abstract class CLObject {
/**
* The OpenCL object handle.
@@ -43,34 +42,17 @@ 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;
}
/**
- * Implementation detail.
- * TODO remove as soon we have extension methods.
- * @deprecated This method is not intended to be called from client code.
- * @see java.lang.AutoCloseable
- */
- @Deprecated
- public final void close() {
- if(this instanceof CLResource) {
- ((CLResource)this).release();
- }
- }
-
- /**
* Returns the context for this OpenCL object.
*/
public CLContext getContext() {
diff --git a/src/com/jogamp/opencl/CLObjectResource.java b/src/com/jogamp/opencl/CLObjectResource.java
new file mode 100644
index 00000000..fcea22c1
--- /dev/null
+++ b/src/com/jogamp/opencl/CLObjectResource.java
@@ -0,0 +1,51 @@
+/*
+ * Created on Saturday, June 18 2011 02:36
+ */
+package com.jogamp.opencl;
+
+import com.jogamp.common.AutoCloseable;
+
+/**
+ * Releasable resource with an CL object ID.
+ * @author Michael Bien
+ */
+abstract class CLObjectResource extends CLObject implements CLResource, AutoCloseable {
+
+ private boolean released;
+
+ public CLObjectResource(long ID) {
+ super(ID);
+ }
+
+ public CLObjectResource(CLContext context, long ID) {
+ super(context, ID);
+ }
+
+ public void release() {
+ if(released) {
+ throw new RuntimeException(getClass().getSimpleName()+" was already released.");
+ }else{
+ released = true;
+ }
+ }
+
+ /**
+ * Implementation detail.
+ * TODO remove as soon we have extension methods.
+ * @deprecated This method is not intended to be called from client code.
+ * @see java.lang.AutoCloseable
+ */
+ @Deprecated
+ @Override
+ public final void close() {
+ if(this instanceof CLResource) {
+ ((CLResource)this).release();
+ }
+ }
+
+ public boolean isReleased() {
+ return released;
+ }
+
+
+}
diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java
index ab2e32b0..bd93caa3 100644
--- a/src/com/jogamp/opencl/CLPlatform.java
+++ b/src/com/jogamp/opencl/CLPlatform.java
@@ -28,6 +28,12 @@
package com.jogamp.opencl;
+import com.jogamp.opencl.llb.CLPlatformBinding;
+import com.jogamp.opencl.llb.CLProgramBinding;
+import com.jogamp.opencl.llb.CLSamplerBinding;
+import com.jogamp.opencl.llb.CLKernelBinding;
+import com.jogamp.opencl.llb.CLImageBinding;
+import com.jogamp.opencl.llb.CL;
import com.jogamp.opencl.impl.CLTLAccessorFactory;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.os.DynamicLookupHelper;
@@ -35,10 +41,16 @@ import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.os.NativeLibrary;
import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.gluegen.runtime.FunctionAddressResolver;
+import com.jogamp.opencl.llb.CLBufferBinding;
+import com.jogamp.opencl.llb.CLCommandQueueBinding;
+import com.jogamp.opencl.llb.CLContextBinding;
+import com.jogamp.opencl.llb.CLDeviceBinding;
+import com.jogamp.opencl.llb.CLEventBinding;
+import com.jogamp.opencl.llb.CLMemObjBinding;
import com.jogamp.opencl.spi.CLPlatformInfoAccessor;
import com.jogamp.opencl.util.CLUtil;
-import com.jogamp.opencl.impl.CLImpl;
-import com.jogamp.opencl.impl.CLProcAddressTable;
+import com.jogamp.opencl.llb.impl.CLImpl;
+import com.jogamp.opencl.llb.impl.CLProcAddressTable;
import com.jogamp.opencl.spi.CLAccessorFactory;
import com.jogamp.opencl.util.Filter;
import com.jogamp.opencl.util.JOCLVersion;
@@ -55,7 +67,7 @@ import java.security.PrivilegedAction;
import static java.security.AccessController.*;
import static com.jogamp.opencl.CLException.*;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
/**
* CLPlatfrorm representing a OpenCL implementation (e.g. graphics driver).
@@ -346,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) {
@@ -538,9 +550,57 @@ public class CLPlatform {
return info;
}
+ protected CLBufferBinding getBufferBinding() {
+ return cl;
+ }
+
+ protected CLCommandQueueBinding getCommandQueueBinding() {
+ return cl;
+ }
+
+ protected CLContextBinding getContextBinding() {
+ return cl;
+ }
+
+ protected CLDeviceBinding getDeviceBinding() {
+ return cl;
+ }
+
+ protected CLEventBinding getEventBinding() {
+ return cl;
+ }
+
+ protected CLImageBinding getImageBinding() {
+ return cl;
+ }
+
+ protected CLKernelBinding getKernelBinding() {
+ return cl;
+ }
+
+ protected CLMemObjBinding getMemObjectBinding() {
+ return cl;
+ }
+
+ protected CLPlatformBinding getPlatformBinding() {
+ return cl;
+ }
+
+ protected CLProgramBinding getProgramBinding() {
+ return cl;
+ }
+
+ protected CLSamplerBinding getSamplerBinding() {
+ 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 53c2e1d9..d373d5d3 100644
--- a/src/com/jogamp/opencl/CLProgram.java
+++ b/src/com/jogamp/opencl/CLProgram.java
@@ -29,12 +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.PointerBuffer;
-import com.jogamp.common.nio.PointerBuffer;
-import com.jogamp.opencl.impl.BuildProgramCallback;
+import com.jogamp.opencl.llb.CLKernelBinding;
+import com.jogamp.opencl.llb.impl.BuildProgramCallback;
import com.jogamp.opencl.util.CLBuildListener;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
@@ -48,7 +49,7 @@ import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import static com.jogamp.opencl.CLException.*;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
import static com.jogamp.common.nio.Buffers.*;
/**
@@ -59,9 +60,10 @@ import static com.jogamp.common.nio.Buffers.*;
* @see CLContext#createProgram(java.util.Map)
* @author Michael Bien
*/
-public class CLProgram extends CLObject implements CLResource {
+public class CLProgram extends CLObjectResource {
private final static ReentrantLock buildLock = new ReentrantLock();
+ private final CLProgramBinding binding;
private final Set<CLKernel> kernels;
private Map<CLDevice, Status> buildStatusMap;
@@ -72,6 +74,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 +85,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 +131,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 +172,14 @@ public class CLProgram extends CLObject implements CLResource {
PointerBuffer size = PointerBuffer.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 +195,12 @@ public class CLProgram extends CLObject implements CLResource {
PointerBuffer size = PointerBuffer.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 +210,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 +377,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 +410,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 +432,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 +441,7 @@ public class CLProgram extends CLObject implements CLResource {
if(numKernels.get(0) > 0) {
PointerBuffer kernelIDs = PointerBuffer.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);
}
@@ -465,13 +474,14 @@ public class CLProgram extends CLObject implements CLResource {
@Override
public void release() {
+ super.release();
releaseKernels();
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];
}
+
PointerBuffer size = PointerBuffer.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();
PointerBuffer sizes = PointerBuffer.allocateDirect(devices.length);
- int ret = cl.clGetProgramInfo(ID, CL_PROGRAM_BINARY_SIZES, sizes.capacity()*sizes.elementSize(), sizes.getBuffer(), null);
+ int ret = binding.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);
}
@@ -628,7 +639,7 @@ public class CLProgram extends CLObject implements CLResource {
}
addresses.rewind();
- ret = cl.clGetProgramInfo(ID, CL_PROGRAM_BINARIES, addresses.capacity()*addresses.elementSize(), addresses.getBuffer(), null);
+ ret = binding.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/CLResource.java b/src/com/jogamp/opencl/CLResource.java
index 4918e725..cd14c59c 100644
--- a/src/com/jogamp/opencl/CLResource.java
+++ b/src/com/jogamp/opencl/CLResource.java
@@ -39,4 +39,8 @@ public interface CLResource {
*/
public void release();
+ /**
+ * Returns true if {@link #release()} has been called.
+ */
+ public boolean isReleased();
}
diff --git a/src/com/jogamp/opencl/CLSampler.java b/src/com/jogamp/opencl/CLSampler.java
index 8632143b..f19f58de 100644
--- a/src/com/jogamp/opencl/CLSampler.java
+++ b/src/com/jogamp/opencl/CLSampler.java
@@ -30,11 +30,12 @@ package com.jogamp.opencl;
import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.opencl.impl.CLTLInfoAccessor;
+import com.jogamp.opencl.llb.CLSamplerBinding;
import java.nio.Buffer;
import static com.jogamp.opencl.CLException.*;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
import static com.jogamp.opencl.util.CLUtil.*;
/**
@@ -42,19 +43,22 @@ import static com.jogamp.opencl.util.CLUtil.*;
* @see CLContext#createSampler(com.jogamp.opencl.CLSampler.AddressingMode, com.jogamp.opencl.CLSampler.FilteringMode, boolean)
* @author Michael Bien
*/
-public class CLSampler extends CLObject implements CLResource {
+public class CLSampler extends CLObjectResource {
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,9 +80,10 @@ public class CLSampler extends CLObject implements CLResource {
@Override
public void release() {
- int ret = cl.clReleaseSampler(ID);
+ super.release();
+ int ret = binding.clReleaseSampler(ID);
context.onSamplerReleased(this);
- if(ret != CL.CL_SUCCESS) {
+ if(ret != CL_SUCCESS) {
throw newException(ret, "can not release "+this);
}
}
@@ -87,7 +92,7 @@ public class CLSampler extends CLObject implements CLResource {
@Override
protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer 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 4bbbf3b8..d1a9da70 100644
--- a/src/com/jogamp/opencl/CLUserEvent.java
+++ b/src/com/jogamp/opencl/CLUserEvent.java
@@ -33,7 +33,8 @@
package com.jogamp.opencl;
import static com.jogamp.opencl.CLException.*;
-import static com.jogamp.opencl.CL.*;
+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 148aa83d..7d41b0eb 100644
--- a/src/com/jogamp/opencl/gl/CLGLBuffer.java
+++ b/src/com/jogamp/opencl/gl/CLGLBuffer.java
@@ -32,6 +32,7 @@ import com.jogamp.opencl.CLBuffer;
import com.jogamp.opencl.CLCommandQueue;
import com.jogamp.opencl.CLContext;
import com.jogamp.opencl.CLException;
+import com.jogamp.opencl.llb.gl.CLGL;
import java.nio.Buffer;
import javax.media.opengl.GLContext;
@@ -58,7 +59,7 @@ public final class CLGLBuffer<B extends Buffer> extends CLBuffer<B> implements C
static <B extends Buffer> CLGLBuffer<B> create(CLContext context, B directBuffer, long size, int flags, int glObject) {
checkBuffer(directBuffer, flags);
- CLGLI clgli = (CLGLI)getCL(context);
+ CLGL clgli = (CLGL)getCL(context);
int[] result = new int[1];
long id = clgli.clCreateFromGLBuffer(context.ID, flags, glObject, result, 0);
@@ -82,14 +83,16 @@ 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();
}
+ @Override
public int getGLObjectID() {
return GLID;
}
+ @Override
public GLObjectType getGLObjectType() {
return GLObjectType.GL_OBJECT_BUFFER;
}
@@ -99,6 +102,7 @@ public final class CLGLBuffer<B extends Buffer> extends CLBuffer<B> implements C
return (CLGLContext) super.getContext();
}
+ @Override
public GLContext getGLContext() {
return getContext().getGLContext();
}
diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java
index 5f12d033..dcddd3df 100644
--- a/src/com/jogamp/opencl/gl/CLGLContext.java
+++ b/src/com/jogamp/opencl/gl/CLGLContext.java
@@ -28,6 +28,7 @@
package com.jogamp.opencl.gl;
+import com.jogamp.opencl.llb.gl.CLGL;
import com.jogamp.opencl.CLContext;
import com.jogamp.opencl.CLDevice;
import java.nio.Buffer;
@@ -42,7 +43,7 @@ import jogamp.opengl.windows.wgl.WindowsWGLContext;
import jogamp.opengl.x11.glx.X11GLXContext;
import javax.media.opengl.GLContext;
-import static com.jogamp.opencl.gl.CLGLI.*;
+import static com.jogamp.opencl.llb.gl.CLGL.*;
/**
* OpenCL Context supporting JOGL-JOCL interoperablity.
@@ -98,7 +99,7 @@ public final class CLGLContext extends CLContext {
long[] glID = new long[1];
PointerBuffer properties = setupContextProperties(platform, glContext, glID);
ErrorDispatcher dispatcher = createErrorHandler();
- long clID = createContextFromType(dispatcher, properties, toDeviceBitmap(deviceTypes));
+ long clID = createContextFromType(platform, dispatcher, properties, toDeviceBitmap(deviceTypes));
return new CLGLContext(platform, glContext, clID, glID[0], dispatcher);
@@ -122,7 +123,7 @@ public final class CLGLContext extends CLContext {
long[] glID = new long[1];
PointerBuffer properties = setupContextProperties(platform, glContext, glID);
ErrorDispatcher dispatcher = createErrorHandler();
- long clID = createContext(dispatcher, properties, devices);
+ long clID = createContext(platform, dispatcher, properties, devices);
CLGLContext context = new CLGLContext(platform, glContext, clID, glID[0], dispatcher);
if(devices != null) {
@@ -308,8 +309,8 @@ public final class CLGLContext extends CLContext {
* Return the low level OpenCL interface with OpenGL interoperability.
*/
@Override
- public CLGLI getCL() {
- return (CLGLI)super.getCL();
+ public CLGL getCL() {
+ return (CLGL)super.getCL();
}
/**
diff --git a/src/com/jogamp/opencl/gl/CLGLImage2d.java b/src/com/jogamp/opencl/gl/CLGLImage2d.java
index 94ad7e84..dd6b9d5a 100644
--- a/src/com/jogamp/opencl/gl/CLGLImage2d.java
+++ b/src/com/jogamp/opencl/gl/CLGLImage2d.java
@@ -28,15 +28,16 @@
package com.jogamp.opencl.gl;
-import com.jogamp.opencl.CL;
+import com.jogamp.opencl.llb.CL;
+import com.jogamp.opencl.llb.gl.CLGL;
import com.jogamp.opencl.CLContext;
import com.jogamp.opencl.CLImage2d;
import com.jogamp.opencl.CLImageFormat;
-import com.jogamp.opencl.impl.CLImageFormatImpl;
+import com.jogamp.opencl.llb.impl.CLImageFormatImpl;
import java.nio.Buffer;
import javax.media.opengl.GLContext;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
/**
* 2D OpenCL image representing an OpenGL renderbuffer.
@@ -60,7 +61,7 @@ public class CLGLImage2d<B extends Buffer> extends CLImage2d<B> implements CLGLO
CL cl = getCL(context);
int[] result = new int[1];
- CLGLI clgli = (CLGLI)cl;
+ CLGL clgli = (CLGL)cl;
long id = clgli.clCreateFromGLRenderbuffer(context.ID, flags, glObject, result, 0);
@@ -94,6 +95,7 @@ public class CLGLImage2d<B extends Buffer> extends CLImage2d<B> implements CLGLO
return (CLGLContext) super.getContext();
}
+ @Override
public GLContext getGLContext() {
return getContext().getGLContext();
}
diff --git a/src/com/jogamp/opencl/gl/CLGLTexture2d.java b/src/com/jogamp/opencl/gl/CLGLTexture2d.java
index faf1bdc8..7cbd95d5 100644
--- a/src/com/jogamp/opencl/gl/CLGLTexture2d.java
+++ b/src/com/jogamp/opencl/gl/CLGLTexture2d.java
@@ -28,13 +28,15 @@
package com.jogamp.opencl.gl;
-import com.jogamp.opencl.CL;
+import com.jogamp.opencl.llb.CL;
import com.jogamp.opencl.CLContext;
import com.jogamp.opencl.CLImageFormat;
-import com.jogamp.opencl.impl.CLImageFormatImpl;
+import com.jogamp.opencl.llb.impl.CLImageFormatImpl;
+import com.jogamp.opencl.llb.gl.CLGL;
import java.nio.Buffer;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.CLException.*;
+import static com.jogamp.opencl.llb.CL.*;
/**
* 2D OpenCL image representing an 2D OpenGL texture.
@@ -58,9 +60,10 @@ public class CLGLTexture2d<B extends Buffer> extends CLGLImage2d<B> implements C
CL cl = getCL(context);
int[] result = new int[1];
- CLGLI clgli = (CLGLI)cl;
+ CLGL clgli = (CLGL)cl;
long id = clgli.clCreateFromGLTexture2D(context.ID, flags, target, mipLevel, texture, result, 0);
+ checkForError((int)id, "can not share memory with texture #"+texture+".");
CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id);
@@ -74,10 +77,12 @@ public class CLGLTexture2d<B extends Buffer> extends CLGLImage2d<B> implements C
}
+ @Override
public int getTextureTarget() {
return target;
}
+ @Override
public int getMipMapLevel() {
return mipMapLevel;
}
diff --git a/src/com/jogamp/opencl/gl/CLGLTexture3d.java b/src/com/jogamp/opencl/gl/CLGLTexture3d.java
index ace779d9..8dd2682c 100644
--- a/src/com/jogamp/opencl/gl/CLGLTexture3d.java
+++ b/src/com/jogamp/opencl/gl/CLGLTexture3d.java
@@ -28,15 +28,16 @@
package com.jogamp.opencl.gl;
-import com.jogamp.opencl.CL;
+import com.jogamp.opencl.llb.gl.CLGL;
+import com.jogamp.opencl.llb.CL;
import com.jogamp.opencl.CLContext;
import com.jogamp.opencl.CLImage3d;
import com.jogamp.opencl.CLImageFormat;
-import com.jogamp.opencl.impl.CLImageFormatImpl;
+import com.jogamp.opencl.llb.impl.CLImageFormatImpl;
import java.nio.Buffer;
import javax.media.opengl.GLContext;
-import static com.jogamp.opencl.CL.*;
+import static com.jogamp.opencl.llb.CL.*;
/**
* 3D OpenCL image representing an 3D OpenGL texture.
@@ -66,7 +67,7 @@ public class CLGLTexture3d<B extends Buffer> extends CLImage3d<B> implements CLG
CL cl = getCL(context);
int[] result = new int[1];
- CLGLI clgli = (CLGLI)cl;
+ CLGL clgli = (CLGL)cl;
long id = clgli.clCreateFromGLTexture3D(context.ID, flags, target, mipLevel, texture, result, 0);
@@ -82,18 +83,22 @@ public class CLGLTexture3d<B extends Buffer> extends CLImage3d<B> implements CLG
return new CLGLTexture3d<B>(context, directBuffer, format, accessor, target, mipLevel, width, height, depth, id, texture, flags);
}
+ @Override
public int getGLObjectID() {
return GLID;
}
+ @Override
public int getTextureTarget() {
return target;
}
+ @Override
public int getMipMapLevel() {
return mipMapLevel;
}
+ @Override
public GLObjectType getGLObjectType() {
return GLObjectType.GL_OBJECT_TEXTURE3D;
}
diff --git a/src/com/jogamp/opencl/gl/package.html b/src/com/jogamp/opencl/gl/package.html
new file mode 100644
index 00000000..24ad0c2e
--- /dev/null
+++ b/src/com/jogamp/opencl/gl/package.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <head></head>
+ <body>
+ High level java bindings, OpenCL-OpenGL interoperability.
+ </body>
+</html>
diff --git a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java
index 2f34fec5..36718f1a 100644
--- a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java
+++ b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java
@@ -5,7 +5,8 @@ package com.jogamp.opencl.impl;
import java.nio.IntBuffer;
import com.jogamp.common.nio.PointerBuffer;
-import com.jogamp.opencl.CL;
+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/llb/gl/package.html b/src/com/jogamp/opencl/llb/gl/package.html
new file mode 100644
index 00000000..47cec148
--- /dev/null
+++ b/src/com/jogamp/opencl/llb/gl/package.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <head></head>
+ <body>
+ Low level java bindings, OpenCL-OpenGL interoperability.
+ </body>
+</html>
diff --git a/src/com/jogamp/opencl/impl/BuildProgramCallback.java b/src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java
index cb4b36d1..51bde322 100644
--- a/src/com/jogamp/opencl/impl/BuildProgramCallback.java
+++ b/src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java
@@ -26,15 +26,15 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opencl.impl;
+package com.jogamp.opencl.llb.impl;
/**
* A callback an application can register to be called when the program executable
* has been built (successfully or unsuccessfully).<br/>
- * 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.
+ * Note1: registering a build callback can make {@link com.jogamp.opencl.llb.CL#clBuildProgram} non blocking (OpenCL implementation dependent).<br/>
+ * Note2: the thread which calls this method is unspecified. The Application should ensure proper synchronization.
* @author Michael Bien
- * @see com.jogamp.opencl.CL#clBuildProgram(long, int, com.jogamp.common.nio.PointerBuffer, java.lang.String, com.jogamp.opencl.impl.BuildProgramCallback)
+ * @see com.jogamp.opencl.llb.CL#clBuildProgram
*/
public interface BuildProgramCallback {
diff --git a/src/com/jogamp/opencl/impl/CLEventCallback.java b/src/com/jogamp/opencl/llb/impl/CLEventCallback.java
index d1526a08..1373995a 100644
--- a/src/com/jogamp/opencl/impl/CLEventCallback.java
+++ b/src/com/jogamp/opencl/llb/impl/CLEventCallback.java
@@ -30,7 +30,7 @@
* Created on Tuesday, July 06 2010 00:46
*/
-package com.jogamp.opencl.impl;
+package com.jogamp.opencl.llb.impl;
/**
* A callback for a specific command execution status.
diff --git a/src/com/jogamp/opencl/impl/CLImpl.java b/src/com/jogamp/opencl/llb/impl/CLImpl.java
index e7f034af..0713ac4d 100644
--- a/src/com/jogamp/opencl/impl/CLImpl.java
+++ b/src/com/jogamp/opencl/llb/impl/CLImpl.java
@@ -29,7 +29,7 @@
/*
* Created on Monday, June 07 2010 at 04:25
*/
-package com.jogamp.opencl.impl;
+package com.jogamp.opencl.llb.impl;
import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.common.os.Platform;
@@ -56,6 +56,7 @@ public class CLImpl extends CLAbstractImpl {
this.contextCallbackMap.setKeyNotFoundValue(0);
}
+ @Override
public long clCreateContext(PointerBuffer properties, PointerBuffer devices, CLErrorHandler pfn_notify, IntBuffer errcode_ret) {
if (properties != null && !properties.isDirect()) {
@@ -87,8 +88,8 @@ 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);
+ @Override
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");
}
@@ -117,6 +118,7 @@ public class CLImpl extends CLAbstractImpl {
private native long clCreateContextFromType0(Object properties, int props_offset, long device_type, Object pfn_notify, long[] global, Object errcode_ret, int err_offset, long address);
+ @Override
public int clReleaseContext(long context) {
long global = 0;
synchronized (contextCallbackMap) {
@@ -134,8 +136,8 @@ 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> */
+ @Override
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");
}
@@ -152,6 +154,7 @@ public class CLImpl extends CLAbstractImpl {
private native int clBuildProgram0(long program, int deviceCount, Object deviceList, int deviceListOffset, String options, BuildProgramCallback cb, long address);
+ @Override
public int clSetEventCallback(long event, int trigger, CLEventCallback callback) {
final long address = addressTable._addressof_clSetEventCallback;
if (address == 0) {
@@ -163,6 +166,7 @@ public class CLImpl extends CLAbstractImpl {
private native int clSetEventCallback0(long event, int type, CLEventCallback cb, long address);
+ @Override
public int clSetMemObjectDestructorCallback(long memObjID, CLMemObjectDestructorCallback cb) {
final long address = addressTable._addressof_clSetMemObjectDestructorCallback;
if (address == 0) {
@@ -175,13 +179,14 @@ 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.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 origin a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param range a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param image_row_pitch a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param image_slice_pitch a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param event_wait_list a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param event a direct {@link com.jogamp.common.nio.PointerBuffer}
@param errcode_ret a direct {@link java.nio.IntBuffer} */
+ @Override
public ByteBuffer clEnqueueMapImage(long command_queue, long image, int blocking_map, long map_flags,
PointerBuffer origin, PointerBuffer range,
PointerBuffer image_row_pitch, PointerBuffer image_slice_pitch,
@@ -235,12 +240,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.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 origin a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param range a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param image_row_pitch a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param image_slice_pitch a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param event_wait_list a direct {@link com.jogamp.common.nio.PointerBuffer}
+ @param event a direct {@link com.jogamp.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/CLMemObjectDestructorCallback.java b/src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java
index c040d2ce..5ed57cce 100644
--- a/src/com/jogamp/opencl/impl/CLMemObjectDestructorCallback.java
+++ b/src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java
@@ -30,7 +30,7 @@
* Created on Thursday, September 02 2010 23:09
*/
-package com.jogamp.opencl.impl;
+package com.jogamp.opencl.llb.impl;
/**
* A callback which is invoked by the OpenCL implementation when the memory
diff --git a/src/com/jogamp/opencl/llb/package.html b/src/com/jogamp/opencl/llb/package.html
new file mode 100644
index 00000000..b68c4de7
--- /dev/null
+++ b/src/com/jogamp/opencl/llb/package.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <head></head>
+ <body>
+ Low level java bindings to OpenCL.
+ </body>
+</html>
diff --git a/src/com/jogamp/opencl/package.html b/src/com/jogamp/opencl/package.html
new file mode 100644
index 00000000..c7cc0a33
--- /dev/null
+++ b/src/com/jogamp/opencl/package.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <head></head>
+ <body>
+ High level java bindings to OpenCL.
+ </body>
+</html>
diff --git a/src/com/jogamp/opencl/spi/CLAccessorFactory.java b/src/com/jogamp/opencl/spi/CLAccessorFactory.java
index 6239bb37..4bafe933 100644
--- a/src/com/jogamp/opencl/spi/CLAccessorFactory.java
+++ b/src/com/jogamp/opencl/spi/CLAccessorFactory.java
@@ -3,7 +3,8 @@
*/
package com.jogamp.opencl.spi;
-import com.jogamp.opencl.CL;
+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.CL;
*/
public interface CLAccessorFactory {
- CLInfoAccessor createDeviceInfoAccessor(CL cl, long id);
+ CLInfoAccessor createDeviceInfoAccessor(CLDeviceBinding cl, long id);
CLPlatformInfoAccessor createPlatformInfoAccessor(CL cl, long id);
diff --git a/src/com/jogamp/opencl/spi/package.html b/src/com/jogamp/opencl/spi/package.html
new file mode 100644
index 00000000..436d5d2b
--- /dev/null
+++ b/src/com/jogamp/opencl/spi/package.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <head></head>
+ <body>
+ SPI for alternative binding implementations.
+ </body>
+</html>
diff --git a/src/com/jogamp/opencl/util/CLBuildListener.java b/src/com/jogamp/opencl/util/CLBuildListener.java
index cec4d391..acd53a52 100644
--- a/src/com/jogamp/opencl/util/CLBuildListener.java
+++ b/src/com/jogamp/opencl/util/CLBuildListener.java
@@ -37,10 +37,10 @@ import com.jogamp.opencl.CLProgram;
/**
* A callback an application can register to be called when the program executable
* has been built (successfully or unsuccessfully).<br/>
- * Note1: registering a build callback can make {@link com.jogamp.opencl.CL#clBuildProgram} non blocking (OpenCL implementation dependent).<br/>
+ * Note1: registering a build callback can make {@link com.jogamp.opencl.llb.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.PointerBuffer, java.lang.String, com.jogamp.opencl.impl.BuildProgramCallback)
+ * @see com.jogamp.opencl.llb.CL#clBuildProgram(long, int, com.jogamp.common.nio.PointerBuffer, java.lang.String, com.jogamp.opencl.llb.impl.BuildProgramCallback)
*/
public interface CLBuildListener {
diff --git a/src/com/jogamp/opencl/util/CLDeviceFilters.java b/src/com/jogamp/opencl/util/CLDeviceFilters.java
index 045d4c7f..a5057fb6 100644
--- a/src/com/jogamp/opencl/util/CLDeviceFilters.java
+++ b/src/com/jogamp/opencl/util/CLDeviceFilters.java
@@ -32,6 +32,7 @@ import com.jogamp.opencl.CLCommandQueue.Mode;
import com.jogamp.opencl.CLDevice;
import java.nio.ByteOrder;
import java.util.Arrays;
+import java.util.EnumSet;
import java.util.List;
/**
@@ -45,13 +46,14 @@ public class CLDeviceFilters {
/**
* Accepts all devices of the given type.
*/
- public static Filter<CLDevice> type(final CLDevice.Type type) {
+ public static Filter<CLDevice> type(final CLDevice.Type... types) {
return new Filter<CLDevice>() {
+ private final EnumSet<CLDevice.Type> set = EnumSet.copyOf(Arrays.asList(types));
public boolean accept(CLDevice item) {
- if(type.equals(CLDevice.Type.ALL)) {
+ if(set.contains(CLDevice.Type.ALL)) {
return true;
}
- return item.getType().equals(type);
+ return set.contains(item.getType());
}
};
}
diff --git a/src/com/jogamp/opencl/util/CLInfo.java b/src/com/jogamp/opencl/util/CLInfo.java
index 3b483fc2..40c4f2ff 100644
--- a/src/com/jogamp/opencl/util/CLInfo.java
+++ b/src/com/jogamp/opencl/util/CLInfo.java
@@ -34,7 +34,7 @@ package com.jogamp.opencl.util;
import com.jogamp.common.os.Platform;
import com.jogamp.opencl.CLDevice;
import com.jogamp.opencl.CLPlatform;
-import com.jogamp.opencl.impl.CLImpl;
+import com.jogamp.opencl.llb.impl.CLImpl;
import java.util.Map;
diff --git a/src/com/jogamp/opencl/util/CLMultiContext.java b/src/com/jogamp/opencl/util/CLMultiContext.java
index f74c0a35..156a9fa6 100644
--- a/src/com/jogamp/opencl/util/CLMultiContext.java
+++ b/src/com/jogamp/opencl/util/CLMultiContext.java
@@ -25,6 +25,7 @@ import static com.jogamp.opencl.CLDevice.Type.*;
public class CLMultiContext implements CLResource {
private final List<CLContext> contexts;
+ private boolean released;
private CLMultiContext() {
contexts = new ArrayList<CLContext>();
@@ -41,7 +42,14 @@ public class CLMultiContext implements CLResource {
* Creates a multi context with all devices of the specified platforms and types.
*/
public static CLMultiContext create(CLPlatform[] platforms, CLDevice.Type... types) {
-
+ return create(platforms, CLDeviceFilters.type(types));
+ }
+
+ /**
+ * Creates a multi context with all matching devices of the specified platforms.
+ */
+ public static CLMultiContext create(CLPlatform[] platforms, Filter<CLDevice>... filters) {
+
if(platforms == null) {
throw new NullPointerException("platform list was null");
}else if(platforms.length == 0) {
@@ -50,7 +58,7 @@ public class CLMultiContext implements CLResource {
List<CLDevice> devices = new ArrayList<CLDevice>();
for (CLPlatform platform : platforms) {
- devices.addAll(asList(platform.listCLDevices(types)));
+ devices.addAll(asList(platform.listCLDevices(filters)));
}
return create(devices);
}
@@ -125,7 +133,12 @@ public class CLMultiContext implements CLResource {
* Releases all contexts.
* @see CLContext#release()
*/
+ @Override
public void release() {
+ if(released) {
+ throw new RuntimeException(getClass().getSimpleName()+" already released");
+ }
+ released = true;
for (CLContext context : contexts) {
context.release();
}
@@ -147,6 +160,10 @@ public class CLMultiContext implements CLResource {
return devices;
}
+ public boolean isReleased() {
+ return released;
+ }
+
@Override
public String toString() {
return getClass().getSimpleName()+" [" + contexts.size()+" contexts, "
diff --git a/src/com/jogamp/opencl/util/CLUtil.java b/src/com/jogamp/opencl/util/CLUtil.java
index 371c493c..98a6cd7e 100644
--- a/src/com/jogamp/opencl/util/CLUtil.java
+++ b/src/com/jogamp/opencl/util/CLUtil.java
@@ -29,7 +29,7 @@
package com.jogamp.opencl.util;
import com.jogamp.common.JogampRuntimeException;
-import com.jogamp.opencl.CL;
+import com.jogamp.opencl.llb.CL;
import com.jogamp.opencl.CLDevice;
import com.jogamp.opencl.CLPlatform;
import com.jogamp.opencl.CLProperty;
diff --git a/src/com/jogamp/opencl/util/JOCLVersion.java b/src/com/jogamp/opencl/util/JOCLVersion.java
index 265233a2..48dd2a9e 100644
--- a/src/com/jogamp/opencl/util/JOCLVersion.java
+++ b/src/com/jogamp/opencl/util/JOCLVersion.java
@@ -35,7 +35,7 @@ import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.JogampVersion;
import com.jogamp.common.util.VersionUtil;
-import com.jogamp.opencl.CL;
+import com.jogamp.opencl.llb.CL;
import java.security.PrivilegedAction;
import java.util.jar.Manifest;
@@ -56,7 +56,7 @@ public class JOCLVersion extends JogampVersion {
private static JOCLVersion createInstance() {
return doPrivileged(new PrivilegedAction<JOCLVersion>() {
- public JOCLVersion run() {
+ @Override public JOCLVersion run() {
Manifest manifest = VersionUtil.getManifest(CL.class.getClassLoader(), PACKAGE);
if(manifest == null) {
manifest = new Manifest();
@@ -92,7 +92,7 @@ public class JOCLVersion extends JogampVersion {
try{
doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
+ @Override public Object run() {
sb.append(GlueGenVersion.getInstance().toString());
return null;
}
diff --git a/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java b/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java
index 9ea960ae..e8bd0124 100644
--- a/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java
+++ b/src/com/jogamp/opencl/util/concurrent/CLCommandQueuePool.java
@@ -29,6 +29,7 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource
private List<CLQueueContext> contexts;
private ExecutorService excecutor;
private FinishAction finishAction = FinishAction.DO_NOTHING;
+ private boolean released;
private CLCommandQueuePool(CLQueueContextFactory factory, Collection<CLCommandQueue> queues) {
this.contexts = initContexts(queues, factory);
@@ -157,7 +158,12 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource
/**
* Releases all queues.
*/
+ @Override
public void release() {
+ if(released) {
+ throw new RuntimeException(getClass().getSimpleName()+" already released");
+ }
+ released = true;
excecutor.shutdown();
for (CLQueueContext context : contexts) {
context.queue.finish().release();
@@ -187,6 +193,11 @@ public class CLCommandQueuePool<C extends CLQueueContext> implements CLResource
return finishAction;
}
+ @Override
+ public boolean isReleased() {
+ return released;
+ }
+
/**
* Sets the action which is run after every completed task.
* This is mainly intended for debugging, default value is {@link FinishAction#DO_NOTHING}.
diff --git a/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java b/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java
index 3f89ad0e..9f92b9a3 100644
--- a/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java
+++ b/src/com/jogamp/opencl/util/concurrent/CLQueueContext.java
@@ -63,10 +63,16 @@ public abstract class CLQueueContext implements CLResource {
return program;
}
+ @Override
public void release() {
program.release();
}
+ @Override
+ public boolean isReleased() {
+ return program.isReleased();
+ }
+
}
}
diff --git a/src/com/jogamp/opencl/util/concurrent/package.html b/src/com/jogamp/opencl/util/concurrent/package.html
new file mode 100644
index 00000000..8b9dc9eb
--- /dev/null
+++ b/src/com/jogamp/opencl/util/concurrent/package.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <head></head>
+ <body>
+ OpenCL multi device concurrency utilities.
+ </body>
+</html>
diff --git a/src/com/jogamp/opencl/util/package.html b/src/com/jogamp/opencl/util/package.html
new file mode 100644
index 00000000..1408c02b
--- /dev/null
+++ b/src/com/jogamp/opencl/util/package.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <head></head>
+ <body>
+ OpenCL utilities.
+ </body>
+</html>