summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableHelper.java1
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java70
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java68
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java8
4 files changed, 98 insertions, 49 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index bdf0b6d74..83b16884e 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -49,7 +49,6 @@ import javax.media.nativewindow.ProxySurface;
import javax.media.nativewindow.UpstreamSurfaceHook;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
index 7cc2d0f2e..22e2f14b5 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
@@ -51,33 +51,67 @@ public class GLXUtil {
throw new IllegalArgumentException("null X11GraphicsDevice display handle");
}
boolean glXAvailable = false;
+ x11Device.lock();
try {
glXAvailable = GLX.glXQueryExtension(x11Device.getHandle(), null, 0, null, 0);
- } catch (Throwable t) { /* n/a */ }
+ } catch (Throwable t) { /* n/a */
+ } finally {
+ x11Device.unlock();
+ }
return glXAvailable;
}
- public static VersionNumber getGLXServerVersionNumber(long display) {
+ public static String getGLXClientString(X11GraphicsDevice x11Device, int name) {
+ x11Device.lock();
+ try {
+ return GLX.glXGetClientString(x11Device.getHandle(), name);
+ } finally {
+ x11Device.unlock();
+ }
+ }
+ public static String queryGLXServerString(X11GraphicsDevice x11Device, int screen_idx, int name) {
+ x11Device.lock();
+ try {
+ return GLX.glXQueryServerString(x11Device.getHandle(), screen_idx, name);
+ } finally {
+ x11Device.unlock();
+ }
+ }
+ public static String queryGLXExtensionsString(X11GraphicsDevice x11Device, int screen_idx) {
+ x11Device.lock();
+ try {
+ return GLX.glXQueryExtensionsString(x11Device.getHandle(), screen_idx);
+ } finally {
+ x11Device.unlock();
+ }
+ }
+
+ public static VersionNumber getGLXServerVersionNumber(X11GraphicsDevice x11Device) {
int[] major = new int[1];
int[] minor = new int[1];
- if (!GLX.glXQueryVersion(display, major, 0, minor, 0)) {
- throw new GLException("glXQueryVersion failed");
+ x11Device.lock();
+ try {
+ if (!GLX.glXQueryVersion(x11Device.getHandle(), major, 0, minor, 0)) {
+ throw new GLException("glXQueryVersion failed");
+ }
+
+ // Work around bugs in ATI's Linux drivers where they report they
+ // only implement GLX version 1.2 on the server side
+ if (major[0] == 1 && minor[0] == 2) {
+ String str = GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_VERSION);
+ try {
+ // e.g. "1.3"
+ major[0] = Integer.valueOf(str.substring(0, 1)).intValue();
+ minor[0] = Integer.valueOf(str.substring(2, 3)).intValue();
+ } catch (Exception e) {
+ major[0] = 1;
+ minor[0] = 2;
+ }
+ }
+ } finally {
+ x11Device.unlock();
}
-
- // Work around bugs in ATI's Linux drivers where they report they
- // only implement GLX version 1.2 on the server side
- if (major[0] == 1 && minor[0] == 2) {
- String str = GLX.glXGetClientString(display, GLX.GLX_VERSION);
- try {
- // e.g. "1.3"
- major[0] = Integer.valueOf(str.substring(0, 1)).intValue();
- minor[0] = Integer.valueOf(str.substring(2, 3)).intValue();
- } catch (Exception e) {
- major[0] = 1;
- minor[0] = 2;
- }
- }
return new VersionNumber(major[0], minor[0], 0);
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index bdccc1047..d1801d8f8 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -59,8 +59,10 @@ import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLDrawableImpl;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.util.VersionNumber;
import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
+import com.jogamp.nativewindow.x11.X11GraphicsDevice;
import com.jogamp.opengl.GLExtensions;
public abstract class X11GLXContext extends GLContextImpl {
@@ -77,6 +79,8 @@ public abstract class X11GLXContext extends GLContextImpl {
// and therefore requires the toolkit to be locked around all GL
// calls rather than just all GLX calls
protected boolean isDirect;
+ protected volatile VersionNumber glXServerVersion;
+ protected volatile boolean isGLXVersionGreaterEqualOneThree;
static {
functionNameMap = new HashMap<String, String>();
@@ -100,6 +104,8 @@ public abstract class X11GLXContext extends GLContextImpl {
hasSwapIntervalSGI = 0;
hasSwapGroupNV = 0;
isDirect = false;
+ glXServerVersion = null;
+ isGLXVersionGreaterEqualOneThree = false;
super.resetStates();
}
@@ -130,8 +136,13 @@ public abstract class X11GLXContext extends GLContextImpl {
@Override
protected Map<String, String> getExtensionNameMap() { return extensionNameMap; }
- protected final boolean isGLXVersionGreaterEqualOneThree() {
- return ((X11GLXDrawableFactory)drawable.getFactoryImpl()).isGLXVersionGreaterEqualOneThree(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice());
+ protected final boolean isGLXVersionGreaterEqualOneThree() { // fast-path: use cached boolean
+ if(null != glXServerVersion) {
+ return isGLXVersionGreaterEqualOneThree;
+ }
+ glXServerVersion = ((X11GLXDrawableFactory)drawable.getFactoryImpl()).getGLXVersionNumber(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice());
+ isGLXVersionGreaterEqualOneThree = null != glXServerVersion ? glXServerVersion.compareTo(X11GLXDrawableFactory.versionOneThree) >= 0 : false;
+ return isGLXVersionGreaterEqualOneThree;
}
@Override
@@ -453,35 +464,40 @@ public abstract class X11GLXContext extends GLContextImpl {
@Override
protected final StringBuilder getPlatformExtensionsStringImpl() {
- StringBuilder sb = new StringBuilder();
- if (DEBUG) {
- System.err.println("GLX Version client version "+ GLXUtil.getClientVersionNumber()+
- ", server: "+
- ((X11GLXDrawableFactory)drawable.getFactoryImpl()).getGLXVersionNumber(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice()));
- }
final NativeSurface ns = drawable.getNativeSurface();
- if(((X11GLXDrawableFactory)drawable.getFactoryImpl()).isGLXVersionGreaterEqualOneOne(ns.getGraphicsConfiguration().getScreen().getDevice())) {
- {
- final String ret = GLX.glXGetClientString(ns.getDisplayHandle(), GLX.GLX_EXTENSIONS);
- if (DEBUG) {
- System.err.println("GLX extensions (glXGetClientString): " + ret);
- }
- sb.append(ret).append(" ");
+ final X11GraphicsDevice x11Device = (X11GraphicsDevice) ns.getGraphicsConfiguration().getScreen().getDevice();
+ StringBuilder sb = new StringBuilder();
+ x11Device.lock();
+ try{
+ if (DEBUG) {
+ System.err.println("GLX Version client version "+ GLXUtil.getClientVersionNumber()+
+ ", server: "+ GLXUtil.getGLXServerVersionNumber(x11Device));
}
- {
- final String ret = GLX.glXQueryExtensionsString(ns.getDisplayHandle(), ns.getScreenIndex());
- if (DEBUG) {
- System.err.println("GLX extensions (glXQueryExtensionsString): " + ret);
+ if(((X11GLXDrawableFactory)drawable.getFactoryImpl()).isGLXVersionGreaterEqualOneOne(x11Device)) {
+ {
+ final String ret = GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_EXTENSIONS);
+ if (DEBUG) {
+ System.err.println("GLX extensions (glXGetClientString): " + ret);
+ }
+ sb.append(ret).append(" ");
}
- sb.append(ret).append(" ");
- }
- {
- final String ret = GLX.glXQueryServerString(ns.getDisplayHandle(), ns.getScreenIndex(), GLX.GLX_EXTENSIONS);
- if (DEBUG) {
- System.err.println("GLX extensions (glXQueryServerString): " + ret);
+ {
+ final String ret = GLX.glXQueryExtensionsString(x11Device.getHandle(), ns.getScreenIndex());
+ if (DEBUG) {
+ System.err.println("GLX extensions (glXQueryExtensionsString): " + ret);
+ }
+ sb.append(ret).append(" ");
+ }
+ {
+ final String ret = GLX.glXQueryServerString(x11Device.getHandle(), ns.getScreenIndex(), GLX.GLX_EXTENSIONS);
+ if (DEBUG) {
+ System.err.println("GLX extensions (glXQueryServerString): " + ret);
+ }
+ sb.append(ret).append(" ");
}
- sb.append(ret).append(" ");
}
+ } finally {
+ x11Device.unlock();
}
return sb;
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index 03c661565..b867125ad 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -239,7 +239,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
GLXUtil.initGLXClientDataSingleton(sharedDevice);
final String glXServerVendorName = GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_VENDOR);
- final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber(sharedDevice.getHandle());
+ final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber(sharedDevice);
final boolean glXServerMultisampleAvailable = GLXUtil.isMultisampleAvailable(GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_EXTENSIONS));
if(X11Util.ATI_HAS_XCLOSEDISPLAY_BUG && GLXUtil.isVendorATI(glXServerVendorName)) {
X11Util.setMarkAllDisplaysUnclosable(true);
@@ -452,7 +452,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return sr.getGLXVersion();
}
if( device instanceof X11GraphicsDevice ) {
- return GLXUtil.getGLXServerVersionNumber(device.getHandle());
+ return GLXUtil.getGLXServerVersionNumber((X11GraphicsDevice)device);
}
}
return null;
@@ -465,7 +465,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return sr.isGLXVersionGreaterEqualOneOne();
}
if( device instanceof X11GraphicsDevice ) {
- final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber(device.getHandle());
+ final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber((X11GraphicsDevice)device);
return glXServerVersion.compareTo(versionOneOne) >= 0;
}
}
@@ -479,7 +479,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return sr.isGLXVersionGreaterEqualOneThree();
}
if( device instanceof X11GraphicsDevice ) {
- final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber(device.getHandle());
+ final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber((X11GraphicsDevice)device);
return glXServerVersion.compareTo(versionOneThree) >= 0;
}
}