diff options
author | Michael Bien <[email protected]> | 2011-10-19 18:03:19 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-10-19 18:03:19 +0200 |
commit | e0e9292a459edc67efc0bd2f3cc18c3825e3aec0 (patch) | |
tree | e118d12c3cd49d884912dc72f2004dc658790747 /test/com/jogamp/opencl | |
parent | 0168c96734d12015cf8176e62f0b1dbfa18dadf4 (diff) |
fixed bug in putCopyImageToBuffer + added junit test for buffer2image and image2buffer copy ops.
Diffstat (limited to 'test/com/jogamp/opencl')
-rw-r--r-- | test/com/jogamp/opencl/CLImageTest.java | 48 |
1 files changed, 48 insertions, 0 deletions
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 { |