diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-02-10 12:54:44 +0000 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-12-18 11:23:48 -0800 |
commit | 556adfa6b90f4c1ef12635cf78fa0bba046cf123 (patch) | |
tree | 7366316bc77b9cab96eb654aa709ade22d50d722 /glamor/glamor_utils.h | |
parent | 430bc16ca03b3ea00255a4045c8e9fd11aea95ad (diff) |
Fixup glx support
Renaming glamor_priv->dispatch and wrapping the access to
the dispatch table with a function that also ensured the
context was bound.
dispatch = glamor_get_dispatch(glamor_priv);
...
glamor_put_dispatch(glamor_priv);
So that we catch all places where we attempt to call into GL withouta
context. As an optimisation we can then do glamor_get_context();
glamor_put_context() around the rendering entry points to reduce the
frequency of having to restore the old context. (Along with allowing
the context to be recursively acquired and making the old context part of
the glamor_egl state.)
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'glamor/glamor_utils.h')
-rw-r--r-- | glamor/glamor_utils.h | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h index a66e24802..4a51ba59e 100644 --- a/glamor/glamor_utils.h +++ b/glamor/glamor_utils.h @@ -664,31 +664,44 @@ static inline void glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO); } -static inline void *glamor_make_current(ScreenPtr screen) +static inline void glamor_make_current(ScreenPtr screen) { - return glamor_egl_make_current(screen); + glamor_egl_make_current(screen); } -static inline void glamor_restore_current(ScreenPtr screen, void *previous_context) +static inline void glamor_restore_current(ScreenPtr screen) { - glamor_egl_restore_context(screen, previous_context); + glamor_egl_restore_context(screen); } #ifdef GLX_USE_SHARED_DISPATCH -#define GLAMOR_DEFINE_CONTEXT void *_previous_context_ = NULL -#define GLAMOR_SET_CONTEXT(glamor_priv) \ - if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN) \ - _previous_context_ = glamor_make_current(glamor_priv->screen) - -#define GLAMOR_RESTORE_CONTEXT(glamor_priv) \ - if ((glamor_priv->flags & GLAMOR_USE_EGL_SCREEN) \ - && _previous_context_ != NULL) \ - glamor_restore_current(glamor_priv->screen, _previous_context_) +static inline glamor_gl_dispatch * +glamor_get_dispatch(glamor_screen_private *glamor_priv) +{ + if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN) + glamor_make_current(glamor_priv->screen); + + return &glamor_priv->_dispatch; +} + +static inline void +glamor_put_dispatch(glamor_screen_private *glamor_priv) +{ + if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN) + glamor_restore_current(glamor_priv->screen); +} #else +#warning "Indirect GLX may be broken, need to implement context switch." +static inline glamor_gl_dispatch * +glamor_get_dispatch(glamor_screen_private *glamor_priv) +{ + return &glamor_priv->_dispatch; +} -#define GLAMOR_DEFINE_CONTEXT -#define GLAMOR_SET_CONTEXT(glamor_priv) -#define GLAMOR_RESTORE_CONTEXT(glamor_priv) +static inline void +glamor_put_dispatch(glamor_screen_private *glamor_priv) +{ +} #endif |