Fix bug in public entrypoint for epoxy_glx_version()

Unfortunately, for GLX 1.4+ entrypoints (just glxGetProcAddress
currently) or extensions, if there isn't a context bound then we don't
have a dpy and screen available to provide useful debug messages.  Oh
well.
macos/v1.5.9
Eric Anholt 11 years ago
parent 14f822ee91
commit 0f67bf3f11
  1. 5
      include/epoxy/glx_common.h
  2. 26
      src/dispatch_common.c
  3. 1
      src/dispatch_common.h
  4. 2
      src/gen_dispatch.py
  5. 2
      test/Makefile.am
  6. 2
      test/glx_glxgetprocaddress_nocontext.c
  7. 2
      test/glx_public_api.c

@ -31,8 +31,11 @@
#include <stdbool.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
bool epoxy_has_glx_extension(const char *extension);
int epoxy_glx_version(void);
int epoxy_glx_version(Display *dpy, int screen);
#endif /* EPOXY_GLX_COMMON_H */

@ -138,21 +138,35 @@ epoxy_is_glx(void)
return true; /* XXX */
}
PUBLIC int
epoxy_glx_version(void)
/**
* If we can determine the GLX version from the current context, then
* return that, otherwise return a version that will just send us on
* to dlsym() or get_proc_address().
*/
int
epoxy_conservative_glx_version(void)
{
Display *dpy = glXGetCurrentDisplay();
GLXContext ctx = glXGetCurrentContext();
int screen;
if (!dpy || !ctx)
return 14;
glXQueryContext(dpy, ctx, GLX_SCREEN, &screen);
return epoxy_glx_version(dpy, screen);
}
PUBLIC int
epoxy_glx_version(Display *dpy, int screen)
{
int server_major, server_minor;
int client_major, client_minor;
int server, client;
const char *version_string;
int screen = 0;
int ret;
/* XXX: What if there's no current context? */
glXQueryContext(dpy, ctx, GLX_SCREEN, &screen);
version_string = glXQueryServerString(dpy, screen, GLX_VERSION);
ret = sscanf(version_string, "%d.%d", &server_major, &server_minor);
assert(ret == 2);

@ -49,6 +49,7 @@ struct api {
bool epoxy_is_glx(void);
void *epoxy_get_proc_address(const char *name);
int epoxy_conservative_glx_version(void);
void *epoxy_dlsym(const char *name);
void epoxy_glx_autoinit(void);
void epoxy_platform_autoinit(void);

@ -292,7 +292,7 @@ class Generator(object):
# We could just always use GPA, but dlsym() is a more
# efficient lookup.
if version > 13:
condition = condition + ' && epoxy_glx_version() >= {0}'.format(version)
condition = condition + ' && epoxy_conservative_glx_version() >= {0}'.format(version)
loader = self.gpa_loader
else:
loader = self.dlsym_loader

@ -37,8 +37,6 @@ TESTS = \
headerguards \
$()
XFAIL_TESTS = glx_glxgetprocaddress_nocontext
check_PROGRAMS = $(TESTS)
glx_public_api_LDFLAGS = $(X11_LIBS) $(EPOXY) libglx_common.la

@ -45,7 +45,7 @@ main(int argc, char **argv)
bool pass = true;
dpy = get_display_or_skip();
if (epoxy_glx_version() < 14)
if (epoxy_glx_version(dpy, 0) < 14)
errx(77, "GLX version 1.4 required for glXGetProcAddress().\n");
void *func = glXGetProcAddress("glGetString");

@ -48,7 +48,7 @@ test_gl_version(void)
static bool
test_glx_version(void)
{
int version = epoxy_glx_version();
int version = epoxy_glx_version(dpy, 0);
const char *version_string;
int ret;
int server_major, server_minor;

Loading…
Cancel
Save