diff options
author | Emily Leiviskä <[email protected]> | 2016-11-16 17:10:00 +0100 |
---|---|---|
committer | Emily Leiviskä <[email protected]> | 2016-11-16 17:10:00 +0100 |
commit | 01f69625995299262c11ae6bcbf345119c7b892f (patch) | |
tree | 9bd719adc485a6749704ffa823c8c4102eb53bed /test/com | |
parent | cf5340c0bfc1914073ea1f4fc3ccad83f50dc57d (diff) |
Changing CLBuffer#create to respect the limit instead of capacity on the direct buffer that the CLBuffer is being created for as this more closely represents the users intention about the buffer size.
Diffstat (limited to 'test/com')
-rw-r--r-- | test/com/jogamp/opencl/CLBufferTest.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/com/jogamp/opencl/CLBufferTest.java b/test/com/jogamp/opencl/CLBufferTest.java index de71dfe1..0c6e1d11 100644 --- a/test/com/jogamp/opencl/CLBufferTest.java +++ b/test/com/jogamp/opencl/CLBufferTest.java @@ -65,6 +65,26 @@ import static com.jogamp.opencl.CLVersion.*; public class CLBufferTest extends UITestCase { @Test + public void createBufferFromLimitedBuffer() { + final int elements = NUM_ELEMENTS; + final int padding = 19*SIZEOF_INT*2; // Totally arbitrary number > 0 divisible by 2*SIZEOF_INT + final CLContext context = CLContext.create(); + + // Make a buffer that is offset relative to the originally allocated position and has a + // limit that is + // not equal to the capacity to test whether all these attributes are correctly handled. + ByteBuffer byteBuffer = ByteBuffer.allocateDirect(elements*SIZEOF_INT + padding); + byteBuffer.position(padding / 2); // Offset the original buffer + IntBuffer intBuffer = byteBuffer.slice().order(ByteOrder.nativeOrder()).asIntBuffer(); // Slice it to have a new buffer that starts at the offset + intBuffer.limit(elements); + + final CLBuffer<IntBuffer> deviceBuffer = context.createBuffer(intBuffer); + assertEquals(elements, deviceBuffer.getCLCapacity()); + assertEquals(elements * SIZEOF_INT, deviceBuffer.getNIOSize()); + assertEquals(elements, deviceBuffer.getNIOCapacity()); + } + + @Test public void cloneWithLimitedBufferTest() { final int elements = NUM_ELEMENTS; final int padding = 312; // Arbitrary number |