From c53440b808ecf8ea066479c004cac4cdbb1e989d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Oct 2013 01:57:34 +0100 Subject: Bug 776 GLContext Sharing: GLSharedContextSetter API Doc: Add 'glFinish()' to lifecycle considerations ; GearsES2: Add glFinish() after init(). --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java | 5 +++++ .../opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java | 8 ++++++++ .../test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java | 8 ++++++++ .../test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java | 2 ++ .../test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java | 8 ++++++++ .../opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java | 8 ++++++++ .../com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java | 3 +++ 8 files changed, 44 insertions(+), 2 deletions(-) diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8a59e68e3..ee93334d4 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -377,8 +377,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java index fd48d12bf..873e4cd9f 100644 --- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -41,6 +41,11 @@ package javax.media.opengl; *

*
Lifecycle Considerations
*

+ * After shared objects are created on the master, the OpenGL pipeline + * might need to be synchronized w/ the slaves, e.g. via {@link GL#glFinish()}. + * At least this has been experienced w/ OSX 10.9. + *

+ *

* Be aware that the master {@link GLContext} and related resources * shall not be destroyed before it's slave {@link GLContext} instances while they are using them.
* Otherwise the OpenGL driver implementation may crash w/ SIGSEGV, since using already destroyed resources, diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java index ede01b52f..3b576fabd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java @@ -181,7 +181,10 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); if( destroyCleanOrder ) { System.err.println("XXX Destroy in clean order NOW"); @@ -332,9 +335,14 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); if( destroyCleanOrder ) { System.err.println("XXX Destroy in clean order NOW"); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java index c35b0658c..d4079e30c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java @@ -172,7 +172,10 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -281,9 +284,14 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java index 24dc09ffb..e8e4cc739 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java @@ -308,6 +308,8 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); Assert.assertEquals(false, a1.isAnimating()); a2.stop(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java index 96a8a5094..c94ae1140 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java @@ -176,7 +176,10 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); if( destroyCleanOrder ) { System.err.println("XXX Destroy in clean order NOW"); @@ -287,9 +290,14 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); if( destroyCleanOrder ) { System.err.println("XXX Destroy in clean order NOW"); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java index 9b6ab88fa..9ccfd394f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java @@ -244,7 +244,10 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); display.syncExec(new Runnable() { public void run() { @@ -335,9 +338,14 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); display.syncExec(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 6c5ddf6e6..be7fcee07 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -304,6 +304,8 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.useProgram(gl, false); + gl.glFinish(); // make sure .. for shared context (impacts OSX 10.9) + System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+" FIN "+this); isInit = true; } @@ -429,6 +431,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void display(GLAutoDrawable drawable) { if( !isInit ) { return; } + if(null != sharedGears && !sharedGears.isInit() ) { return; } GLAnimatorControl anim = drawable.getAnimator(); if( verbose && ( null == anim || !anim.isAnimating() ) ) { System.err.println(Thread.currentThread()+" GearsES2.display "+sid()+" "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); -- cgit v1.2.3