aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl/x11
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/x11')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java51
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java135
2 files changed, 107 insertions, 79 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
index 1dadc2edf..fddfb4cd1 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
@@ -40,6 +40,7 @@
package com.jogamp.opengl.impl.x11.glx;
+import com.jogamp.common.util.VersionNumber;
import java.nio.*;
import java.util.*;
import javax.media.opengl.*;
@@ -48,13 +49,14 @@ import com.jogamp.opengl.impl.*;
import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
import com.jogamp.nativewindow.impl.x11.X11Util;
-import javax.media.nativewindow.x11.X11GraphicsDevice;
public abstract class X11GLXContext extends GLContextImpl {
protected static final boolean TRACE_CONTEXT_CURRENT = false; // true;
private static final Map/*<String, String>*/ functionNameMap;
private static final Map/*<String, String>*/ extensionNameMap;
+ private VersionNumber glXVersion;
+ private boolean glXVersionOneThreeCapable;
private boolean glXQueryExtensionsStringInitialized;
private boolean glXQueryExtensionsStringAvailable;
private GLXExt glXExt;
@@ -78,17 +80,14 @@ public abstract class X11GLXContext extends GLContextImpl {
extensionNameMap.put("GL_ARB_pixel_format", "GLX_SGIX_pbuffer"); // good enough
}
- public X11GLXContext(GLDrawableImpl drawable, GLDrawableImpl drawableRead,
- GLContext shareWith) {
- super(drawable, drawableRead, shareWith);
- }
-
- public X11GLXContext(GLDrawableImpl drawable,
- GLContext shareWith) {
- this(drawable, null, shareWith);
+ X11GLXContext(GLDrawableImpl drawable,
+ GLContext shareWith) {
+ super(drawable, shareWith);
}
protected void resetState() {
+ glXVersion = null;
+ glXVersionOneThreeCapable = false;
glXQueryExtensionsStringInitialized=false;
glXQueryExtensionsStringAvailable=false;
// no inner state glXExt=null;
@@ -120,16 +119,38 @@ public abstract class X11GLXContext extends GLContextImpl {
protected Map/*<String, String>*/ getExtensionNameMap() { return extensionNameMap; }
- protected boolean glXMakeContextCurrent(long dpy, long writeDrawable, long readDrawable, long ctx) {
+ public final boolean isGLReadDrawableAvailable() {
+ if(null == glXVersion) {
+ X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl();
+
+ X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ AbstractGraphicsDevice device = config.getScreen().getDevice();
+
+ glXVersion = factory.getGLXVersion(device);
+ if( null != glXVersion ) {
+ glXVersionOneThreeCapable = glXVersion.compareTo(factory.versionOneThree)>=0;
+ }
+ }
+ return glXVersionOneThreeCapable;
+ }
+
+ private final boolean glXMakeContextCurrent(long dpy, long writeDrawable, long readDrawable, long ctx) {
boolean res = false;
try {
if(TRACE_CONTEXT_CURRENT) {
Throwable t = new Throwable(Thread.currentThread()+" - glXMakeContextCurrent("+toHexString(dpy)+", "+
- toHexString(writeDrawable)+", "+toHexString(readDrawable)+", "+toHexString(ctx)+")");
+ toHexString(writeDrawable)+", "+toHexString(readDrawable)+", "+toHexString(ctx)+") - GLX >= 1.3 "+ glXVersionOneThreeCapable);
t.printStackTrace();
}
- res = GLX.glXMakeContextCurrent(dpy, writeDrawable, readDrawable, ctx);
+ if ( glXVersionOneThreeCapable ) {
+ res = GLX.glXMakeContextCurrent(dpy, writeDrawable, readDrawable, ctx);
+ } else if ( writeDrawable == readDrawable ) {
+ res = GLX.glXMakeCurrent(dpy, writeDrawable, ctx);
+ } else {
+ // should not happen due to 'isGLReadDrawableAvailable()' query in GLContextImpl
+ throw new InternalError("Given readDrawable but no driver support");
+ }
} catch (RuntimeException re) {
if(DEBUG) {
System.err.println("Warning: X11GLXContext.glXMakeContextCurrent failed: "+re+", with "+
@@ -258,6 +279,8 @@ public abstract class X11GLXContext extends GLContextImpl {
X11GLXContext sharedContext = (X11GLXContext) factory.getOrCreateSharedContextImpl(device);
long display = device.getHandle();
+ isGLReadDrawableAvailable(); // trigger setup glXVersionOneThreeCapable
+
X11GLXContext other = (X11GLXContext) GLContextShareSet.getShareContext(this);
long share = 0;
if (other != null) {
@@ -270,7 +293,7 @@ public abstract class X11GLXContext extends GLContextImpl {
GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
GLProfile glp = glCaps.getGLProfile();
- isVendorATI = factory.isVendorATI(device);
+ isVendorATI = factory.isGLXVendorATI(device);
if(config.getFBConfigID()<0) {
// not able to use FBConfig
@@ -388,7 +411,7 @@ public abstract class X11GLXContext extends GLContextImpl {
} finally {
X11Util.setX11ErrorHandler(false, false);
}
- if (DEBUG && (VERBOSE || newCreated)) {
+ if (DEBUG && newCreated) {
System.err.println(getThreadName() + ": glXMakeCurrent(display " +
toHexString(dpy)+
", drawable " + toHexString(drawable.getHandle()) +
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index 4412a7a1c..c8b656e9f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -55,6 +55,7 @@ import java.util.Iterator;
public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
private static final DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper;
+ static final VersionNumber versionOneThree = new VersionNumber(1, 3, 0);
static {
DesktopGLDynamicLookupHelper tmp = null;
@@ -208,7 +209,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
sharedDevice.setCloseDisplay(true);
X11Util.lockDefaultToolkit(sharedDevice.getHandle()); // OK
try {
- String vendorName = GLXUtil.getVendorName(sharedDevice.getHandle());
+ String glXVendorName = GLXUtil.getVendorName(sharedDevice.getHandle());
X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
X11DummyGLXDrawable sharedDrawable = X11DummyGLXDrawable.create(sharedScreen, X11GLXDrawableFactory.this,
GLProfile.getDefault(sharedDevice));
@@ -216,9 +217,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
throw new GLException("Couldn't init shared screen(" + sharedScreen + ")/drawable(" + sharedDrawable + ")");
}
X11GLXContext sharedContext;
+ VersionNumber glXVersion;
try {
X11GLXContext ctx = (X11GLXContext) sharedDrawable.createContext(null);
ctx.makeCurrent();
+ {
+ int[] major = new int[1];
+ int[] minor = new int[1];
+ GLXUtil.getGLXVersion(sharedDevice.getHandle(), major, minor);
+ glXVersion = new VersionNumber(major[0], minor[0], 0);
+ }
ctx.release();
sharedContext = ctx;
} catch (Throwable t) {
@@ -228,12 +236,14 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
throw new GLException("X11GLXDrawableFactory - Shared Context is null");
}
if (DEBUG) {
- System.err.println("!!! SharedDevice: "+sharedDevice);
- System.err.println("!!! SharedScreen: "+sharedScreen);
+ System.err.println("!!! SharedDevice: "+sharedDevice);
+ System.err.println("!!! SharedScreen: "+sharedScreen);
System.err.println("!!! SharedContext: "+sharedContext);
- System.err.println("!!! Vendor: "+vendorName);
+ System.err.println("!!! GLX Vendor: "+glXVendorName);
+ System.err.println("!!! GLX Version: "+glXVersion +
+ " >= 1.3: " + ( glXVersion.compareTo(versionOneThree) >= 0 ) );
}
- return new SharedResource(sharedDevice, sharedScreen, sharedDrawable, sharedContext, vendorName);
+ return new SharedResource(sharedDevice, sharedScreen, sharedDrawable, sharedContext, glXVersion, glXVendorName);
} finally {
X11Util.unlockDefaultToolkit(sharedDevice.getHandle()); // OK
}
@@ -246,10 +256,10 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
if (DEBUG) {
System.err.println("!!! Shutdown Shared:");
- System.err.println("!!! Device : "+sr.device);
- System.err.println("!!! Screen : "+sr.screen);
- System.err.println("!!! Drawable: "+sr.drawable);
- System.err.println("!!! CTX : "+sr.context);
+ System.err.println("!!! Device : "+sr.device);
+ System.err.println("!!! Screen : "+sr.screen);
+ System.err.println("!!! Drawable: "+sr.drawable);
+ System.err.println("!!! CTX : "+sr.context);
}
if (null != sr.context) {
@@ -278,23 +288,34 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
SharedResourcesRunner sharedResourcesRunner=null;
static class SharedResource {
- private X11GraphicsDevice device;
- private X11GraphicsScreen screen;
- private X11DummyGLXDrawable drawable;
- private X11GLXContext context;
- private String vendorName;
- private boolean isVendorATI;
- private boolean isVendorNVIDIA;
-
- SharedResource(X11GraphicsDevice dev, X11GraphicsScreen scrn, X11DummyGLXDrawable draw, X11GLXContext ctx, String vendor) {
+ X11GraphicsDevice device;
+ X11GraphicsScreen screen;
+ X11DummyGLXDrawable drawable;
+ X11GLXContext context;
+ String glXVendorName;
+ boolean isGLXVendorATI;
+ boolean isGLXVendorNVIDIA;
+ VersionNumber glXVersion;
+
+ SharedResource(X11GraphicsDevice dev, X11GraphicsScreen scrn,
+ X11DummyGLXDrawable draw, X11GLXContext ctx,
+ VersionNumber glXVer, String glXVendor) {
device = dev;
screen = scrn;
drawable = draw;
context = ctx;
- vendorName = vendor;
- isVendorATI = GLXUtil.isVendorATI(vendorName);
- isVendorNVIDIA = GLXUtil.isVendorNVIDIA(vendorName);
+ glXVersion = glXVer;
+ glXVendorName = glXVendor;
+ isGLXVendorATI = GLXUtil.isVendorATI(glXVendorName);
+ isGLXVendorNVIDIA = GLXUtil.isVendorNVIDIA(glXVendorName);
}
+ X11GraphicsDevice getDevice() { return device; }
+ X11GraphicsScreen getScreen() { return screen; }
+ X11GLXContext getContext() { return context; }
+ String getGLXVendorName() { return glXVendorName; }
+ boolean isGLXVendorATI() { return isGLXVendorATI; }
+ boolean isGLXVendorNVIDIA() { return isGLXVendorNVIDIA; }
+ VersionNumber getGLXVersion() { return glXVersion; }
}
HashMap/*<connection, SharedResource>*/ sharedMap = new HashMap();
X11GraphicsDevice defaultDevice;
@@ -354,7 +375,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) {
SharedResource sr = getOrCreateShared(device);
if(null!=sr) {
- return sr.context;
+ return sr.getContext();
}
return null;
}
@@ -362,31 +383,39 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
protected final long getOrCreateSharedDpy(AbstractGraphicsDevice device) {
SharedResource sr = getOrCreateShared(device);
if(null!=sr) {
- return sr.device.getHandle();
+ return sr.getDevice().getHandle();
}
return 0;
}
- protected final String getVendorName(AbstractGraphicsDevice device) {
+ protected final VersionNumber getGLXVersion(AbstractGraphicsDevice device) {
SharedResource sr = getOrCreateShared(device);
if(null!=sr) {
- return sr.vendorName;
+ return sr.getGLXVersion();
+ }
+ return null;
+ }
+
+ protected final String getGLXVendorName(AbstractGraphicsDevice device) {
+ SharedResource sr = getOrCreateShared(device);
+ if(null!=sr) {
+ return sr.getGLXVendorName();
}
return GLXUtil.getVendorName(device.getHandle());
}
- protected final boolean isVendorATI(AbstractGraphicsDevice device) {
+ protected final boolean isGLXVendorATI(AbstractGraphicsDevice device) {
SharedResource sr = getOrCreateShared(device);
if(null!=sr) {
- return sr.isVendorATI;
+ return sr.isGLXVendorATI();
}
return GLXUtil.isVendorATI(device.getHandle());
}
- protected final boolean isVendorNVIDIA(AbstractGraphicsDevice device) {
+ protected final boolean isGLXVendorNVIDIA(AbstractGraphicsDevice device) {
SharedResource sr = getOrCreateShared(device);
if(null!=sr) {
- return sr.isVendorNVIDIA;
+ return sr.isGLXVendorNVIDIA();
}
return GLXUtil.isVendorNVIDIA(device.getHandle());
}
@@ -413,43 +442,19 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return new X11OffscreenGLXDrawable(this, target);
}
- public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
- return glxVersionGreaterEqualThan(device, 1, 3);
+ public final boolean glXVersionGreaterEqualOneThree(AbstractGraphicsDevice device) {
+ VersionNumber glXVersion = getGLXVersion(device);
+ return ( null != glXVersion ) ? glXVersion.compareTo(versionOneThree) >= 0 : false ;
}
- private boolean glxVersionsQueried = false;
- private int glxVersionMajor=0, glxVersionMinor=0;
- protected final boolean glxVersionGreaterEqualThan(AbstractGraphicsDevice device, int majorReq, int minorReq) {
- if (!glxVersionsQueried) {
- if(null == device) {
- SharedResource sr = getOrCreateShared(defaultDevice);
- if(null!=sr) {
- device = sr.device;
- }
- }
- if(null == device) {
- throw new GLException("FIXME: No AbstractGraphicsDevice (passed or shared-device");
- }
- device.lock(); // OK
- try {
- long display = device.getHandle();
- int[] major = new int[1];
- int[] minor = new int[1];
-
- GLXUtil.getGLXVersion(display, major, minor);
- if (DEBUG) {
- System.err.println("!!! GLX version: major " + major[0] +
- ", minor " + minor[0]);
- }
-
- glxVersionMajor = major[0];
- glxVersionMinor = minor[0];
- glxVersionsQueried = true;
- } finally {
- device.unlock(); // OK
+ public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
+ if(null == device) {
+ SharedResource sr = getOrCreateShared(defaultDevice);
+ if(null!=sr) {
+ device = sr.getDevice();
}
- }
- return ( glxVersionMajor > majorReq ) || ( glxVersionMajor == majorReq && glxVersionMinor >= minorReq ) ;
+ }
+ return glXVersionGreaterEqualOneThree(device);
}
protected final GLDrawableImpl createGLPbufferDrawableImpl(final NativeSurface target) {
@@ -469,7 +474,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
* since switching Display in this regard is another ATI bug.
*/
SharedResource sr = getOrCreateShared(device);
- if( null!=sr && sr.isVendorATI && null == GLContext.getCurrent() ) {
+ if( null!=sr && sr.isGLXVendorATI() && null == GLContext.getCurrent() ) {
synchronized(sr.context) {
sr.context.makeCurrent();
try {
@@ -490,7 +495,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
X11GraphicsScreen screen = null;
SharedResource sr = getOrCreateShared(defaultDevice);
if(null!=sr) {
- screen = sr.screen;
+ screen = sr.getScreen();
}
if(null==screen) {
return null;