st/xlib: add HUD support for xlib/GLX
authorBrian Paul <brianp@vmware.com>
Thu, 4 Apr 2013 20:06:51 +0000 (14:06 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 4 Apr 2013 23:00:42 +0000 (17:00 -0600)
For the softpipe and llvmpipe drivers.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/state_trackers/glx/xlib/xm_api.c
src/gallium/state_trackers/glx/xlib/xm_api.h
src/gallium/state_trackers/glx/xlib/xm_st.c
src/gallium/state_trackers/glx/xlib/xm_st.h

index 021175c..04960f3 100644 (file)
@@ -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);
    }
index 606bcf3..6d37ed7 100644 (file)
@@ -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;
 };
 
 
index a681e82..1cfd89e 100644 (file)
@@ -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)
 {
index a293728..c939c1e 100644 (file)
@@ -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);