Login  Register

Re: CLMemory#getNIOSize should use buffer.limit() instead of buffer.capacity().

Posted by Emily Leiviskä on Nov 16, 2016; 3:34pm
URL: https://forum.jogamp.org/CLMemory-getNIOSize-should-use-buffer-limit-instead-of-buffer-capacity-tp4037407p4037421.html

Yes, Win7 pro 64bit on MinGW64 under MSYS2. There are no spaces in any of the involved paths... so that's not it. Anyway I disabled the test result archive task. Now I can run the tests.

However I'm encountering an issue writing my own tests. I copied one of the existing tests and only changed it to use "cloneWith" and now the test fails. I cannot see what I'm doing wrong...

        final int elements = NUM_ELEMENTS;
        final CLContext context = CLContext.create();

        // These two lines instead of commented line below causes the test to fail. The contents of clBufferB.buffer are rubbish.
        final ByteBuffer buffer = ByteBuffer.allocateDirect(elements*SIZEOF_INT);
        final CLBuffer<ByteBuffer> clBufferA = context.createBuffer(elements*SIZEOF_INT, Mem.READ_ONLY).cloneWith(buffer);

        // This works and IMHO should be equivalent to the above...
        // final CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements*SIZEOF_INT, Mem.READ_ONLY);


        final CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements*SIZEOF_INT, Mem.READ_ONLY);

        fillBuffer(clBufferA.buffer, 12345);

        final CLCommandQueue queue = context.getDevices()[0].createCommandQueue();
        queue.putWriteBuffer(clBufferA, false)                                 // write A
             .putCopyBuffer(clBufferA, clBufferB, clBufferA.buffer.capacity()) // copy A -> B
             .putReadBuffer(clBufferB, true)                                   // read B
             .finish();

        context.release();
        checkIfEqual(clBufferA.buffer, clBufferB.buffer, elements);