diff options
author | Michael Bien <[email protected]> | 2010-07-05 00:10:15 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-07-05 00:10:15 +0200 |
commit | a81e907b30364b1abc2a75d446772f066fbf74ff (patch) | |
tree | 6b61b193829bb72c3a0432afffc36d469950314c /test/com | |
parent | e5208ab035bc454730edc847cad9d5af3ed92e8c (diff) |
finished CLSubBuffer, added junit testcase, perf improvements and cleanup.
CLMemory methods contain now NIO infix for nio buffer specific queries and CL infix for memory object queries.
Diffstat (limited to 'test/com')
-rw-r--r-- | test/com/jogamp/opencl/CLBufferTest.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/test/com/jogamp/opencl/CLBufferTest.java b/test/com/jogamp/opencl/CLBufferTest.java index d0c8c2f..f2d2d60 100644 --- a/test/com/jogamp/opencl/CLBufferTest.java +++ b/test/com/jogamp/opencl/CLBufferTest.java @@ -4,6 +4,7 @@ import com.jogamp.opencl.CLMemory.Mem; import com.jogamp.opencl.CLMemory.Map; import com.jogamp.common.nio.Buffers; import java.nio.ByteBuffer; +import java.nio.FloatBuffer; import org.junit.Test; import static org.junit.Assert.*; @@ -145,5 +146,74 @@ public class CLBufferTest { context.release(); } + + @Test + public void subBufferTest() { + + CLPlatform[] platforms = CLPlatform.listCLPlatforms(); + CLPlatform theChosenOne = null; + for (CLPlatform platform : platforms) { + if(platform.isAtLeast(CLVersion.CL_1_1)) { + theChosenOne = platform; + break; + } + } + + if(theChosenOne == null) { + out.println("aborting subBufferTest"); + return; + } + + CLContext context = CLContext.create(theChosenOne); + try{ + final int subelements = 5; + // device only + { + CLBuffer<?> buffer = context.createBuffer(64); + + assertFalse(buffer.isSubBuffer()); + assertNotNull(buffer.getSubBuffers()); + assertTrue(buffer.getSubBuffers().isEmpty()); + + CLSubBuffer<?> subBuffer = buffer.createSubBuffer(10, subelements); + + assertTrue(subBuffer.isSubBuffer()); + assertEquals(subelements, subBuffer.getCLSize()); + assertEquals(10, subBuffer.getOffset()); + assertEquals(10, subBuffer.getCLOffset()); + assertEquals(buffer, subBuffer.getParent()); + assertEquals(1, buffer.getSubBuffers().size()); + + subBuffer.release(); + assertEquals(0, buffer.getSubBuffers().size()); + } + + // device + direct buffer + { + CLBuffer<FloatBuffer> buffer = context.createFloatBuffer(64); + assertFalse(buffer.isSubBuffer()); + assertNotNull(buffer.getSubBuffers()); + assertTrue(buffer.getSubBuffers().isEmpty()); + + CLSubBuffer<FloatBuffer> subBuffer = buffer.createSubBuffer(10, subelements); + + assertTrue(subBuffer.isSubBuffer()); + assertEquals(subelements, subBuffer.getBuffer().capacity()); + assertEquals(10, subBuffer.getOffset()); + assertEquals(40, subBuffer.getCLOffset()); + assertEquals(buffer, subBuffer.getParent()); + assertEquals(1, buffer.getSubBuffers().size()); + + assertEquals(subBuffer.getCLCapacity(), subBuffer.getBuffer().capacity()); + + subBuffer.release(); + assertEquals(0, buffer.getSubBuffers().size()); + } + + }finally{ + context.release(); + } + + } } |