summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLBuffer.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-01-21 15:06:00 +0100
committerMichael Bien <[email protected]>2010-01-21 15:06:00 +0100
commit564b4d7e2fcd4c408ae6046710b29f3a12280574 (patch)
tree7d0a92eaf66034fd2f34e0a71c095fdd4190faba /src/com/mbien/opencl/CLBuffer.java
parent96251f7aa2770d2d8278afbd6e4b603c24932049 (diff)
moved all CLGL specific methods into CLGLBuffer.
Diffstat (limited to 'src/com/mbien/opencl/CLBuffer.java')
-rw-r--r--src/com/mbien/opencl/CLBuffer.java31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/com/mbien/opencl/CLBuffer.java b/src/com/mbien/opencl/CLBuffer.java
index e42b9064..fd8611e5 100644
--- a/src/com/mbien/opencl/CLBuffer.java
+++ b/src/com/mbien/opencl/CLBuffer.java
@@ -8,46 +8,31 @@ import static com.mbien.opencl.CLException.*;
*
* @author Michael Bien
*/
-public final class CLBuffer<B extends Buffer> extends CLMemory<B> {
+public class CLBuffer<B extends Buffer> extends CLMemory<B> {
- private CLBuffer(CLContext context, B directBuffer, long id) {
+ protected CLBuffer(CLContext context, B directBuffer, long id) {
super(context, directBuffer, id);
}
static <B extends Buffer> CLBuffer<B> create(CLContext context, B directBuffer, int flags) {
- return create(context, directBuffer, flags, 0);
- }
-
- static <B extends Buffer> CLBuffer<B> create(CLContext context, B directBuffer, int flags, int glBuffer) {
if(directBuffer != null && !directBuffer.isDirect())
throw new IllegalArgumentException("buffer is not a direct buffer");
+ B host_ptr = null;
CL cl = context.cl;
- long id;
-
int[] result = new int[1];
- if(glBuffer == 0) {
- B host_ptr = null;
- if(isHostPointerFlag(flags)) {
- host_ptr = directBuffer;
- }
- id = cl.clCreateBuffer(context.ID, flags, sizeOfBufferElem(directBuffer)*directBuffer.capacity(), host_ptr, result, 0);
- }else{
- if(isHostPointerFlag(flags)) {
- throw new IllegalArgumentException(
- "CL_MEM_COPY_HOST_PTR or CL_MEM_USE_HOST_PTR can not be used with OpenGL Buffers.");
- }
- CLGLI clgli = (CLGLI)cl;
- id = clgli.clCreateFromGLBuffer(context.ID, flags, glBuffer, result, 0);
+ if(isHostPointerFlag(flags)) {
+ host_ptr = directBuffer;
}
+ long id = cl.clCreateBuffer(context.ID, flags, sizeOfBufferElem(directBuffer)*directBuffer.capacity(), host_ptr, result, 0);
checkForError(result[0], "can not create cl buffer");
-
+
return new CLBuffer<B>(context, directBuffer, id);
}
-
+
@Override
public <T extends Buffer> CLBuffer<T> cloneWith(T directBuffer) {
return new CLBuffer<T>(context, directBuffer, ID);