diff options
author | Michael Bien <[email protected]> | 2011-04-20 01:01:42 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-04-20 01:01:42 +0200 |
commit | 59ec9a937001549262c37c543266cc6015e53f9d (patch) | |
tree | e52a7c0a07a65f6612308ba26b332b07e8b56656 | |
parent | 3c06ab634c7119249d37f808a5a979a5f7776de5 (diff) |
added mapped CLMemory argument to putUnmapMemory for more flexibility.
-rw-r--r-- | src/com/jogamp/opencl/CLCommandQueue.java | 15 | ||||
-rw-r--r-- | test/com/jogamp/opencl/CLBufferTest.java | 8 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/com/jogamp/opencl/CLCommandQueue.java b/src/com/jogamp/opencl/CLCommandQueue.java index eed004e4..dc954a4a 100644 --- a/src/com/jogamp/opencl/CLCommandQueue.java +++ b/src/com/jogamp/opencl/CLCommandQueue.java @@ -31,6 +31,7 @@ package com.jogamp.opencl; import com.jogamp.common.nio.CachedBufferFactory; import com.jogamp.opencl.gl.CLGLI; import com.jogamp.common.nio.PointerBuffer; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.ArrayList; @@ -326,7 +327,7 @@ public class CLCommandQueue extends CLObject implements CLResource { int originX, int originY, int hostX, int hostY, int rangeX, int rangeY, long rowPitch, long slicePitch, long hostRowPitch, long hostSlicePitch, boolean blockingRead, CLEventList condition, CLEventList events) { - // spec: if 2d: origin/hostpos=0, ragne=1 + // spec: if 2d: origin/hostpos=0, range=1 putReadBufferRect( readBuffer, originX, originY, 0, hostX, hostY, 0, rangeX, rangeY, 1, @@ -1297,21 +1298,21 @@ public class CLCommandQueue extends CLObject implements CLResource { /** * Calls {@native clEnqueueUnmapMemObject}. */ - public CLCommandQueue putUnmapMemory(CLMemory<?> memory) { - return putUnmapMemory(memory, null, null); + public CLCommandQueue putUnmapMemory(CLMemory<?> memory, Buffer mapped) { + return putUnmapMemory(memory, mapped, null, null); } /** * Calls {@native clEnqueueUnmapMemObject}. */ - public CLCommandQueue putUnmapMemory(CLMemory<?> memory, CLEventList events) { - return putUnmapMemory(memory, null, events); + public CLCommandQueue putUnmapMemory(CLMemory<?> memory, Buffer mapped, CLEventList events) { + return putUnmapMemory(memory, mapped, null, events); } /** * Calls {@native clEnqueueUnmapMemObject}. */ - public CLCommandQueue putUnmapMemory(CLMemory<?> memory, CLEventList condition, CLEventList events) { + public CLCommandQueue putUnmapMemory(CLMemory<?> memory, Buffer mapped, CLEventList condition, CLEventList events) { PointerBuffer conditionIDs = null; int conditions = 0; @@ -1320,7 +1321,7 @@ public class CLCommandQueue extends CLObject implements CLResource { conditions = condition.size; } - int ret = cl.clEnqueueUnmapMemObject(ID, memory.ID, memory.getBuffer(), + int ret = cl.clEnqueueUnmapMemObject(ID, memory.ID, mapped, conditions, conditionIDs, events==null ? null : events.IDs); if(ret != CL_SUCCESS) { throw newException(ret, "can not unmap " + memory + toStr(condition, events)); diff --git a/test/com/jogamp/opencl/CLBufferTest.java b/test/com/jogamp/opencl/CLBufferTest.java index 0e4a4a65..1b718277 100644 --- a/test/com/jogamp/opencl/CLBufferTest.java +++ b/test/com/jogamp/opencl/CLBufferTest.java @@ -158,10 +158,10 @@ public class CLBufferTest { ByteBuffer mappedBufferA = queue.putMapBuffer(clBufferA, Map.READ_WRITE, true); assertEquals(sizeInBytes, mappedBufferA.capacity()); - fillBuffer(mappedBufferA, 12345); // write to A + fillBuffer(mappedBufferA, 12345); // write to A - queue.putUnmapMemory(clBufferA) // unmap A - .putCopyBuffer(clBufferA, clBufferB); // copy A -> B + queue.putUnmapMemory(clBufferA, mappedBufferA)// unmap A + .putCopyBuffer(clBufferA, clBufferB); // copy A -> B // map B for read operations ByteBuffer mappedBufferB = queue.putMapBuffer(clBufferB, Map.READ, true); @@ -171,7 +171,7 @@ public class CLBufferTest { checkIfEqual(mappedBufferA, mappedBufferB, elements); // A == B ? out.println("results are valid"); - queue.putUnmapMemory(clBufferB); // unmap B + queue.putUnmapMemory(clBufferB, mappedBufferB); // unmap B context.release(); |