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>
This commit is contained in:
Chris Wilson 2012-02-10 12:54:44 +00:00 • committed by Eric Anholt
commit 556adfa6b9
29 changed files with 224 additions and 335 deletions

View file

@ -26,36 +26,23 @@
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
static Bool
_glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
DDXPointPtr ppt, Bool fallback)
{
GLAMOR_DEFINE_CONTEXT;
glamor_screen_private *glamor_priv;
if (!fallback
&& glamor_ddx_fallback_check_gc(pGC)
&& glamor_ddx_fallback_check_pixmap(pDrawable))
goto fail;
return FALSE;
glamor_priv = glamor_get_screen_private(pDrawable->pScreen);
GLAMOR_SET_CONTEXT(glamor_priv);
glamor_prepare_access_gc(pGC);
glamor_prepare_access(pDrawable, GLAMOR_ACCESS_RW);
fbPolyPoint(pDrawable, pGC, mode, npt, ppt);
glamor_finish_access(pDrawable, GLAMOR_ACCESS_RW);
glamor_finish_access_gc(pGC);
GLAMOR_RESTORE_CONTEXT(glamor_priv);
return TRUE;
fail:
return FALSE;
}
void
@ -76,16 +63,11 @@ static Bool
_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
xSegment *pSeg, Bool fallback)
{
GLAMOR_DEFINE_CONTEXT;
glamor_screen_private *glamor_priv;
if (!fallback
&& glamor_ddx_fallback_check_gc(pGC)
&& glamor_ddx_fallback_check_pixmap(pDrawable))
goto fail;
return FALSE;
glamor_priv = glamor_get_screen_private(pDrawable->pScreen);
GLAMOR_SET_CONTEXT(glamor_priv);
/* For lineWidth is not zero, fb calls to mi functions. */
if (pGC->lineWidth == 0) {
glamor_prepare_access_gc(pGC);
@ -94,13 +76,9 @@ _glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
glamor_finish_access(pDrawable, GLAMOR_ACCESS_RW);
glamor_finish_access_gc(pGC);
} else
fbPolySegment(pDrawable, pGC, nseg, pSeg);
fbPolySegment(pDrawable, pGC, nseg, pSeg);
GLAMOR_RESTORE_CONTEXT(glamor_priv);
return TRUE;
fail:
return FALSE;
}
void
@ -121,17 +99,12 @@ static Bool
_glamor_poly_line(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
DDXPointPtr ppt, Bool fallback)
{
GLAMOR_DEFINE_CONTEXT;
glamor_screen_private *glamor_priv;
if (!fallback
&& glamor_ddx_fallback_check_gc(pGC)
&& glamor_ddx_fallback_check_pixmap(pDrawable))
goto fail;
return FALSE;
/* For lineWidth is not zero, fb calls to mi functions. */
glamor_priv = glamor_get_screen_private(pDrawable->pScreen);
GLAMOR_SET_CONTEXT(glamor_priv);
if (pGC->lineWidth == 0) {
glamor_prepare_access_gc(pGC);
glamor_prepare_access(pDrawable, GLAMOR_ACCESS_RW);
@ -139,13 +112,9 @@ _glamor_poly_line(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
glamor_finish_access(pDrawable, GLAMOR_ACCESS_RW);
glamor_finish_access_gc(pGC);
} else
fbPolyLine(pDrawable, pGC, mode, npt, ppt);
fbPolyLine(pDrawable, pGC, mode, npt, ppt);
GLAMOR_RESTORE_CONTEXT(glamor_priv);
return TRUE;
fail:
return FALSE;
}
void