summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-10-19 18:03:19 +0200
committerMichael Bien <[email protected]>2011-10-19 18:03:19 +0200
commite0e9292a459edc67efc0bd2f3cc18c3825e3aec0 (patch)
treee118d12c3cd49d884912dc72f2004dc658790747
parent0168c96734d12015cf8176e62f0b1dbfa18dadf4 (diff)
fixed bug in putCopyImageToBuffer + added junit test for buffer2image and image2buffer copy ops.
-rw-r--r--src/com/jogamp/opencl/CLCommandQueue.java4
-rw-r--r--test/com/jogamp/opencl/CLImageTest.java48
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 {