summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/CLMemory.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/jogamp/opencl/CLMemory.java')
-rw-r--r--src/com/jogamp/opencl/CLMemory.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/com/jogamp/opencl/CLMemory.java b/src/com/jogamp/opencl/CLMemory.java
index b78e6024..db64f8a5 100644
--- a/src/com/jogamp/opencl/CLMemory.java
+++ b/src/com/jogamp/opencl/CLMemory.java
@@ -30,7 +30,7 @@ package com.jogamp.opencl;
import com.jogamp.opencl.gl.CLGLI;
import com.jogamp.common.nio.Buffers;
-import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.common.nio.NativeSizeBuffer;
import com.jogamp.opencl.impl.CLMemObjectDestructorCallback;
import java.nio.Buffer;
import java.nio.IntBuffer;
@@ -50,7 +50,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL
B buffer;
protected final int FLAGS;
- protected final long size;
+ protected long size;
// depends on the nio buffer type
protected int elementSize;
@@ -65,11 +65,15 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL
this.buffer = directBuffer;
this.FLAGS = flags;
this.size = size;
- initElementSizes();
+ initElementSize();
+ initCLCapacity();
}
- private void initElementSizes() {
+ private void initElementSize() {
this.elementSize = (buffer==null) ? 1 : Buffers.sizeOfBufferElem(buffer);
+ }
+
+ protected final void initCLCapacity() {
this.clCapacity = (int) (size / elementSize);
}
@@ -118,7 +122,8 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL
+" but got " + buffer.getClass());
}
this.buffer = buffer;
- initElementSizes();
+ initElementSize();
+ initCLCapacity();
return this;
}