summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/jogamp')
-rw-r--r--src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java10
-rw-r--r--src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java17
2 files changed, 15 insertions, 12 deletions
diff --git a/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java b/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java
index 9fcd172..9c6b648 100644
--- a/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java
+++ b/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java
@@ -280,12 +280,12 @@ public class MultiDeviceFractal implements GLEventListener {
// setup one empty PBO per slice
for (int i = 0; i < slices; i++) {
+ final int size = width*height * SIZEOF_INT / slices ;
gl.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo[i]);
- gl.glBufferData(GL_PIXEL_UNPACK_BUFFER, width*height * SIZEOF_INT / slices, null, GL_STREAM_DRAW);
+ gl.glBufferData(GL_PIXEL_UNPACK_BUFFER, size, null, GL_STREAM_DRAW);
gl.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
- pboBuffers[i] = clContext.createFromGLBuffer(pbo[i], WRITE_ONLY);
-
+ pboBuffers[i] = clContext.createFromGLBuffer(pbo[i], size, WRITE_ONLY);
}
buffersInitialized = true;
@@ -386,9 +386,9 @@ public class MultiDeviceFractal implements GLEventListener {
.rewind();
// aquire GL objects, and enqueue a kernel with a probe from the list
- queues[i].putAcquireGLObject(pboBuffers[i].ID)
+ queues[i].putAcquireGLObject(pboBuffers[i])
.put2DRangeKernel(kernels[i], 0, 0, sliceWidth, height, 0, 0, probes)
- .putReleaseGLObject(pboBuffers[i].ID);
+ .putReleaseGLObject(pboBuffers[i]);
}
diff --git a/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java b/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java
index fbd3775..19f9e42 100644
--- a/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java
+++ b/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java
@@ -147,17 +147,18 @@ public class GLCLInteroperabilityDemo implements GLEventListener {
// gl.glBufferData(GL2.GL_ELEMENT_ARRAY_BUFFER, ib.capacity() * SIZEOF_INT, ib, GL2.GL_STATIC_DRAW);
// gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0);
+ final int bsz = MESH_SIZE * MESH_SIZE * 4 * SIZEOF_FLOAT;
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, glObjects[VERTICES]);
- gl.glBufferData(GL2.GL_ARRAY_BUFFER, MESH_SIZE * MESH_SIZE * 4 * SIZEOF_FLOAT, null, GL2.GL_DYNAMIC_DRAW);
+ gl.glBufferData(GL2.GL_ARRAY_BUFFER, bsz, null, GL2.GL_DYNAMIC_DRAW);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
- gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
+ gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
pushPerspectiveView(gl);
gl.glFinish();
// init OpenCL
- initCL();
+ initCL(gl, bsz);
// start rendering thread
Animator animator = new Animator(drawable);
@@ -166,7 +167,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener {
}
}
- private void initCL() {
+ private void initCL(GL2 gl, int bufferSize) {
CLProgram program;
try {
@@ -181,7 +182,9 @@ public class GLCLInteroperabilityDemo implements GLEventListener {
commandQueue = clContext.getMaxFlopsDevice().createCommandQueue();
- clBuffer = clContext.createFromGLBuffer(glObjects[VERTICES], CLGLBuffer.Mem.WRITE_ONLY);
+ clBuffer = clContext.createFromGLBuffer(glObjects[VERTICES],
+ bufferSize /* gl.glGetBufferSize(glObjects[VERTICES]*/,
+ CLGLBuffer.Mem.WRITE_ONLY);
System.out.println("cl buffer type: " + clBuffer.getGLObjectType());
System.out.println("shared with gl buffer: " + clBuffer.getGLObjectID());
@@ -230,9 +233,9 @@ public class GLCLInteroperabilityDemo implements GLEventListener {
kernel.setArg(2, step += 0.05f);
- commandQueue.putAcquireGLObject(clBuffer.ID)
+ commandQueue.putAcquireGLObject(clBuffer)
.put2DRangeKernel(kernel, 0, 0, MESH_SIZE, MESH_SIZE, 0, 0)
- .putReleaseGLObject(clBuffer.ID)
+ .putReleaseGLObject(clBuffer)
.finish();
}