From c7ac21e7d25e5271f600806c93e3bd870d45bce3 Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ * Usually synchronization should not be required, if the shared GL objects
+ * are created and immutable before concurrent usage.
+ * Synchronization can be avoided if accessing the shared GL objects
+ * exclusively via a queue or {@link com.jogamp.common.util.Ringbuffer Ringbuffer}, see GLMediaPlayerImpl as an example.
+ *
+ * Appears on:
+ *
+ * However, using drivers exposing this issue always require the user to
+ * synchronize access of shared GL objects.
+ *
+ *
+ *
+ *
+ *
+ * See Bug 1088 - https://jogamp.org/bugzilla/show_bug.cgi?id=1088 + *
+ */ + public static final int NeedSharedObjectSync = 20; + /** @deprecated Use {@link #getCount()}, this value is no more valid! */ public static final int COUNT = 18; /** Return the number of known quirks. */ - public static final int getCount() { return 20; } + public static final int getCount() { return 21; } private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", @@ -375,7 +407,8 @@ public class GLRendererQuirks { "NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext", "NoFullFBOSupport", "GLSLNonCompliant", "GL4NeedsGL3Request", "GLSharedContextBuggy", "GLES3ViaEGLES2Config", "SingletonEGLDisplayOnly", - "NoMultiSamplingBuffers", "BuggyColorRenderbuffer", "NoPBufferWithAccum" + "NoMultiSamplingBuffers", "BuggyColorRenderbuffer", "NoPBufferWithAccum", + "NeedSharedObjectSync" }; private static final IdentityHashMap@@ -88,6 +90,20 @@ package javax.media.opengl; glad.setVisible(true); // GLWindow creation .. * *
+ *+ * Usually synchronization of shared GL objects should not be required, if the shared GL objects + * are created and immutable before concurrent usage. + *
+ *+ * However, using drivers exposing {@link GLRendererQuirks#NeedSharedObjectSync} always + * require the user to synchronize access of shared GL objects. + *
+ *+ * Synchronization can be avoided if accessing the shared GL objects + * exclusively via a queue or {@link com.jogamp.common.util.Ringbuffer Ringbuffer}, see GLMediaPlayerImpl as an example. + *
+ * *
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index bc8d3b7e4..45a4f2426 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -1785,6 +1785,13 @@ public abstract class GLContextImpl extends GLContext {
}
quirks.addQuirk( quirk );
}
+ {
+ final int quirk = GLRendererQuirks.NeedSharedObjectSync;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType());
+ }
+ quirks.addQuirk( quirk );
+ }
if( Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Mavericks) >= 0 && 3==reqMajor && 4==major ) {
final int quirk = GLRendererQuirks.GL4NeedsGL3Request;
if(DEBUG) {
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 a66aaf9d8..8d040222a 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
@@ -107,12 +107,13 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
animator.start();
final GearsES2 g1 = new GearsES2(0);
+ g1.setSyncObjects(g1); // this is master, since rendered we must use it as sync
final GLWindow f1 = createGLWindow(0, 0, g1);
animator.add(f1);
final InsetsImmutable insets = f1.getInsets();
final GearsES2 g2 = new GearsES2(0);
- g2.setSharedGears(g1);
+ g2.setSharedGears(g1); // also uses master g1 as sync, if required
final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, g2);
f2.setSharedAutoDrawable(f1);
@@ -120,7 +121,7 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
f2.setVisible(true);
final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGears(g1);
+ g3.setSharedGears(g1); // also uses master g1 as sync, if required
final GLWindow f3 = createGLWindow(f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), g3);
f3.setSharedAutoDrawable(f1);
@@ -222,6 +223,7 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
public void asyncEachAnimator(final boolean destroyCleanOrder) throws InterruptedException {
final Animator a1 = new Animator();
final GearsES2 g1 = new GearsES2(0);
+ g1.setSyncObjects(g1); // this is master, since rendered we must use it as sync
final GLWindow f1 = createGLWindow(0, 0, g1);
a1.add(f1);
a1.start();
@@ -230,7 +232,7 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
final Animator a2 = new Animator();
final GearsES2 g2 = new GearsES2(0);
- g2.setSharedGears(g1);
+ g2.setSharedGears(g1); // also uses master g1 as sync, if required
final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, g2);
f2.setSharedAutoDrawable(f1);
@@ -240,7 +242,7 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
final Animator a3 = new Animator();
final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGears(g1);
+ g3.setSharedGears(g1); // also uses master g1 as sync, if required
final GLWindow f3 = createGLWindow(f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), g3);
f3.setSharedAutoDrawable(f1);
@@ -336,8 +338,10 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
}
static long duration = 1000; // ms
+ static boolean mainRun = false;
public static void main(final String args[]) {
+ mainRun = true;
for(int i=0; i