summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-25 05:47:29 +0200
committerSven Gothel <[email protected]>2012-03-25 05:47:29 +0200
commita0abff2c5ea6adee2813bf49141b2a106f055390 (patch)
tree6d92b800af673fbc001ef6ff891fd69e4c7de245
parent2357728a8b1ed2edd961b94e75ebddfe12e4516f (diff)
Fix EGLConfig re-use w/ different EGLDisplay handle (Triggered w/ Mesa EGL/ES)
Reusing the native EGLConfig handle of another EGLDisplay is invalid, hence the EGLCapabilities cfg-handle value shall be 'refreshed' using the immutable cfg-id and the new EGLDisplay. Also fix EGLError value in createSurface() exception and don't override EGLCapabilities transparency value for a given EGLConfig ID.
-rwxr-xr-xmake/scripts/tests.sh4
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java22
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java20
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java1
5 files changed, 34 insertions, 19 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 54f3159aa..9f1f678b4 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -67,12 +67,12 @@ function jrun() {
#D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
#D_ARGS="-Dnewt.debug.MainThread"
#D_ARGS="-Dnewt.debug.Window"
- D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all"
+ #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all"
#D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow"
#D_ARGS="-Djogl.debug=all"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch"
#D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache"
- #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable"
+ D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable"
#D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile"
#D_ARGS="-Djogl.debug.GLProfile"
#D_ARGS="-Dnewt.debug.EDT -Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.NativeWindow"
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
index b54089d13..6ef016aa4 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
@@ -90,8 +90,9 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), surface.getSurfaceHandle());
- if (EGL.EGL_NO_SURFACE==eglSurface) {
- final int eglError0 = EGL.eglGetError();
+ int eglError0 = EGL.EGL_SUCCESS;
+ if (EGL.EGL_NO_SURFACE == eglSurface) {
+ eglError0 = EGL.eglGetError();
if(EGL.EGL_BAD_NATIVE_WINDOW == eglError0) {
// Try window handle if available and differs (Windows HDC / HWND).
// ANGLE impl. required HWND on Windows.
@@ -102,12 +103,15 @@ public abstract class EGLDrawable extends GLDrawableImpl {
System.err.println(getThreadName() + ": Info: Creation of window surface w/ surface handle failed: "+eglConfig+", error "+toHexString(eglError0)+", retry w/ windowHandle");
}
eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), nw.getWindowHandle());
+ if (EGL.EGL_NO_SURFACE == eglSurface) {
+ eglError0 = EGL.eglGetError();
+ }
}
}
}
}
- if (EGL.EGL_NO_SURFACE==eglSurface) {
- throw new GLException("Creation of window surface failed: "+eglConfig+", "+surface+", error "+toHexString(EGL.eglGetError()));
+ if (EGL.EGL_NO_SURFACE == eglSurface) {
+ throw new GLException("Creation of window surface failed: "+eglConfig+", "+surface+", error "+toHexString(eglError0));
}
if(DEBUG) {
@@ -176,7 +180,15 @@ public abstract class EGLDrawable extends GLDrawableImpl {
AbstractGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities();
if(aConfig instanceof EGLGraphicsConfiguration) {
- eglConfig = new EGLGraphicsConfiguration(s, (EGLGLCapabilities)aConfig.getChosenCapabilities(), capsRequested, null);
+ final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities();
+ if(0 == capsChosen.getEGLConfig()) {
+ // 'refresh' the native EGLConfig handle
+ capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDisplay, capsChosen.getEGLConfigID()));
+ if(0 == capsChosen.getEGLConfig()) {
+ throw new GLException("Refreshing native EGLConfig handle failed: "+capsChosen+" of "+aConfig);
+ }
+ }
+ eglConfig = new EGLGraphicsConfiguration(s, capsChosen, capsRequested, null);
if(DEBUG) {
System.err.println(getThreadName() + ": Reusing chosenCaps: "+eglConfig);
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
index 2e1793d72..0ae597938 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
@@ -29,14 +29,13 @@
package jogamp.opengl.egl;
import javax.media.nativewindow.NativeWindowException;
-import javax.media.nativewindow.VisualIDHolder;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
public class EGLGLCapabilities extends GLCapabilities {
- final private long eglcfg;
+ private long eglcfg;
final private int eglcfgid;
final private int renderableType;
final private int nativeVisualID;
@@ -74,7 +73,8 @@ public class EGLGLCapabilities extends GLCapabilities {
throw new GLException(e);
}
}
-
+
+ final protected void setEGLConfig(long v) { eglcfg=v; }
final public long getEGLConfig() { return eglcfg; }
final public int getEGLConfigID() { return eglcfgid; }
final public int getRenderableType() { return renderableType; }
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
index 35e30c5f4..9f9a7b9c4 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
@@ -73,19 +73,20 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
}
public static EGLGraphicsConfiguration create(GLCapabilitiesImmutable capsRequested, AbstractGraphicsScreen absScreen, int cfgID) {
- AbstractGraphicsDevice absDevice = absScreen.getDevice();
+ final AbstractGraphicsDevice absDevice = absScreen.getDevice();
if(null==absDevice || !(absDevice instanceof EGLGraphicsDevice)) {
throw new GLException("GraphicsDevice must be a valid EGLGraphicsDevice");
}
- long dpy = absDevice.getHandle();
+ final long dpy = absDevice.getHandle();
if (dpy == EGL.EGL_NO_DISPLAY) {
throw new GLException("Invalid EGL display: "+absDevice);
}
- GLProfile glp = capsRequested.getGLProfile();
- long cfg = EGLConfigId2EGLConfig(glp, dpy, cfgID);
- EGLGLCapabilities caps = EGLConfig2Capabilities(glp, dpy, cfg, false, capsRequested.isOnscreen(), capsRequested.isPBuffer());
- caps = (EGLGLCapabilities) GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(caps, capsRequested.isBackgroundOpaque()); // FIXME: valid to override EGL transparency ?
- return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser());
+ final long cfg = EGLConfigId2EGLConfig(dpy, cfgID);
+ if(0 < cfg) {
+ final EGLGLCapabilities caps = EGLConfig2Capabilities(capsRequested.getGLProfile(), dpy, cfg, false, capsRequested.isOnscreen(), capsRequested.isPBuffer());
+ return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser());
+ }
+ return null;
}
@Override
@@ -106,7 +107,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
}
}
- public static long EGLConfigId2EGLConfig(GLProfile glp, long display, int configID) {
+ public static long EGLConfigId2EGLConfig(long display, int configID) {
int[] attrs = new int[] {
EGL.EGL_CONFIG_ID, configID,
EGL.EGL_NONE
@@ -365,7 +366,8 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
@Override
public String toString() {
- return getClass().getSimpleName()+"["+getScreen()+", eglConfigID "+toHexString(getNativeConfigID())+
+ return getClass().getSimpleName()+"["+getScreen()+
+ ",\n\teglConfigHandle "+toHexString(getNativeConfig())+", eglConfigID "+toHexString(getNativeConfigID())+
",\n\trequested " + getRequestedCapabilities()+
",\n\tchosen " + getChosenCapabilities()+
"]";
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index 2d9fc0227..aac7f5f85 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -285,6 +285,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
throw new GLException("Graphics configuration failed [direct caps, eglGetConfig/chooser and fixed-caps(1-3)]");
}
if(ownEGLDisplay) {
+ ((EGLGLCapabilities) res.getChosenCapabilities()).setEGLConfig(0); // eglDisplay: EOL
EGLDisplayUtil.eglTerminate(eglDisplay);
}
return res;