summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLMemory.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-02-18 01:40:40 +0100
committerMichael Bien <[email protected]>2010-02-18 01:40:40 +0100
commit074e8a18e8f5f77168bde267ab87f3cf285f82be (patch)
tree5dfd0063968fc2ed1b809b86daa247f8cda27fcd /src/com/mbien/opencl/CLMemory.java
parent62d9a63caad9d614a4a4ca90956b38ff623242a5 (diff)
added putCopyBufferToImage, putCopyImageToBuffer and putMap/UnmapBuffer operations to CLCommandQueue.
added buffer mapping test to CLBufferTest.
Diffstat (limited to 'src/com/mbien/opencl/CLMemory.java')
-rw-r--r--src/com/mbien/opencl/CLMemory.java53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/com/mbien/opencl/CLMemory.java b/src/com/mbien/opencl/CLMemory.java
index 296f16f5..2d12ca31 100644
--- a/src/com/mbien/opencl/CLMemory.java
+++ b/src/com/mbien/opencl/CLMemory.java
@@ -39,7 +39,9 @@ public abstract class CLMemory <B extends Buffer> implements CLResource {
}
protected static final boolean isHostPointerFlag(int flags) {
- return (flags & CL_MEM_COPY_HOST_PTR) != 0 || (flags & CL_MEM_USE_HOST_PTR) != 0;
+ return (flags & CL_MEM_COPY_HOST_PTR) != 0
+ || (flags & CL_MEM_USE_HOST_PTR) != 0
+ || (flags & CL_MEM_ALLOC_HOST_PTR)!= 0;
}
protected static final int sizeOfBufferElem(Buffer buffer) {
@@ -176,7 +178,7 @@ public abstract class CLMemory <B extends Buffer> implements CLResource {
* to allocate memory from host accessible memory.
* {@link #ALLOC_HOST_PTR} and {@link #USE_BUFFER} are mutually exclusive.
*/
- ALLOC_HOST_PTR(CL_MEM_ALLOC_HOST_PTR),
+ ALLOCATE_BUFFER(CL_MEM_ALLOC_HOST_PTR),
/**
* Enum representing CL_MEM_COPY_HOST_PTR.
@@ -207,7 +209,7 @@ public abstract class CLMemory <B extends Buffer> implements CLResource {
case CL_MEM_USE_HOST_PTR:
return Mem.USE_BUFFER;
case(CL_MEM_ALLOC_HOST_PTR):
- return ALLOC_HOST_PTR;
+ return ALLOCATE_BUFFER;
case CL_MEM_COPY_HOST_PTR:
return Mem.COPY_BUFFER;
}
@@ -228,6 +230,51 @@ public abstract class CLMemory <B extends Buffer> implements CLResource {
}
}
+ /**
+ * Configures the mapping process of
+ * {@link com.mbien.opencl.CLCommandQueue#putMapBuffer(CLBuffer, CLMemory.Map, boolean)}.
+ */
+ public enum Map {
+
+ /**
+ * Enum representing CL_MAP_READ | CL_MAP_WRITE.
+ * This flag specifies that the memory object will be mapped for read and write operation.
+ */
+ READ_WRITE(CL_MAP_READ | CL_MAP_WRITE),
+
+ /**
+ * Enum representing CL_MAP_WRITE.
+ * This flag specifies that the memory object will be mapped for write operation.
+ */
+ WRITE(CL_MAP_WRITE),
+
+ /**
+ * Enum representing CL_MAP_READ.
+ * This flag specifies that the memory object will be mapped for read operation.
+ */
+ READ(CL_MAP_READ);
+
+ /**
+ * Value of wrapped OpenCL flag.
+ */
+ public final int FLAGS;
+
+ private Map(int flags) {
+ this.FLAGS = flags;
+ }
+
+ public Map valueOf(int flag) {
+ if(flag == WRITE.FLAGS)
+ return WRITE;
+ else if(flag == READ.FLAGS)
+ return READ;
+ else if(flag == READ_WRITE.FLAGS)
+ return READ_WRITE;
+ return null;
+ }
+
+ }
+
}