aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-03-16 23:27:53 +0100
committerMichael Bien <[email protected]>2010-03-16 23:27:53 +0100
commit2c230d8e774653c68905b5817c935c405ba1b548 (patch)
tree85e69536a60e78ad78a6d7804845fbdcba77ebfd
parentdf1138e7ffad1f5b1d34d3923ee9a089656031e7 (diff)
made sure to flush gl/cl pipelines correctly (-> fixed rare segmentation fault).
-rw-r--r--src/com/mbien/opencl/demos/fractal/MultiDeviceFractal.java7
-rw-r--r--src/com/mbien/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java9
2 files changed, 9 insertions, 7 deletions
diff --git a/src/com/mbien/opencl/demos/fractal/MultiDeviceFractal.java b/src/com/mbien/opencl/demos/fractal/MultiDeviceFractal.java
index a8fc16e..5c89ad8 100644
--- a/src/com/mbien/opencl/demos/fractal/MultiDeviceFractal.java
+++ b/src/com/mbien/opencl/demos/fractal/MultiDeviceFractal.java
@@ -118,6 +118,7 @@ public class MultiDeviceFractal implements GLEventListener {
// enable GL error checking using the composable pipeline
drawable.setGL(new DebugGL2(drawable.getGL().getGL2()));
+ drawable.getGL().glFinish();
initCL(drawable.getContext());
GL2 gl = drawable.getGL().getGL2();
@@ -295,6 +296,8 @@ public class MultiDeviceFractal implements GLEventListener {
public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
+ // make sure GL does not use our objects before we start computeing
+ gl.glFinish();
if(!buffersInitialized) {
initPBO(gl);
setKernelConstants();
@@ -303,8 +306,6 @@ public class MultiDeviceFractal implements GLEventListener {
buildProgram();
setKernelConstants();
}
- // make sure GL does not use our objects before we start computeing
- gl.glFinish();
compute();
render(gl.getGL2());
@@ -335,7 +336,7 @@ public class MultiDeviceFractal implements GLEventListener {
}
- // block until done
+ // block until done (important: finish before doing further gl work)
for (int i = 0; i < slices; i++) {
queues[i].finish();
}
diff --git a/src/com/mbien/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java b/src/com/mbien/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java
index 8c53dd2..067e113 100644
--- a/src/com/mbien/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java
+++ b/src/com/mbien/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java
@@ -179,10 +179,13 @@ public class GLCLInteroperabilityDemo implements GLEventListener {
public void display(GLAutoDrawable drawable) {
- computeHeightfield();
-
GL2 gl = drawable.getGL().getGL2();
+ // ensure pipeline is clean before doing cl work
+ gl.glFinish();
+
+ computeHeightfield();
+
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
@@ -199,8 +202,6 @@ public class GLCLInteroperabilityDemo implements GLEventListener {
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
// gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
-
- gl.glFinish();
}