diff options
author | Michael Bien <[email protected]> | 2010-06-16 20:23:33 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-06-16 20:23:33 +0200 |
commit | 4b96c9539e7b31bbfd5b349d16b51dd5eb556707 (patch) | |
tree | a08563d3fb71af931181823a1f4eee6fc4981ac9 /src/com | |
parent | 35c9254adf4448c5eb86239118c5fb1dd6db88b8 (diff) |
implemented OpenCL 1.1 user events + JUnit test.
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/jogamp/opencl/CLEvent.java | 16 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLEventList.java | 10 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLUserEvent.java | 59 |
3 files changed, 83 insertions, 2 deletions
diff --git a/src/com/jogamp/opencl/CLEvent.java b/src/com/jogamp/opencl/CLEvent.java index bf4ac690..5b71cc29 100644 --- a/src/com/jogamp/opencl/CLEvent.java +++ b/src/com/jogamp/opencl/CLEvent.java @@ -40,6 +40,13 @@ public class CLEvent extends CLObject implements CLResource { public ExecutionStatus getStatus() { return ExecutionStatus.valueOf(getStatusCode()); } + + /** + * Returns true only if {@link #getStatus} returns {@link ExecutionStatus#COMPLETE}. + */ + public boolean isComplete() { + return ExecutionStatus.COMPLETE.equals(getStatus()); + } public int getStatusCode() { return (int)eventInfo.getLong(CL_EVENT_COMMAND_EXECUTION_STATUS); @@ -57,7 +64,7 @@ public class CLEvent extends CLObject implements CLResource { @Override public String toString() { - return "CLEvent [id: " + ID + return getClass().getSimpleName()+" [id: " + ID + " name: " + getType() + " status: " + getStatus()+"]"; } @@ -237,8 +244,13 @@ public class CLEvent extends CLObject implements CLResource { MAP_IMAGE(CL_COMMAND_MAP_IMAGE), UNMAP_MEM_OBJECT(CL_COMMAND_UNMAP_MEM_OBJECT), MARKER(CL_COMMAND_MARKER), + READ_BUFFER_RECT(CL_COMMAND_READ_BUFFER_RECT), + WRITE_BUFFER_RECT(CL_COMMAND_WRITE_BUFFER_RECT), + COPY_BUFFER_RECT(CL_COMMAND_COPY_BUFFER_RECT), + USER(CL_COMMAND_USER), ACQUIRE_GL_OBJECTS(CL_COMMAND_ACQUIRE_GL_OBJECTS), - RELEASE_GL_OBJECTS(CL_COMMAND_RELEASE_GL_OBJECTS); + RELEASE_GL_OBJECTS(CL_COMMAND_RELEASE_GL_OBJECTS), + GL_FENCE_SYNC_OBJECT_KHR(CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR); /** * Value of wrapped OpenCL command type. diff --git a/src/com/jogamp/opencl/CLEventList.java b/src/com/jogamp/opencl/CLEventList.java index b9b4cd4b..43f2b36b 100644 --- a/src/com/jogamp/opencl/CLEventList.java +++ b/src/com/jogamp/opencl/CLEventList.java @@ -19,6 +19,16 @@ public final class CLEventList implements CLResource, Iterable<CLEvent> { this.IDs = PointerBuffer.allocateDirect(capacity); } + public CLEventList(CLEvent... events) { + this.events = events; + this.IDs = PointerBuffer.allocateDirect(events.length); + for (CLEvent event : events) { + IDs.put(event.ID); + } + IDs.rewind(); + size = events.length; + } + void createEvent(CLContext context) { if(events[size] != null) diff --git a/src/com/jogamp/opencl/CLUserEvent.java b/src/com/jogamp/opencl/CLUserEvent.java new file mode 100644 index 00000000..56fb7a0c --- /dev/null +++ b/src/com/jogamp/opencl/CLUserEvent.java @@ -0,0 +1,59 @@ +/* + * Created on Wednesday, June 16 2010 18:05 + */ + +package com.jogamp.opencl; + +import static com.jogamp.opencl.CLException.*; +import static com.jogamp.opencl.CL.*; + +/** + * Custom, user controlled event. + * @see CLEvent + * @author Michael Bien + */ +public class CLUserEvent extends CLEvent { + + CLUserEvent(CLContext context, long ID) { + super(context, ID); + } + + /** + * Creates a new user event. + */ + public static CLUserEvent create(CLContext context) { + int[] error = new int[1]; + long ID = context.cl.clCreateUserEvent(context.ID, error, 0); + checkForError(error[0], "can not create user event."); + return new CLUserEvent(context, ID); + } + + /** + * Sets the event execution status. + * Calls {@native clSetUserEventStatus}. + */ + public CLUserEvent setStatus(CLEvent.ExecutionStatus status) { + int err = cl.clSetUserEventStatus(ID, status.STATUS); + if(err != CL_SUCCESS) { + newException(err, "can not set status "+status); + } + return this; + } + + /** + * Sets this event's status to {@link CLEvent.ExecutionStatus#COMPLETE}. + * @see #setStatus(com.jogamp.opencl.CLEvent.ExecutionStatus) + */ + public CLUserEvent setComplete() { + return setStatus(ExecutionStatus.COMPLETE); + } + + /** + * Returns {@link CLEvent.CommandType#USER}. + */ + @Override + public CommandType getType() { + return CommandType.USER; + } + +} |