Skip to content

Commit

Permalink
made sure to flush gl/cl pipelines correctly (-> fixed rare segmentat…
Browse files Browse the repository at this point in the history
…ion fault).
  • Loading branch information
mbien committed Mar 16, 2010
1 parent df1138e commit 2c230d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/com/mbien/opencl/demos/fractal/MultiDeviceFractal.java
Expand Up @@ -118,6 +118,7 @@ public void init(GLAutoDrawable drawable) {
// 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();
Expand Down Expand Up @@ -295,6 +296,8 @@ private void setKernelConstants() {
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();
Expand All @@ -303,8 +306,6 @@ public void display(GLAutoDrawable drawable) {
buildProgram();
setKernelConstants();
}
// make sure GL does not use our objects before we start computeing
gl.glFinish();
compute();

render(gl.getGL2());
Expand Down Expand Up @@ -335,7 +336,7 @@ private void compute() {

}

// block until done
// block until done (important: finish before doing further gl work)
for (int i = 0; i < slices; i++) {
queues[i].finish();
}
Expand Down
Expand Up @@ -179,10 +179,13 @@ private void initCL() {

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();

Expand All @@ -199,8 +202,6 @@ public void display(GLAutoDrawable drawable) {
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);

// gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);

gl.glFinish();

}

Expand Down

0 comments on commit 2c230d8

Please sign in to comment.