[Mesa-dev] [PATCH] st/xlib: add HUD support for xlib/GLX

Jose Fonseca jfonseca at vmware.com
Thu Apr 4 14:08:43 PDT 2013


----- Original Message -----
> For the softpipe and llvmpipe drivers.
> ---
>  src/gallium/state_trackers/glx/xlib/xm_api.c |   15 +++++++++++++++
>  src/gallium/state_trackers/glx/xlib/xm_api.h |    3 +++
>  src/gallium/state_trackers/glx/xlib/xm_st.c  |   12 ++++++++++++
>  src/gallium/state_trackers/glx/xlib/xm_st.h  |    4 ++++
>  4 files changed, 34 insertions(+), 0 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c
> b/src/gallium/state_trackers/glx/xlib/xm_api.c
> index 021175c..04960f3 100644
> --- a/src/gallium/state_trackers/glx/xlib/xm_api.c
> +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
> @@ -64,6 +64,8 @@
>  #include "util/u_atomic.h"
>  #include "util/u_inlines.h"
>  
> +#include "hud/hud_context.h"
> +
>  #include "xm_public.h"
>  #include <GL/glx.h>
>  
> @@ -910,6 +912,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v,
> XMesaContext share_list,
>  
>     c->st->st_manager_private = (void *) c;
>  
> +   c->hud = hud_create(c->st->pipe, c->st->cso_context);
> +
>     return c;
>  
>  fail:
> @@ -925,6 +929,10 @@ fail:
>  PUBLIC
>  void XMesaDestroyContext( XMesaContext c )
>  {
> +   if (c->hud) {
> +      hud_destroy(c->hud);
> +   }
> +
>     c->st->destroy(c->st);
>  
>     /* FIXME: We should destroy the screen here, but if we do so, surfaces
>     may
> @@ -1224,6 +1232,13 @@ void XMesaSwapBuffers( XMesaBuffer b )
>  {
>     XMesaContext xmctx = XMesaGetCurrentContext();
>  
> +   /* Need to draw HUD before flushing */
> +   if (xmctx && xmctx->hud) {
> +      struct pipe_resource *back =
> +         xmesa_get_framebuffer_resource(b->stfb, ST_ATTACHMENT_BACK_LEFT);
> +      hud_draw(xmctx->hud, back);
> +   }
> +
>     if (xmctx && xmctx->xm_buffer == b) {
>        xmctx->st->flush( xmctx->st, ST_FLUSH_FRONT, NULL);
>     }
> diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h
> b/src/gallium/state_trackers/glx/xlib/xm_api.h
> index 606bcf3..6d37ed7 100644
> --- a/src/gallium/state_trackers/glx/xlib/xm_api.h
> +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h
> @@ -67,6 +67,8 @@ and create a window, you must do the following to use the
> X/Mesa interface:
>  # include <X11/Xlibint.h>
>  # include <X11/Xutil.h>
>  
> +struct hud_context;
> +
>  typedef struct xmesa_display *XMesaDisplay;
>  typedef struct xmesa_buffer *XMesaBuffer;
>  typedef struct xmesa_context *XMesaContext;
> @@ -305,6 +307,7 @@ struct xmesa_context {
>     XMesaVisual xm_visual;	/** pixel format info */
>     XMesaBuffer xm_buffer;	/** current drawbuffer */
>     XMesaBuffer xm_read_buffer;  /** current readbuffer */
> +   struct hud_context *hud;
>  };
>  
>  
> diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c
> b/src/gallium/state_trackers/glx/xlib/xm_st.c
> index a681e82..1cfd89e 100644
> --- a/src/gallium/state_trackers/glx/xlib/xm_st.c
> +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c
> @@ -317,6 +317,18 @@ xmesa_destroy_st_framebuffer(struct st_framebuffer_iface
> *stfbi)
>     free(stfbi);
>  }
>  
> +/**
> + * Return the pipe_surface which corresponds to the given
> + * framebuffer attachment.
> + */
> +struct pipe_resource *
> +xmesa_get_framebuffer_resource(struct st_framebuffer_iface *stfbi,
> +                               enum st_attachment_type att)
> +{
> +   struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
> +   return xstfb->textures[att];
> +}
> +
>  void
>  xmesa_swap_st_framebuffer(struct st_framebuffer_iface *stfbi)
>  {
> diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.h
> b/src/gallium/state_trackers/glx/xlib/xm_st.h
> index a293728..c939c1e 100644
> --- a/src/gallium/state_trackers/glx/xlib/xm_st.h
> +++ b/src/gallium/state_trackers/glx/xlib/xm_st.h
> @@ -40,6 +40,10 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy,
> XMesaBuffer b);
>  void
>  xmesa_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi);
>  
> +struct pipe_resource *
> +xmesa_get_framebuffer_resource(struct st_framebuffer_iface *stfbi,
> +                               enum st_attachment_type att);
> +
>  void
>  xmesa_swap_st_framebuffer(struct st_framebuffer_iface *stfbi);
>  
> --
> 1.7.3.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 

Looks good to me.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>


More information about the mesa-dev mailing list