diff options
Diffstat (limited to 'src/com/jogamp/opencl/CLCommandQueue.java')
-rw-r--r-- | src/com/jogamp/opencl/CLCommandQueue.java | 43 |
1 files changed, 28 insertions, 15 deletions
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) { |