From: Brian Paul Date: Wed, 3 Apr 2013 19:46:40 +0000 (-0600) Subject: st/wgl: add HUD support X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e95514c0eaeb44b9664ff00d0d7b10144cf3f219;p=mesa.git st/wgl: add HUD support v2: fix a few minor issues spotted by Jose. Reviewed-by: José Fonseca --- diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index 5e5b41f77c0..f3773edd6ab 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -38,6 +38,7 @@ #include "util/u_memory.h" #include "util/u_atomic.h" #include "state_tracker/st_api.h" +#include "hud/hud_context.h" #include "stw_icd.h" #include "stw_device.h" @@ -217,6 +218,10 @@ stw_create_context_attribs( ctx->st->st_manager_private = (void *) ctx; + if (ctx->st->cso_context) { + ctx->hud = hud_create(ctx->st->pipe, ctx->st->cso_context); + } + pipe_mutex_lock( stw_dev->ctx_mutex ); ctx->dhglrc = handle_table_add(stw_dev->ctx_table, ctx); pipe_mutex_unlock( stw_dev->ctx_mutex ); @@ -226,6 +231,9 @@ stw_create_context_attribs( return ctx->dhglrc; no_hglrc: + if (ctx->hud) { + hud_destroy(ctx->hud); + } ctx->st->destroy(ctx->st); no_st_ctx: FREE(ctx); @@ -255,6 +263,10 @@ DrvDeleteContext( if (curctx == ctx) stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL); + if (ctx->hud) { + hud_destroy(ctx->hud); + } + ctx->st->destroy(ctx->st); FREE(ctx); diff --git a/src/gallium/state_trackers/wgl/stw_context.h b/src/gallium/state_trackers/wgl/stw_context.h index 18f3c4a657e..72e112a661a 100644 --- a/src/gallium/state_trackers/wgl/stw_context.h +++ b/src/gallium/state_trackers/wgl/stw_context.h @@ -30,6 +30,7 @@ #include +struct hud_context; struct stw_framebuffer; struct st_context_iface; @@ -41,6 +42,8 @@ struct stw_context HDC hdc; struct stw_framebuffer *current_framebuffer; + + struct hud_context *hud; }; DHGLRC stw_create_context_attribs( HDC hdc, INT iLayerPlane, DHGLRC hShareContext, diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c index 449c5373b06..c22e0f153f0 100644 --- a/src/gallium/state_trackers/wgl/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c @@ -31,6 +31,7 @@ #include "pipe/p_screen.h" #include "util/u_format.h" #include "util/u_memory.h" +#include "hud/hud_context.h" #include "state_tracker/st_api.h" #include "stw_icd.h" @@ -593,6 +594,7 @@ BOOL APIENTRY DrvSwapBuffers( HDC hdc ) { + struct stw_context *ctx; struct stw_framebuffer *fb; if (!stw_dev) @@ -607,6 +609,14 @@ DrvSwapBuffers( return TRUE; } + /* Display the HUD */ + ctx = stw_current_context(); + if (ctx && ctx->hud) { + struct pipe_resource *back = + stw_get_framebuffer_resource(fb->stfb, ST_ATTACHMENT_BACK_LEFT); + hud_draw(ctx->hud, back); + } + stw_flush_current_locked(fb); return stw_st_swap_framebuffer_locked(hdc, fb->stfb); diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/wgl/stw_st.c index dcf958769e8..3acf26658e9 100644 --- a/src/gallium/state_trackers/wgl/stw_st.c +++ b/src/gallium/state_trackers/wgl/stw_st.c @@ -263,6 +263,19 @@ stw_st_swap_framebuffer_locked(HDC hdc, struct st_framebuffer_iface *stfb) return stw_st_framebuffer_present_locked(hdc, &stwfb->base, front); } + +/** + * Return the pipe_resource that correspond to given buffer. + */ +struct pipe_resource * +stw_get_framebuffer_resource(struct st_framebuffer_iface *stfb, + enum st_attachment_type att) +{ + struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb); + return stwfb->textures[att]; +} + + /** * Create an st_api of the state tracker. */ diff --git a/src/gallium/state_trackers/wgl/stw_st.h b/src/gallium/state_trackers/wgl/stw_st.h index 945d3508b48..c2473c724c4 100644 --- a/src/gallium/state_trackers/wgl/stw_st.h +++ b/src/gallium/state_trackers/wgl/stw_st.h @@ -46,4 +46,8 @@ stw_st_destroy_framebuffer_locked(struct st_framebuffer_iface *stfb); boolean stw_st_swap_framebuffer_locked(HDC hdc, struct st_framebuffer_iface *stfb); +struct pipe_resource * +stw_get_framebuffer_resource(struct st_framebuffer_iface *stfb, + enum st_attachment_type att); + #endif /* STW_ST_H */