diff options
-rw-r--r-- | src/com/jogamp/opencl/CLCommandQueue.java | 4 | ||||
-rw-r--r-- | test/com/jogamp/opencl/CLImageTest.java | 48 |
2 files changed, 50 insertions, 2 deletions
diff --git a/src/com/jogamp/opencl/CLCommandQueue.java b/src/com/jogamp/opencl/CLCommandQueue.java index 970ef0ce..ad8a4c69 100644 --- a/src/com/jogamp/opencl/CLCommandQueue.java +++ b/src/com/jogamp/opencl/CLCommandQueue.java @@ -1038,7 +1038,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, srcOriginX, srcOriginY, 0); copy2NIO(ibB, rangeX, rangeY, 1); - int ret = cl.clEnqueueCopyImageToBuffer(ID, dstBuffer.ID, srcImage.ID, + int ret = cl.clEnqueueCopyImageToBuffer(ID, srcImage.ID, dstBuffer.ID, ibA, ibB, dstOffset, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { @@ -1103,7 +1103,7 @@ public class CLCommandQueue extends CLObjectResource { copy2NIO(ibA, srcOriginX, srcOriginY, srcOriginZ); copy2NIO(ibB, rangeX, rangeY, rangeZ); - int ret = cl.clEnqueueCopyImageToBuffer(ID, dstBuffer.ID, srcImage.ID, + int ret = cl.clEnqueueCopyImageToBuffer(ID, srcImage.ID, dstBuffer.ID, ibA, ibB, dstOffset, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { diff --git a/test/com/jogamp/opencl/CLImageTest.java b/test/com/jogamp/opencl/CLImageTest.java index 862b7798..db68d16d 100644 --- a/test/com/jogamp/opencl/CLImageTest.java +++ b/test/com/jogamp/opencl/CLImageTest.java @@ -130,6 +130,54 @@ public class CLImageTest { } } + + @Test + public void image2dCopyBufferTest() throws IOException { + + CLDevice device = getCompatibleDevice(); + if(device == null) { + out.println("WARNING: can not test image api."); + return; + } + CLContext context = CLContext.create(device); + + CLCommandQueue queue = device.createCommandQueue(); + + try{ + + CLImageFormat format = new CLImageFormat(RGBA, UNSIGNED_INT32); + + CLImage2d<IntBuffer> imageA = context.createImage2d(newDirectIntBuffer(pixels), 128, 128, format); + CLImage2d<IntBuffer> imageB = context.createImage2d(newDirectIntBuffer(pixels.length), 128, 128, format); + CLBuffer<IntBuffer> buffer = context.createBuffer(newDirectIntBuffer(pixels.length)); + + // image -> buffer + queue.putWriteImage(imageA, false) + .putCopyImageToBuffer(imageA, buffer) + .putReadBuffer(buffer, true); + + IntBuffer content = buffer.getBuffer(); + while(content.hasRemaining()) { + assertEquals(pixels[content.position()], content.get()); + } + content.rewind(); + + // buffer -> image + queue.putCopyBufferToImage(buffer, imageB) + .putReadImage(imageB, true); + + IntBuffer bufferA = imageA.getBuffer(); + IntBuffer bufferB = imageB.getBuffer(); + + while(bufferA.hasRemaining()) { + assertEquals(bufferA.get(), bufferB.get()); + } + + }finally{ + context.release(); + } + + } @Test public void image2dKernelCopyTest() throws IOException { |