diff options
author | Michael Bien <[email protected]> | 2011-04-10 22:47:54 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-04-10 22:47:54 +0200 |
commit | 8a313c3240994d802af08673d095b0ec8ed69eac (patch) | |
tree | 8675133ce28a0d5129cd55a0fd90f7a68432bf6d /src | |
parent | eb0aeae72378942509942314b346ad9ed30e1333 (diff) |
using Buffers.sizeOfBufferElem(buffer) instead of old private implementation.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/jogamp/opencl/CLBuffer.java | 2 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLMemory.java | 21 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLSubBuffer.java | 3 |
3 files changed, 4 insertions, 22 deletions
diff --git a/src/com/jogamp/opencl/CLBuffer.java b/src/com/jogamp/opencl/CLBuffer.java index fed7db1..57fba46 100644 --- a/src/com/jogamp/opencl/CLBuffer.java +++ b/src/com/jogamp/opencl/CLBuffer.java @@ -82,7 +82,7 @@ public class CLBuffer<B extends Buffer> extends CLMemory<B> { if(isHostPointerFlag(flags)) { host_ptr = directBuffer; } - int size = sizeOfBufferElem(directBuffer) * directBuffer.capacity(); + int size = Buffers.sizeOfBufferElem(directBuffer) * directBuffer.capacity(); long id = cl.clCreateBuffer(context.ID, flags, size, host_ptr, result, 0); checkForError(result[0], "can not create cl buffer"); diff --git a/src/com/jogamp/opencl/CLMemory.java b/src/com/jogamp/opencl/CLMemory.java index 2525380..ebeec28 100644 --- a/src/com/jogamp/opencl/CLMemory.java +++ b/src/com/jogamp/opencl/CLMemory.java @@ -33,11 +33,7 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.impl.CLMemObjectDestructorCallback; import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.DoubleBuffer; -import java.nio.FloatBuffer; import java.nio.IntBuffer; -import java.nio.ShortBuffer; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; @@ -73,7 +69,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL } private void initElementSizes() { - this.elementSize = (buffer==null) ? 1 : sizeOfBufferElem(buffer); + this.elementSize = (buffer==null) ? 1 : Buffers.sizeOfBufferElem(buffer); this.clCapacity = (int) (size / elementSize); } @@ -85,21 +81,6 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL || (flags & CL_MEM_USE_HOST_PTR) != 0; } - static int sizeOfBufferElem(Buffer buffer) { - if (buffer instanceof ByteBuffer) { - return Buffers.SIZEOF_BYTE; - } else if (buffer instanceof IntBuffer) { - return Buffers.SIZEOF_INT; - } else if (buffer instanceof ShortBuffer) { - return Buffers.SIZEOF_SHORT; - } else if (buffer instanceof FloatBuffer) { - return Buffers.SIZEOF_FLOAT; - } else if (buffer instanceof DoubleBuffer) { - return Buffers.SIZEOF_DOUBLE; - } - throw new RuntimeException("Unexpected buffer type " + buffer.getClass().getName()); - } - protected static long getSizeImpl(CL cl, long id) { PointerBuffer pb = PointerBuffer.allocateDirect(1); int ret = cl.clGetMemObjectInfo(id, CL_MEM_SIZE, PointerBuffer.elementSize(), pb.getBuffer(), null); diff --git a/src/com/jogamp/opencl/CLSubBuffer.java b/src/com/jogamp/opencl/CLSubBuffer.java index 89a7471..d883178 100644 --- a/src/com/jogamp/opencl/CLSubBuffer.java +++ b/src/com/jogamp/opencl/CLSubBuffer.java @@ -28,6 +28,7 @@ package com.jogamp.opencl; +import com.jogamp.common.nio.Buffers; import com.jogamp.opencl.CLMemory.Mem; import java.nio.Buffer; @@ -72,7 +73,7 @@ public class CLSubBuffer<B extends Buffer> extends CLBuffer<B> { * Returns the offset of this sub buffer to its parent in buffer elements. */ public int getOffset() { - int elemSize = buffer==null ? 1 : sizeOfBufferElem(buffer); + int elemSize = buffer==null ? 1 : Buffers.sizeOfBufferElem(buffer); return offset/elemSize; } |