summaryrefslogtreecommitdiffstats
path: root/make/config
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-13 21:24:44 +0200
committerSven Gothel <[email protected]>2010-04-13 21:24:44 +0200
commit2df3bea10859ee2f2c4b3622f3b610b17a5749d6 (patch)
tree9bb948241aef06fdaf1dd4d09f1b31989c76f858 /make/config
parent1c1053c6a8b669c067ae1316b9770871e213ea05 (diff)
ATI (fglrx) PBuffer/X11Display bug workaround/cleanup
- See https://bugzilla.mozilla.org/show_bug.cgi?id=486277 - Description: - To use PBuffer, a context must be current - X11Display cannot be switched while using the PBuffer [within one thread]. Hence we shall try harder to reuse _the_ user configured X11Display - whenever possible. This is actually a good thing, ie cleanup up our code again. - Changes to workaround/cleanup: - GLDrawableFactory* methods 'canCreate*()' are changed to 'canCreate*(AbstractGraphicsDevice)' to allow pipelining the X11Display. This reduces the overhead of using a local TLS X11Display. - WindowsDummyWGLDrawable cstr gets the GLProfile as a parameter now, this is done while adding X11DummyGLXDrawable - forseeing the usecase to query available GLProfiles at startup. - X11DummyGLXDrawable added, following the WindowsDummyWGLDrawable path to have a dummy GLContext current to fix the ATI bug. NativeWindow X11: - Add XIOErrorHandler to identify the fatal failure of closing a Display (-> ATI bug). Build: - Adding ant.jar and ant-junit.jar to the junit compile/run classpath - Misc: - Fix: CreateDummyWindow(..) returns a HWND, not a HDC - mapToRealGLFunctionName: Added mapping for X11/GLX. - X11GLXGraphicsConfigurationFactory: Uncommented dead code 'createDefaultGraphicsConfigurationFBConfig' Tests: Passed (Linux64bit: NVidia/ATI) Todo: More tests on ATI, especially multithreading/X11Display usage.
Diffstat (limited to 'make/config')
-rwxr-xr-xmake/config/nativewindow/x11-CustomCCode.c61
-rw-r--r--make/config/nativewindow/x11-CustomJavaCode.java5
-rw-r--r--make/config/nativewindow/x11-lib.cfg5
3 files changed, 69 insertions, 2 deletions
diff --git a/make/config/nativewindow/x11-CustomCCode.c b/make/config/nativewindow/x11-CustomCCode.c
index 8eded9aa2..982a39f7e 100755
--- a/make/config/nativewindow/x11-CustomCCode.c
+++ b/make/config/nativewindow/x11-CustomCCode.c
@@ -167,3 +167,64 @@ Java_com_jogamp_nativewindow_impl_x11_X11Lib_XGetVisualInfoCopied1__JJLjava_nio_
return jbyteCopy;
}
+
+static XIOErrorHandler origIOErrorHandler = NULL;
+
+static int displayIOErrorHandler(Display *dpy)
+{
+ fprintf(stderr, "Fatal: Nativewindow X11 IOError: Display %p not available\n", dpy);
+ origIOErrorHandler(dpy);
+ return 0;
+}
+
+static void displayIOErrorHandlerEnable(int onoff) {
+ if(onoff) {
+ if(NULL==origIOErrorHandler) {
+ origIOErrorHandler = XSetIOErrorHandler(displayIOErrorHandler);
+ }
+ } else {
+ XSetIOErrorHandler(origIOErrorHandler);
+ origIOErrorHandler = NULL;
+ }
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.nativewindow.impl.x11.X11Lib
+ * Java method: int XCloseDisplay(long display)
+ * C function: int XCloseDisplay(Display * display);
+ */
+JNIEXPORT jint JNICALL
+Java_com_jogamp_nativewindow_impl_x11_X11Lib_XCloseDisplay__J(JNIEnv *env, jclass _unused, jlong display) {
+ int _res;
+ // fprintf(stderr, "X11Lib.XCloseDisplay: %p\n", (Display *) (intptr_t) display);
+ displayIOErrorHandlerEnable(1);
+ _res = XCloseDisplay((Display *) (intptr_t) display);
+ displayIOErrorHandlerEnable(0);
+ return _res;
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.nativewindow.impl.x11.X11Lib
+ * Java method: long XOpenDisplay(java.lang.String arg0)
+ * C function: Display * XOpenDisplay(const char * );
+ */
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_nativewindow_impl_x11_X11Lib_XOpenDisplay__Ljava_lang_String_2(JNIEnv *env, jclass _unused, jstring arg0) {
+ const char* _strchars_arg0 = NULL;
+ Display * _res;
+ if ( NULL != arg0 ) {
+ _strchars_arg0 = (*env)->GetStringUTFChars(env, arg0, (jboolean*)NULL);
+ if ( NULL == _strchars_arg0 ) {
+ (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"),
+ "Failed to get UTF-8 chars for argument \"arg0\" in native dispatcher for \"XOpenDisplay\"");
+ return 0;
+ }
+ }
+ _res = XOpenDisplay((char *) _strchars_arg0);
+ // fprintf(stderr, "X11Lib.XOpenDisplay: %s -> %p\n", _strchars_arg0, _res);
+ if ( NULL != arg0 ) {
+ (*env)->ReleaseStringUTFChars(env, arg0, _strchars_arg0);
+ }
+ return (jlong) (intptr_t) _res;
+}
+
diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java
index 5c269c6c8..d631c92cb 100644
--- a/make/config/nativewindow/x11-CustomJavaCode.java
+++ b/make/config/nativewindow/x11-CustomJavaCode.java
@@ -24,3 +24,8 @@
/** Entry point to C language function: <code> XVisualInfo * XGetVisualInfo(Display * , long, XVisualInfo * , int * ); </code> */
private static native java.nio.ByteBuffer XGetVisualInfoCopied1(long arg0, long arg1, java.nio.ByteBuffer arg2, Object arg3, int arg3_byte_offset);
+ public static native long XOpenDisplay(String arg0);
+ public static native int XCloseDisplay(long display);
+ public static native long dlopen(String name);
+ public static native long dlsym(String name);
+
diff --git a/make/config/nativewindow/x11-lib.cfg b/make/config/nativewindow/x11-lib.cfg
index 7a64307da..394dd230a 100644
--- a/make/config/nativewindow/x11-lib.cfg
+++ b/make/config/nativewindow/x11-lib.cfg
@@ -20,8 +20,9 @@ Opaque long Display *
Opaque boolean Bool
Opaque long GLXFBConfig
-CustomJavaCode X11Lib public static native long dlopen(String name);
-CustomJavaCode X11Lib public static native long dlsym(String name);
+# Manually implement XOpenDisplay, XCloseDisplay, catching XIOError
+ManuallyImplement XCloseDisplay
+ManuallyImplement XOpenDisplay
IncludeAs CustomJavaCode X11Lib x11-CustomJavaCode.java
IncludeAs CustomCCode x11-CustomCCode.c