Skip to content

Commit

Permalink
dispatch: Try harder to avoid calling the resolver
Browse files Browse the repository at this point in the history
Our caller may load (eg) epoxy_glAlphaFunc, which is a function pointer,
and then call through that value multiple times. Until the caller
re-examines the value of that function pointer, which is a copy
relocation in the executable, repeated calls mean repeated work
resolving the GL function.

We can't make the caller reinspect the variable, but the resolver
function can avoid doing redundant work.

Fixes: #171
Signed-off-by: Adam Jackson <ajax@redhat.com>
  • Loading branch information
nwnk committed May 17, 2018
1 parent c00c889 commit 707f50e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/dispatch_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,20 @@
#define WRAPPER(x) x ## _wrapped

#define GEN_GLOBAL_REWRITE_PTR(name, args, passthrough) \
static void EPOXY_CALLSPEC \
static void EPOXY_CALLSPEC \
name##_global_rewrite_ptr args \
{ \
name = (void *)name##_resolver(); \
if (name == (void *)name##_global_rewrite_ptr) \
name = (void *)name##_resolver(); \
name passthrough; \
}

#define GEN_GLOBAL_REWRITE_PTR_RET(ret, name, args, passthrough) \
static ret EPOXY_CALLSPEC \
name##_global_rewrite_ptr args \
{ \
name = (void *)name##_resolver(); \
if (name == (void *)name##_global_rewrite_ptr) \
name = (void *)name##_resolver(); \
return name passthrough; \
}

Expand Down

0 comments on commit 707f50e

Please sign in to comment.