diff options
author | Sven Gothel <[email protected]> | 2011-05-18 05:58:26 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-05-18 05:58:26 +0200 |
commit | be2915e8eb6c1b230514a93c25a08f05217db8ea (patch) | |
tree | 867693b667db614c94bfd5ad2c69aefeef3ac896 /src/com/jogamp | |
parent | bb3cc47fefe772fdb9977daf34d7f7289183ad7d (diff) |
sync with JOCL c6f97a2e6ea1d337f371152a2fee65ee1dd4c5d5
Diffstat (limited to 'src/com/jogamp')
-rw-r--r-- | src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java | 10 | ||||
-rw-r--r-- | src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java | 17 |
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(); } |