From 074e8a18e8f5f77168bde267ab87f3cf285f82be Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Thu, 18 Feb 2010 01:40:40 +0100 Subject: added putCopyBufferToImage, putCopyImageToBuffer and putMap/UnmapBuffer operations to CLCommandQueue. added buffer mapping test to CLBufferTest. --- src/com/mbien/opencl/CLBuffer.java | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/com/mbien/opencl/CLBuffer.java') 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 extends CLMemory { + 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 CLBuffer 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; -- cgit v1.2.3