summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/jogamp')
-rw-r--r--src/com/jogamp/opencl/CLEventList.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/com/jogamp/opencl/CLEventList.java b/src/com/jogamp/opencl/CLEventList.java
index f2b98adf..23ef3963 100644
--- a/src/com/jogamp/opencl/CLEventList.java
+++ b/src/com/jogamp/opencl/CLEventList.java
@@ -29,6 +29,7 @@
package com.jogamp.opencl;
import com.jogamp.common.AutoCloseable;
+import com.jogamp.common.nio.CachedBufferFactory;
import com.jogamp.common.nio.PointerBuffer;
import java.util.Iterator;
@@ -51,24 +52,43 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL
final PointerBuffer IDsView;
int size;
-
+
public CLEventList(int capacity) {
+ this(null, capacity);
+ }
+
+ public CLEventList(CLEvent... events) {
+ this(null, events);
+ }
+
+ public CLEventList(CachedBufferFactory factory, int capacity) {
this.events = new CLEvent[capacity];
- this.IDs = PointerBuffer.allocateDirect(capacity);
+ this.IDs = initIDBuffer(factory, capacity);
this.IDsView = PointerBuffer.wrap(IDs.getBuffer());
}
- public CLEventList(CLEvent... events) {
+ public CLEventList(CachedBufferFactory factory, CLEvent... events) {
this.events = events;
- this.IDs = PointerBuffer.allocateDirect(events.length);
+ this.IDs = initIDBuffer(factory, events.length);
this.IDsView = PointerBuffer.wrap(IDs.getBuffer());
for (CLEvent event : events) {
+ if(event == null) {
+ throw new IllegalArgumentException("event list containes null element.");
+ }
IDs.put(event.ID);
}
IDs.rewind();
size = events.length;
}
+
+ private PointerBuffer initIDBuffer(CachedBufferFactory factory, int size) {
+ if(factory == null) {
+ return PointerBuffer.allocateDirect(size);
+ }else{
+ return PointerBuffer.wrap(factory.newDirectByteBuffer(size*PointerBuffer.elementSize()));
+ }
+ }
void createEvent(CLContext context) {
@@ -98,7 +118,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable<CL
public final void close() throws Exception {
release();
}
-
+
public CLEvent getEvent(int index) {
if(index >= size)
throw new IndexOutOfBoundsException("list contains "+size+" events, can not return event with index "+index);