This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: X server 1.5.3-2 candidate


Yaakov (Cygwin Ports) wrote:
Of course, we only have the choice of the latter, but if swrast_dri.so
is missing, the GLX (and SGI-GLX) extension is disabled.  So I prepared
mesa-7.2-2 and tried building that module, but after fixing up the build
system, I found that it wasn't so simple.  The build only links the
module against libmesa.a (a convenience lib that becomes part of libGL),
leaving several undefined references:

_glapi_Context
_glapi_Dispatch
_glapi_add_dispatch
_glapi_check_multithread
_glapi_get_context
_glapi_get_dispatch_table_size
_glapi_noop_enable_warnings
_glapi_set_context
_glapi_set_dispatch
_glapi_set_warning_func

My understanding -- and I may be wrong -- is that these symbols are left
undefined on purpose, because they are meant to be resolved by whatever
loads the module.  That may be a DRI-enabled libGL, an X server, etc.
But that doesn't work for us because DLLs must have all references
resolved at link time.

So what to do?  All the X servers have GLX support, but if I were to
resolve these symbols against e.g. XWin, then the other servers will
crash trying to load it.  (Yes, I tried it.)  So while our libGL doesn't
actually use the module, the only neutral solution was to link against
all of libGL instead of just part of it, and at least on the surface it
appears to work.

After doing some tracing into the server, and looking at the difference between the successful and failing remote cases, it seems that we really do have a direct context in the success case, whereas in the failure case we have an indirect context.


I think that due to your trick of linking dri_swrast.so with libGL, we have some duplicate symbols, as libGL provides glapi_Dispatch itself, but it's also defined in the server GLX code.

I think maybe creating the indirect context (which occurs deep inside swrast) isn't setting the instance of this symbol which the GLX functions dispatch through when we have an indirect context, instead they are dispatching through glapi_noop_table, hence the crash.

I tried to work around this by removing the files with duplicate symbols (glpapi.c and glthread.c) from the GLX code and linking XWin with libGL as well, which seems to work as far as running glgears goes...

(I still need to check that these files are actually functionally identical between xserver/GLX and mesa/glapi)

Attached is a rough patch

Cygwin/X: GLX crash workaround

Remove GL dispatcher symbols which are defined in libGL, and link 
with libGL for them instead (as dri_swrast.so is linked with libGL)

Paper over the cracks. Avoid a crash when we have a broken context.

Turn on GLX null context debugging

---
 xserver/glx/Makefile.am      |    2 --
 xserver/glx/single2.c        |    3 +++
 xserver/hw/vfb/Makefile.am   |    7 ++++++-
 xserver/hw/xnest/Makefile.am |    7 ++++++-
 xserver/hw/xwin/InitOutput.c |   24 ++++++++++++++++++++++++
 xserver/hw/xwin/Makefile.am  |    8 +++++++-
 6 files changed, 46 insertions(+), 5 deletions(-)

Index: xorg-server-1.5.3/xserver/glx/single2.c
===================================================================
--- xorg-server-1.5.3.orig/xserver/glx/single2.c
+++ xorg-server-1.5.3/xserver/glx/single2.c
@@ -341,6 +341,9 @@ int DoGetString(__GLXclientState *cl, GL
     string = (const char *) CALL_GetString( GET_DISPATCH(), (name) );
     client = cl->client;
 
+    if (string == NULL)
+      string = "";
+
     /*
     ** Restrict extensions to those that are supported by both the
     ** implementation and the connection.  That is, return the
Index: xorg-server-1.5.3/xserver/hw/xwin/InitOutput.c
===================================================================
--- xorg-server-1.5.3.orig/xserver/hw/xwin/InitOutput.c
+++ xorg-server-1.5.3/xserver/hw/xwin/InitOutput.c
@@ -134,6 +134,9 @@ const char *
 winGetBaseDir(void);
 #endif
 
+static
+void glx_debugging(void);
+
 /*
  * For the depth 24 pixmap we default to 32 bits per pixel, but
  * we change this pixmap format later if we detect that the display
@@ -1045,6 +1048,8 @@ InitOutput (ScreenInfo *screenInfo, int 
        * Apply locale specified in LANG environment variable.
        */
       setlocale (LC_ALL, "");
+
+      glx_debugging();
     }
 #endif
 
