aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun/opengl/impl/x11/glx
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-06-18 06:50:13 +0000
committerSven Gothel <[email protected]>2009-06-18 06:50:13 +0000
commit3c6a7838b1a647b42cc8b37d1a433ed9a1431860 (patch)
tree2ed11714feef306f04e1c34beb71591f34563e21 /src/jogl/classes/com/sun/opengl/impl/x11/glx
parent5607c14460e9e8abd2833517016f1dd3ec9c685c (diff)
- Fix: X11 locking
The current thread default display or the given display is being used, hence it is no more required to use a ToolkitLock for X11 without AWT. Removed X11 ToolkitLock in case of X11 without AWT, which is being detected with the absence of the classes java.awt.Component _AND_ javax.media.nativewindow.awt.AWTGraphicsDevice or with the system property java.awt.headless=true Only in the Java2D/Swing case, one 'leaking' Display is created within canCreateGLPbuffer(). - Workaround for Hotsport bugs #4395095, #6852404 4395095 JNI access to java.nio DirectBuffer constructor/accessor 6852404 Race condition in JNI Direct Buffer access and creation routines - Added build.xml -Dbuild.noarchives=true property to skip the time consuming creation of zip archives. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1988 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/impl/x11/glx')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java61
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java15
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java50
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java6
5 files changed, 51 insertions, 87 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java
index b3d25b52c..8f21fef42 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java
@@ -39,63 +39,18 @@ import javax.media.nativewindow.NativeWindowFactory;
import com.sun.nativewindow.impl.x11.*;
public class GLXUtil {
- private static final boolean DEBUG = Debug.debug("GLXUtil");
-
- private GLXUtil() {}
-
- // ATI's proprietary drivers apparently send GLX tokens even for
- // direct contexts, so we need to disable the context optimizations
- // in this case
- private static boolean isVendorATI;
-
- // Display connection for use by visual selection algorithm and by all offscreen surfaces
- private static boolean multisampleAvailable=false;
-
- private static volatile boolean isInit=false;
-
- private static synchronized void init() {
- if (!isInit) {
- synchronized (GLXUtil.class) {
- if (!isInit) {
- long locDisplay = X11Util.getThreadLocalDefaultDisplay();
- if(locDisplay!=0) {
- if (DEBUG) {
- int screen = X11Lib.DefaultScreen(locDisplay);
- System.err.println("!!! GLX server vendor : " +
- GLX.glXQueryServerString(locDisplay, screen, GLX.GLX_VENDOR));
- System.err.println("!!! GLX server version: " +
- GLX.glXQueryServerString(locDisplay, screen, GLX.GLX_VERSION));
- System.err.println("!!! GLX client vendor : " +
- GLX.glXGetClientString(locDisplay, GLX.GLX_VENDOR));
- System.err.println("!!! GLX client version: " +
- GLX.glXGetClientString(locDisplay, GLX.GLX_VERSION));
- }
- String vendor = GLX.glXGetClientString(locDisplay, GLX.GLX_VENDOR);
- if (vendor != null && vendor.startsWith("ATI")) {
- isVendorATI = true;
- }
- String exts = GLX.glXGetClientString(locDisplay, GLX.GLX_EXTENSIONS);
- if (exts != null) {
- multisampleAvailable = (exts.indexOf("GLX_ARB_multisample") >= 0);
- }
- isInit=true;
- } else {
- throw new GLException("Unable to open default display, needed for visual selection and offscreen surface handling");
- }
- }
- }
+ public static boolean isMultisampleAvailable(long display) {
+ String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
+ if (exts != null) {
+ return (exts.indexOf("GLX_ARB_multisample") >= 0);
}
- }
-
- public static boolean isMultisampleAvailable() {
- init();
- return multisampleAvailable;
+ return false;
}
/** Workaround for apparent issue with ATI's proprietary drivers
where direct contexts still send GLX tokens for GL calls */
- public static boolean isVendorATI() {
- init();
- return isVendorATI;
+ public static boolean isVendorATI(long display) {
+ String vendor = GLX.glXGetClientString(display, GLX.GLX_VENDOR);
+ return vendor != null && vendor.startsWith("ATI") ;
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
index 921d305a8..7029b81b0 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
@@ -134,6 +134,7 @@ public abstract class X11GLXContext extends GLContextImpl {
}
GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
long display = config.getScreen().getDevice().getHandle();
+ isVendorATI = GLXUtil.isVendorATI(display);
if(config.getFBConfigID()<0) {
// not able to use FBConfig
@@ -424,8 +425,7 @@ public abstract class X11GLXContext extends GLContextImpl {
}
public boolean isOptimizable() {
- return (super.isOptimizable() &&
- !GLXUtil.isVendorATI());
+ return (super.isOptimizable() && !isVendorATI);
}
//----------------------------------------------------------------------
@@ -436,4 +436,6 @@ public abstract class X11GLXContext extends GLContextImpl {
return context;
}
+ private boolean isVendorATI = false;
+
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
index 404881329..83f671cb4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -288,7 +288,10 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
// FBConfig
- public static GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, long display, long fbcfg) {
+ // sgothel: The synchronized was added, due to bugs within the GLX implementation on my platform
+ // in regards to multithreading (FIXME).
+
+ public synchronized static GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, long display, long fbcfg, boolean isMultisampleEnabled) {
int[] tmp = new int[1];
int val;
val = glXGetFBConfig(display, fbcfg, GLX.GLX_RENDER_TYPE, tmp, 0);
@@ -309,7 +312,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
res.setAccumGreenBits(glXGetFBConfig(display, fbcfg, GLX.GLX_ACCUM_GREEN_SIZE, tmp, 0));
res.setAccumBlueBits (glXGetFBConfig(display, fbcfg, GLX.GLX_ACCUM_BLUE_SIZE, tmp, 0));
res.setAccumAlphaBits(glXGetFBConfig(display, fbcfg, GLX.GLX_ACCUM_ALPHA_SIZE, tmp, 0));
- if (GLXUtil.isMultisampleAvailable()) {
+ if (isMultisampleEnabled) {
res.setSampleBuffers(glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLE_BUFFERS, tmp, 0) != 0);
res.setNumSamples (glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLES, tmp, 0));
}
@@ -333,7 +336,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
return res;
}
- private static String glXGetFBConfigErrorCode(int err) {
+ private synchronized static String glXGetFBConfigErrorCode(int err) {
switch (err) {
case GLX.GLX_NO_EXTENSION: return "GLX_NO_EXTENSION";
case GLX.GLX_BAD_ATTRIBUTE: return "GLX_BAD_ATTRIBUTE";
@@ -341,7 +344,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
}
}
- public static int glXGetFBConfig(long display, long cfg, int attrib, int[] tmp, int tmp_offset) {
+ public synchronized static int glXGetFBConfig(long display, long cfg, int attrib, int[] tmp, int tmp_offset) {
if (display == 0) {
throw new GLException("No display connection");
}
@@ -376,7 +379,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
return res;
}
- public static GLCapabilities XVisualInfo2GLCapabilities(GLProfile glp, long display, XVisualInfo info) {
+ public static GLCapabilities XVisualInfo2GLCapabilities(GLProfile glp, long display, XVisualInfo info, boolean isMultisampleEnabled) {
int[] tmp = new int[1];
int val = glXGetConfig(display, info, GLX.GLX_USE_GL, tmp, 0);
if (val == 0) {
@@ -404,7 +407,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
res.setAccumGreenBits(glXGetConfig(display, info, GLX.GLX_ACCUM_GREEN_SIZE, tmp, 0));
res.setAccumBlueBits (glXGetConfig(display, info, GLX.GLX_ACCUM_BLUE_SIZE, tmp, 0));
res.setAccumAlphaBits(glXGetConfig(display, info, GLX.GLX_ACCUM_ALPHA_SIZE, tmp, 0));
- if (GLXUtil.isMultisampleAvailable()) {
+ if (isMultisampleEnabled) {
res.setSampleBuffers(glXGetConfig(display, info, GLX.GLX_SAMPLE_BUFFERS, tmp, 0) != 0);
res.setNumSamples (glXGetConfig(display, info, GLX.GLX_SAMPLES, tmp, 0));
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 1e2f2f185..9acf580c4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -74,26 +74,27 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
long fbcfg = 0;
int fbid = -1;
- long display = x11Screen.getDevice().getHandle();
- int screen = x11Screen.getIndex();
-
// Utilizing FBConfig
//
GLCapabilities capsFB = null;
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
try {
+ long display = x11Screen.getDevice().getHandle();
+ int screen = x11Screen.getIndex();
+ boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+
long visID = X11Lib.DefaultVisualID(display, x11Screen.getIndex());
xvis = X11GLXGraphicsConfiguration.XVisualID2XVisualInfo(display, visID);
- caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, xvis);
+ caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, xvis, isMultisampleAvailable);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(caps, true, GLXUtil.isMultisampleAvailable(), usePBuffer, 0, 0);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(caps, true, isMultisampleAvailable, usePBuffer, 0, 0);
int[] count = { -1 };
java.nio.LongBuffer fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
if (fbcfgsL == null || fbcfgsL.limit()<1) {
throw new Exception("Could not fetch FBConfig for "+caps);
}
fbcfg = fbcfgsL.get(0);
- capsFB = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfg);
+ capsFB = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfg, isMultisampleAvailable);
int[] tmpID = new int[1];
fbid = X11GLXGraphicsConfiguration.glXGetFBConfig(display, fbcfg, GLX.GLX_FBCONFIG_ID, tmpID, 0);
@@ -102,10 +103,10 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
if (xvis==null) {
throw new GLException("Error: Choosen FBConfig has no visual");
}
- } catch (Throwable t) {
- } finally {
+ } catch (Throwable t) {
+ } finally {
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
- }
+ }
return new X11GLXGraphicsConfiguration(x11Screen, (null!=capsFB)?capsFB:caps, caps, null, xvis, fbcfg, fbid);
}
@@ -163,12 +164,6 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
GLCapabilitiesChooser chooser,
X11GraphicsScreen x11Screen,
boolean usePBuffer) {
- int screen = x11Screen.getIndex();
- AbstractGraphicsDevice absDevice = x11Screen.getDevice();
- long display = absDevice.getHandle();
-
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, GLXUtil.isMultisampleAvailable(), usePBuffer, 0, 0);
- int[] count = { -1 };
int recommendedIndex = -1;
GLCapabilities[] caps = null;
java.nio.LongBuffer fbcfgsL = null;
@@ -181,6 +176,13 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
//
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
try {
+ int screen = x11Screen.getIndex();
+ AbstractGraphicsDevice absDevice = x11Screen.getDevice();
+ long display = absDevice.getHandle();
+ boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, usePBuffer, 0, 0);
+ int[] count = { -1 };
+
fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
if (fbcfgsL == null || fbcfgsL.limit()<1) {
if(DEBUG) {
@@ -191,7 +193,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
recommendedIndex = 0; // 1st match is always recommended ..
caps = new GLCapabilities[fbcfgsL.limit()];
for (int i = 0; i < fbcfgsL.limit(); i++) {
- caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i));
+ caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i), isMultisampleAvailable);
}
if(null==chooser) {
@@ -228,22 +230,15 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationXVisual(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
X11GraphicsScreen x11Screen) {
-
if (chooser == null) {
chooser = new DefaultGLCapabilitiesChooser();
}
- int screen = x11Screen.getIndex();
- AbstractGraphicsDevice absDevice = x11Screen.getDevice();
- long display = absDevice.getHandle();
-
// Until we have a rock-solid visual selection algorithm written
// in pure Java, we're going to provide the underlying window
// system's selection to the chooser as a hint
GLProfile glProfile = capabilities.getGLProfile();
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, GLXUtil.isMultisampleAvailable(), false, 0, 0);
- XVisualInfo[] infos = null;
GLCapabilities[] caps = null;
int recommendedIndex = -1;
XVisualInfo retXVisualInfo = null;
@@ -251,6 +246,13 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
try {
+ int screen = x11Screen.getIndex();
+ AbstractGraphicsDevice absDevice = x11Screen.getDevice();
+ long display = absDevice.getHandle();
+ boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, false, 0, 0);
+ XVisualInfo[] infos = null;
+
XVisualInfo recommendedVis = GLX.glXChooseVisualCopied(display, screen, attribs, 0);
if (DEBUG) {
System.err.print("!!! glXChooseVisual recommended ");
@@ -269,7 +271,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
caps = new GLCapabilities[infos.length];
for (int i = 0; i < infos.length; i++) {
- caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i]);
+ caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], isMultisampleAvailable);
// Attempt to find the visual chosen by glXChooseVisual
if (recommendedVis != null && recommendedVis.visualid() == infos[i].visualid()) {
recommendedIndex = i;
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
index 78ff306aa..604bde46b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
@@ -94,8 +94,10 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
if(DEBUG) {
System.err.println("X11AWTGLXGraphicsConfigurationFactory: using a thread local X11 display");
}
- } else if(DEBUG) {
- System.err.println("X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle));
+ } else {
+ if(DEBUG) {
+ System.err.println("X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle));
+ }
}
((AWTGraphicsDevice)awtScreen.getDevice()).setHandle(displayHandle);
x11Device = new X11GraphicsDevice(displayHandle);