aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-09-28 18:59:11 +0200
committerSven Gothel <[email protected]>2012-09-28 18:59:11 +0200
commit27fe889023c7366e264647e5dc25053f22df0956 (patch)
tree102cec7585b32bf0f741918757acba3dc38404ab /src/jogl/classes
parent30d6d5e3c1ee7132c2b3cc722839528882e03053 (diff)
Adding Mesa Quirk 'NoSetSwapIntervalPostRetarget': SIGSEGV on setSwapInterval() after changing the context's drawable w/ 'Mesa 8.0.4' dri2SetSwapInterval/DRI2 (soft & intel)
Analyzing 'TestGLContextDrawableSwitchNEWT' crash at setSwapInterval -> dri2SetSwapInterval after retargeting the context (new drawable association). Turns out Mesa's dri2SetSwapInterval may have a bug. +++ GLContext TRACE_SWITCH: Add drawable handle to debug/trace output.
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java9
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java25
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java38
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java1
4 files changed, 44 insertions, 29 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
index 13c94c6f2..1bbe22548 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
@@ -48,12 +48,15 @@ public class GLRendererQuirks {
/** No offscreen bitmap available, currently true for JOGL's OSX implementation. */
public static final int NoOffscreenBitmap = 3;
+ /** SIGSEGV on setSwapInterval() after changing the context's drawable w/ 'Mesa 8.0.4' dri2SetSwapInterval/DRI2 (soft & intel) */
+ public static final int NoSetSwapIntervalPostRetarget = 4;
+
/** Number of quirks known. */
- public static final int COUNT = 4;
+ public static final int COUNT = 5;
private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
- "NoOffscreenBitmap"
- };
+ "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget"
+ };
private final int _bitmask;
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 93b9bfe82..1cee0209c 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -162,6 +162,9 @@ public abstract class GLContext {
private int currentSwapInterval;
protected GLRendererQuirks glRendererQuirks;
+ /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */
+ protected boolean drawableRetargeted;
+
protected void resetStates() {
if (DEBUG) {
System.err.println(getThreadName() + ": GLContext.resetStates()");
@@ -175,6 +178,7 @@ public abstract class GLContext {
contextHandle=0;
currentSwapInterval = -1;
glRendererQuirks = null;
+ drawableRetargeted = false;
}
/**
@@ -781,8 +785,8 @@ public abstract class GLContext {
}
/**
- * Set the swap interval if the current context.
- * @param interval Should be &ge; 0. 0 Disables the vertical synchronisation,
+ * Set the swap interval of the current context and attached drawable.
+ * @param interval Should be &ge; 0. 0 disables the vertical synchronization,
* where &ge; 1 is the number of vertical refreshes before a swap buffer occurs.
* A value &lt; 0 is ignored.
* @return true if the operation was successful, otherwise false
@@ -792,9 +796,11 @@ public abstract class GLContext {
public final boolean setSwapInterval(int interval) throws GLException {
validateCurrent();
if(0<=interval) {
- if( setSwapIntervalImpl(interval) ) {
- currentSwapInterval = interval;
- return true;
+ if( !drawableRetargeted || !hasRendererQuirk(GLRendererQuirks.NoSetSwapIntervalPostRetarget) ) {
+ if( setSwapIntervalImpl(interval) ) {
+ currentSwapInterval = interval;
+ return true;
+ }
}
}
return false;
@@ -808,15 +814,12 @@ public abstract class GLContext {
* the default value <code>-1</code> is returned.
* </p>
* <p>
- * The default value for a valid context is <code>1</code> for
- * an EGL based profile (ES1 or ES2) and <code>-1</code> (undefined)
- * for desktop.
+ * For a valid context the default value is <code>1</code>
+ * in case of an EGL based profile (ES1 or ES2) and <code>-1</code>
+ * (undefined) for desktop.
* </p>
*/
public final int getSwapInterval() {
- if(-1 == currentSwapInterval && this.isGLES()) {
- currentSwapInterval = 1;
- }
return currentSwapInterval;
}
protected final void setDefaultSwapInterval() {
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index e164dfe44..d7f61681f 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -214,6 +214,7 @@ public abstract class GLContextImpl extends GLContext {
}
final GLDrawableImpl old = drawable;
old.associateContext(this, false);
+ drawableRetargeted = null != drawable;
drawable = (GLDrawableImpl) readWrite ;
drawable.associateContext(this, true);
if(lockHeld) {
@@ -270,7 +271,7 @@ public abstract class GLContextImpl extends GLContext {
}
private void release(boolean inDestruction) throws GLException {
if(TRACE_SWITCH) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - release() - force: "+inDestruction+", "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - release() - force: "+inDestruction+", "+lock);
}
if ( !lock.isOwner(Thread.currentThread()) ) {
throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this);
@@ -296,7 +297,7 @@ public abstract class GLContextImpl extends GLContext {
drawable.unlockSurface();
lock.unlock();
if(TRACE_SWITCH) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - "+(actualRelease?"switch":"keep ")+" - CONTEXT_RELEASE - "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+(actualRelease?"switch":"keep ")+" - CONTEXT_RELEASE - "+lock);
}
}
if(null != drawableContextMadeCurrentException) {
@@ -310,7 +311,7 @@ public abstract class GLContextImpl extends GLContext {
public final void destroy() {
if (DEBUG || TRACE_SWITCH) {
System.err.println(getThreadName() + ": GLContextImpl.destroy.0: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) +
- ", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
+ ", surf "+toHexString(drawable.getHandle())+", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
}
if (contextHandle != 0) {
int lockRes = drawable.lockSurface();
@@ -463,7 +464,7 @@ public abstract class GLContextImpl extends GLContext {
// For Mac OS X, however, we need to update the context to track resizes
drawableUpdatedNotify();
if(TRACE_SWITCH) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - keep - CONTEXT_CURRENT - "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep - CONTEXT_CURRENT - "+lock);
}
return CONTEXT_CURRENT;
} else {
@@ -503,7 +504,7 @@ public abstract class GLContextImpl extends GLContext {
if (res == CONTEXT_NOT_CURRENT) {
if(TRACE_SWITCH) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_NOT_CURRENT - "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - CONTEXT_NOT_CURRENT - "+lock);
}
} else {
setCurrent(this);
@@ -527,10 +528,10 @@ public abstract class GLContextImpl extends GLContext {
contextRealized(true);
if(DEBUG || TRACE_SWITCH) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT_NEW - "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - CONTEXT_CURRENT_NEW - "+lock);
}
} else if(TRACE_SWITCH) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - CONTEXT_CURRENT - "+lock);
}
contextMadeCurrent(true);
@@ -568,10 +569,10 @@ public abstract class GLContextImpl extends GLContext {
}
if (DEBUG || TRACE_SWITCH) {
if(created) {
- System.err.println(getThreadName() + ": Create GL context OK: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + " for " + getClass().getName()+" - "+getGLVersion());
+ System.err.println(getThreadName() + ": Create GL context OK: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName()+" - "+getGLVersion());
// Thread.dumpStack();
} else {
- System.err.println(getThreadName() + ": Create GL context FAILED obj " + toHexString(hashCode()) + ", for " + getClass().getName());
+ System.err.println(getThreadName() + ": Create GL context FAILED obj " + toHexString(hashCode()) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName());
}
}
if(!created) {
@@ -1296,12 +1297,21 @@ public abstract class GLContextImpl extends GLContext {
}
quirks[i++] = quirk;
}
- if( glRendererLowerCase.contains("intel(r)") && glRendererLowerCase.contains("mesa") ) {
- final int quirk = GLRendererQuirks.NoDoubleBufferedPBuffer;
- if(DEBUG) {
- System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
+ if( glRendererLowerCase.contains("mesa") ) {
+ {
+ final int quirk = GLRendererQuirks.NoSetSwapIntervalPostRetarget;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
+ }
+ quirks[i++] = quirk;
+ }
+ if( glRendererLowerCase.contains("intel(r)") ) {
+ final int quirk = GLRendererQuirks.NoDoubleBufferedPBuffer;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
+ }
+ quirks[i++] = quirk;
}
- quirks[i++] = quirk;
}
glRendererQuirks = new GLRendererQuirks(quirks, 0, i);
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index d1801d8f8..e1330eb52 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -245,7 +245,6 @@ public abstract class X11GLXContext extends GLContextImpl {
// hence we need to catch the X11 Error within this block.
X11Util.setX11ErrorHandler(true, DEBUG ? false : true); // make sure X11 error handler is set
ctx = _glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs);
- if(DEBUG) { X11Lib.XSync(display, false); }
} catch (RuntimeException re) {
if(DEBUG) {
Throwable t = new Throwable(getThreadName()+": Info: X11GLXContext.createContextARBImpl glXCreateContextAttribsARB failed with "+getGLVersion(major, minor, ctp, "@creation"), re);