@@ -1127,3 +1132,22 @@ winCheckDisplayNumber ()
 
   return TRUE;
 }
+
+/* GLX debugging helpers */
+#include <../glx/glapi.h>
+
+static
+void warn_func(void * p1, const char *format, ...) {
+  va_list v;
+  va_start(v, format);
+  vfprintf(stderr, format, v);
+  va_end(v);
+  fprintf(stderr,"\n");
+}
+
+static
+void glx_debugging(void)
+{
+  _glapi_set_warning_func(warn_func);
+  _glapi_noop_enable_warnings(TRUE);
+}
Index: xorg-server-1.5.3/xserver/glx/Makefile.am
===================================================================
--- xorg-server-1.5.3.orig/xserver/glx/Makefile.am
+++ xorg-server-1.5.3/xserver/glx/Makefile.am
@@ -38,10 +38,8 @@ glapi_sources =					\
 	dispatch.h				\
 	glapitable.h				\
 	glapitemp.h				\
-	glapi.c					\
 	glapi.h					\
 	glapioffsets.h				\
-	glthread.c				\
 	glthread.h				\
 	glprocs.h
 
Index: xorg-server-1.5.3/xserver/hw/xwin/Makefile.am
===================================================================
--- xorg-server-1.5.3.orig/xserver/hw/xwin/Makefile.am
+++ xorg-server-1.5.3/xserver/hw/xwin/Makefile.am
@@ -70,6 +70,12 @@ SRCS_XV = \
 DEFS_XV = -DXWIN_XV
 endif
 
+# me so borken
+if GLX
+XWIN_GL_LIBS = \
+	$(GL_LIBS)
+endif
+
 SRCS =	InitInput.c \
 	InitOutput.c \
 	winallpriv.c \
@@ -148,7 +154,7 @@ XWin_SOURCES = $(SRCS)
 INCLUDES = -I$(top_srcdir)/miext/rootless
 
 XWin_DEPENDENCIES = $(XWIN_LIBS)
-XWin_LDADD = $(XWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XWIN_SYS_LIBS)
+XWin_LDADD = $(XWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XWIN_SYS_LIBS) $(XWIN_GL_LIBS)
 XWin_LDFLAGS = -mwindows
 
 .rc.o:
Index: xorg-server-1.5.3/xserver/hw/vfb/Makefile.am
===================================================================
--- xorg-server-1.5.3.orig/xserver/hw/vfb/Makefile.am
+++ xorg-server-1.5.3/xserver/hw/vfb/Makefile.am
@@ -24,7 +24,12 @@ XVFB_LIBS = \
 	libfbcmap.a \
 	$(XSERVER_LIBS)
 
-Xvfb_LDADD = $(XVFB_LIBS) $(XVFB_SYS_LIBS) $(XSERVER_SYS_LIBS)
+if GLX
+XVFB_GL_LIBS = \
+	$(GL_LIBS)
+endif
+
+Xvfb_LDADD = $(XVFB_LIBS) $(XVFB_SYS_LIBS) $(XSERVER_SYS_LIBS) $(XVFB_GL_LIBS)
 Xvfb_DEPENDENCIES = $(XVFB_LIBS)
 Xvfb_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 
Index: xorg-server-1.5.3/xserver/hw/xnest/Makefile.am
===================================================================
--- xorg-server-1.5.3.orig/xserver/hw/xnest/Makefile.am
+++ xorg-server-1.5.3/xserver/hw/xnest/Makefile.am
@@ -52,10 +52,15 @@ XNEST_LIBS = \
         @XNEST_LIBS@ \
 	libfbcmap.a
 
+if GLX
+XNEST_GL_LIBS = \
+	$(GL_LIBS)
+endif
+
 Xnest_SOURCES = $(SRCS)
 
 Xnest_DEPENDENCIES = $(XNEST_LIBS)
-Xnest_LDADD = $(XNEST_LIBS) $(XNEST_SYS_LIBS) $(XSERVER_SYS_LIBS)
+Xnest_LDADD = $(XNEST_LIBS) $(XNEST_SYS_LIBS) $(XSERVER_SYS_LIBS) $(XNEST_GL_LIBS)
 Xnest_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 
 EXTRA_DIST = icon \

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]