summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLBuffer.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/CLBuffer.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/CLBuffer.java')
-rw-r--r--src/com/mbien/opencl/CLBuffer.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/com/mbien/opencl/CLBuffer.java b/src/com/mbien/opencl/CLBuffer.java
index fd8611e5..ebde221c 100644
--- a/src/com/mbien/opencl/CLBuffer.java
+++ b/src/com/mbien/opencl/CLBuffer.java
@@ -10,15 +10,34 @@ import static com.mbien.opencl.CLException.*;
*/
public class CLBuffer<B extends Buffer> extends CLMemory<B> {
+ public CLBuffer(CLContext context, long id) {
+ super(context, id);
+ }
protected CLBuffer(CLContext context, B directBuffer, long id) {
super(context, directBuffer, id);
}
+ @SuppressWarnings("unchecked")
+ static CLBuffer<?> create(CLContext context, int size, int flags) {
+
+ CL cl = context.cl;
+ int[] result = new int[1];
+
+ if(isHostPointerFlag(flags)) {
+ throw new IllegalArgumentException("no host pointer defined");
+ }
+
+ long id = cl.clCreateBuffer(context.ID, flags, size, null, result, 0);
+ checkForError(result[0], "can not create cl buffer");
+
+ return new CLBuffer(context, id);
+ }
+
static <B extends Buffer> CLBuffer<B> create(CLContext context, B directBuffer, int flags) {
- if(directBuffer != null && !directBuffer.isDirect())
- throw new IllegalArgumentException("buffer is not a direct buffer");
+ if(!directBuffer.isDirect())
+ throw new IllegalArgumentException("buffer is not direct");
B host_ptr = null;
CL cl = context.cl;