summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-09-29 04:41:47 +0200
committerSven Gothel <[email protected]>2012-09-29 04:41:47 +0200
commit43891be36e8485353ac74f329fd2f7438303a846 (patch)
treebd85f1bfdf2b31f21e03a5f052371aa25c540111 /src/nativewindow/classes/jogamp
parente0904a65bcf87ea0fd41d76cc1af7ad29daaefb5 (diff)
Cache XineramaIsEnabled(dpy) per display-name in X11Util minimize triggering ATI driver bug of sporadic XCB errors and to reduce server roundtrips.
Enhances commit: e4176f4e76f519b3599ad557210def3d35266e7b X11Util.XineramaIsEnabled(dpy) hash maps the Xinerama enable result to the dpy-name. Minimize triggering ATI driver bug of sporadic XCB errors: Our multithreading code somehow triggers an _XReply in XQueryExtension beside other functions, which fails the XCB assertion: ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed. This only appears w/ ATI driver and is probably due to a race condition in the driver (?). This change also reduces server roundtrips / querying time for the cost of 1 hash-map.
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
index 67508bf87..30792113d 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
@@ -34,6 +34,7 @@
package jogamp.nativewindow.x11;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import javax.media.nativewindow.AbstractGraphicsDevice;
@@ -139,6 +140,7 @@ public class X11Util {
private static List<NamedDisplay> openDisplayList = new ArrayList<NamedDisplay>(); // open, no close attempt
private static List<NamedDisplay> reusableDisplayList = new ArrayList<NamedDisplay>(); // close attempt, marked uncloseable, for reuse
private static List<NamedDisplay> pendingDisplayList = new ArrayList<NamedDisplay>(); // all open (close attempt or reusable) in creation order
+ private static final HashMap<String /* displayName */, Boolean> displayXineramaEnabledMap = new HashMap<String, Boolean>();
/**
* Cleanup resources.
@@ -178,6 +180,7 @@ public class X11Util {
reusableDisplayList.clear();
pendingDisplayList.clear();
openDisplayMap.clear();
+ displayXineramaEnabledMap.clear();
shutdown0();
}
}
@@ -503,10 +506,19 @@ public class X11Util {
device.unlock();
}
}
+
public static boolean XineramaIsEnabled(long displayHandle) {
if( 0 == displayHandle ) {
throw new IllegalArgumentException("X11 Display handle is NULL");
}
+ final String displayName = X11Lib.XDisplayString(displayHandle);
+ synchronized(displayXineramaEnabledMap) {
+ final Boolean b = displayXineramaEnabledMap.get(displayName);
+ if(null != b) {
+ return b.booleanValue();
+ }
+ }
+ final boolean res;
if(!XineramaFetched) { // volatile: ok
synchronized(X11Util.class) {
if( !XineramaFetched ) {
@@ -519,16 +531,21 @@ public class X11Util {
}
}
if(0!=XineramaQueryFunc) {
- final boolean res = X11Lib.XineramaIsEnabled(XineramaQueryFunc, displayHandle);
+ res = X11Lib.XineramaIsEnabled(XineramaQueryFunc, displayHandle);
+ } else {
if(DEBUG) {
- System.err.println("XineramaIsEnabled: 0x"+Long.toHexString(displayHandle)+": "+res);
+ System.err.println("XineramaIsEnabled: Couldn't bind to Xinerama - lib 0x"+Long.toHexString(XineramaLibHandle)+
+ "query 0x"+Long.toHexString(XineramaQueryFunc));
}
- return res;
- } else if(DEBUG) {
- System.err.println("XineramaIsEnabled: Couldn't bind to Xinerama - lib 0x"+Long.toHexString(XineramaLibHandle)+
- "query 0x"+Long.toHexString(XineramaQueryFunc));
+ res = false;
}
- return false;
+ synchronized(displayXineramaEnabledMap) {
+ if(DEBUG) {
+ System.err.println("XineramaIsEnabled Cache: Display "+displayName+" (0x"+Long.toHexString(displayHandle)+") -> "+res);
+ }
+ displayXineramaEnabledMap.put(displayName, Boolean.valueOf(res));
+ }
+ return res;
}
private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI