st/wgl: add HUD support
v2: fix a few minor issues spotted by Jose. Reviewed-by: José Fonseca <jfonseca@vmware.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
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,
|
||||
|
@@ -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);
|
||||
|
@@ -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.
|
||||
*/
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user