[Mesa-dev] [PATCH 2/4 resend] glx: Allow a context-specific fallback for glXGetProcAddress

Jeremy Huddleston jeremyhu at gmail.com
Fri Jun 17 12:31:54 PDT 2011


In applegl, GLX advertises the same extensions provided by OpenGL.framework
even if such extensions are not provided by glapi.  This allows a client
to get access to such API.

Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
---
 src/glx/applegl_glx.c  |    9 +++++++++
 src/glx/dri2_glx.c     |    1 +
 src/glx/dri_glx.c      |    1 +
 src/glx/drisw_glx.c    |    1 +
 src/glx/glxclient.h    |    2 +-
 src/glx/glxcmds.c      |    6 ++++++
 src/glx/indirect_glx.c |    1 +
 7 files changed, 20 insertions(+), 1 deletions(-)

diff --git origin/master/src/glx/applegl_glx.c origin/master/src/glx/applegl_glx.c
index 4bf4672..8766c88 100644
--- origin/master/src/glx/applegl_glx.c
+++ origin/master/src/glx/applegl_glx.c
@@ -34,10 +34,12 @@
 #if defined(GLX_USE_APPLEGL)
 
 #include <stdbool.h>
+#include <dlfcn.h>
 
 #include "glxclient.h"
 #include "apple_glx_context.h"
 #include "apple_glx.h"
+#include "apple_cgl.h"
 #include "glx_error.h"
 
 static void
@@ -82,6 +84,12 @@ applegl_wait_x(struct glx_context *gc)
    apple_glx_waitx(dpy, gc->driContext);
 }
 
+static void *
+applegl_get_proc_address(const char *symbol)
+{
+   return dlsym(apple_cgl_get_dl_handle(), symbol);
+}
+
 static const struct glx_context_vtable applegl_context_vtable = {
    applegl_destroy_context,
    applegl_bind_context,
@@ -91,6 +99,7 @@ static const struct glx_context_vtable applegl_context_vtable = {
    DRI_glXUseXFont,
    NULL, /* bind_tex_image, */
    NULL, /* release_tex_image, */
+   applegl_get_proc_address,
 };
 
 struct glx_context *
diff --git origin/master/src/glx/dri2_glx.c origin/master/src/glx/dri2_glx.c
index e7c18ff..80e4da3 100644
--- origin/master/src/glx/dri2_glx.c
+++ origin/master/src/glx/dri2_glx.c
@@ -767,6 +767,7 @@ static const struct glx_context_vtable dri2_context_vtable = {
    DRI_glXUseXFont,
    dri2_bind_tex_image,
    dri2_release_tex_image,
+   NULL, /* get_proc_address */
 };
 
 static void
diff --git origin/master/src/glx/dri_glx.c origin/master/src/glx/dri_glx.c
index d59784c..6f3b2b8 100644
--- origin/master/src/glx/dri_glx.c
+++ origin/master/src/glx/dri_glx.c
@@ -558,6 +558,7 @@ static const struct glx_context_vtable dri_context_vtable = {
    DRI_glXUseXFont,
    NULL,
    NULL,
+   NULL, /* get_proc_address */
 };
 
 static struct glx_context *
diff --git origin/master/src/glx/drisw_glx.c origin/master/src/glx/drisw_glx.c
index 0075695..07d4955 100644
--- origin/master/src/glx/drisw_glx.c
+++ origin/master/src/glx/drisw_glx.c
@@ -296,6 +296,7 @@ static const struct glx_context_vtable drisw_context_vtable = {
    DRI_glXUseXFont,
    NULL,
    NULL,
+   NULL, /* get_proc_address */
 };
 
 static struct glx_context *
diff --git origin/master/src/glx/glxclient.h origin/master/src/glx/glxclient.h
index 88a6edd..0641528 100644
--- origin/master/src/glx/glxclient.h
+++ origin/master/src/glx/glxclient.h
@@ -224,7 +224,7 @@ struct glx_context_vtable {
 			  GLXDrawable drawable,
 			  int buffer, const int *attrib_list);
    void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer);
-   
+   void * (*get_proc_address)(const char *symbol);
 };
 
 extern void
diff --git origin/master/src/glx/glxcmds.c origin/master/src/glx/glxcmds.c
index cd8bc97..e6816ea 100644
--- origin/master/src/glx/glxcmds.c
+++ origin/master/src/glx/glxcmds.c
@@ -2521,6 +2521,12 @@ _X_EXPORT void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
 #endif
       if (!f)
          f = (gl_function) _glapi_get_proc_address((const char *) procName);
+      if (!f) {
+         struct glx_context *gc = __glXGetCurrentContext();
+      
+         if (gc != NULL && gc->vtable->get_proc_address != NULL)
+            f = gc->vtable->get_proc_address((const char *) procName);
+      }
    }
    return f;
 }
diff --git origin/master/src/glx/indirect_glx.c origin/master/src/glx/indirect_glx.c
index b4f16c7..7b542dd 100644
--- origin/master/src/glx/indirect_glx.c
+++ origin/master/src/glx/indirect_glx.c
@@ -335,6 +335,7 @@ static const struct glx_context_vtable indirect_context_vtable = {
    indirect_use_x_font,
    indirect_bind_tex_image,
    indirect_release_tex_image,
+   NULL, /* get_proc_address */
 };
 
 /**
-- 
1.7.5.4




More information about the mesa-dev mailing list