From b128dd9b253b1586458ecb78276eb1b1a74ad4e3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 9 Dec 2013 22:14:09 -0800 Subject: [PATCH] Move the check for whether to dlsym or GPA on linux to the common C code. This is going to change for macos and win32, and this will be easier than trying to spread that logic through the python code and into the generated code. --- src/dispatch_common.c | 10 ++++++++++ src/dispatch_common.h | 1 + src/gen_dispatch.py | 10 ++-------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/dispatch_common.c b/src/dispatch_common.c index 32fb43e..cf2a398 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -338,6 +338,16 @@ epoxy_gles2_dlsym(const char *name) return do_dlsym(&api.gles1_handle, "libGLESv2.so.2", name, true); } +void * +epoxy_get_core_proc_address(const char *name, int core_version) +{ + if (core_version <= 12) { + return epoxy_gl_dlsym(name); + } else { + return epoxy_get_proc_address(name); + } +} + void * epoxy_get_proc_address(const char *name) { diff --git a/src/dispatch_common.h b/src/dispatch_common.h index a454ad3..78fc042 100644 --- a/src/dispatch_common.h +++ b/src/dispatch_common.h @@ -55,6 +55,7 @@ void *epoxy_gl_dlsym(const char *name); void *epoxy_gles1_dlsym(const char *name); void *epoxy_gles2_dlsym(const char *name); void *epoxy_get_proc_address(const char *name); +void *epoxy_get_core_proc_address(const char *name, int core_version); int epoxy_conservative_gl_version(void); bool epoxy_conservative_has_gl_extension(const char *name); diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py index 537ae80..0de4274 100755 --- a/src/gen_dispatch.py +++ b/src/gen_dispatch.py @@ -282,14 +282,8 @@ class Generator(object): human_name = 'Desktop OpenGL {0}'.format(feature.get('number')) condition = 'epoxy_is_desktop_gl()' - # Everything in GL 1.2 is guaranteed to be present as - # public symbols in the Linux libGL ABI. Everything - # else is supposed to not be present, so you have to - # glXGetProcAddress() it. - if version <= 12: - loader = 'epoxy_gl_dlsym({0})' - else: - loader = 'epoxy_get_proc_address({0})' + loader = 'epoxy_get_core_proc_address({0}, {1})'.format('{0}', version) + if version >= 11: condition += ' && epoxy_conservative_gl_version() >= {0}'.format(version) elif api == 'gles2': human_name = 'OpenGL ES {0}'.format(feature.get('number'))