From a23488d63e6717f9fd9ac16c99d1ae8b7f8f6a1e Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sat, 10 Dec 2022 04:10:36 +0800 Subject: [PATCH] gallium/hud: typedef and use hud_st_invalidate_state_func to avoid cast Signed-off-by: Yonggang Luo Reviewed-by: Jesse Natalie Part-of: --- src/gallium/auxiliary/hud/hud_context.c | 7 ++++--- src/gallium/auxiliary/hud/hud_context.h | 7 ++++++- src/gallium/auxiliary/hud/hud_private.h | 5 +++-- src/gallium/frontends/dri/dri_context.c | 2 +- src/gallium/frontends/glx/xlib/xm_api.c | 2 +- src/gallium/frontends/wgl/stw_context.c | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 61f7b0dedcb..58a3edb6a51 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -1673,8 +1673,8 @@ hud_unset_draw_context(struct hud_context *hud) static bool hud_set_draw_context(struct hud_context *hud, struct cso_context *cso, - void *st, - void (*st_invalidate_state)(void *st, unsigned flags)) + struct st_context *st, + hud_st_invalidate_state_func st_invalidate_state) { struct pipe_context *pipe = cso_get_pipe_context(cso); @@ -1857,7 +1857,8 @@ hud_set_record_context(struct hud_context *hud, struct pipe_context *pipe) */ struct hud_context * hud_create(struct cso_context *cso, struct hud_context *share, - void *st, void (*st_invalidate_state)(void *st, unsigned flags)) + struct st_context *st, + hud_st_invalidate_state_func st_invalidate_state) { const char *share_env = debug_get_option("GALLIUM_HUD_SHARE", NULL); unsigned record_ctx = 0, draw_ctx = 0; diff --git a/src/gallium/auxiliary/hud/hud_context.h b/src/gallium/auxiliary/hud/hud_context.h index f02466acef1..ad495970d63 100644 --- a/src/gallium/auxiliary/hud/hud_context.h +++ b/src/gallium/auxiliary/hud/hud_context.h @@ -33,10 +33,15 @@ struct cso_context; struct pipe_context; struct pipe_resource; struct util_queue_monitoring; +struct st_context; + +typedef void (*hud_st_invalidate_state_func)(struct st_context *st, + unsigned flags); struct hud_context * hud_create(struct cso_context *cso, struct hud_context *share, - void *st, void (*st_invalidate_state)(void *st, unsigned flags)); + struct st_context *st, + hud_st_invalidate_state_func st_invalidate_state); void hud_destroy(struct hud_context *hud, struct cso_context *cso); diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index fb4850851de..0c3fbbba4db 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -32,6 +32,7 @@ #include "pipe/p_state.h" #include "util/list.h" #include "hud/font.h" +#include "hud/hud_context.h" #include "cso_cache/cso_context.h" enum hud_counter { @@ -53,8 +54,8 @@ struct hud_context { struct cso_context *cso; /* For notifying st_context to rebind states that we clobbered. */ - void *st; - void (*st_invalidate_state)(void *st, unsigned flags); + struct st_context *st; + hud_st_invalidate_state_func st_invalidate_state; struct hud_batch_query_context *batch_query; struct list_head pane_list; diff --git a/src/gallium/frontends/dri/dri_context.c b/src/gallium/frontends/dri/dri_context.c index 91052905ca2..de21c78e985 100644 --- a/src/gallium/frontends/dri/dri_context.c +++ b/src/gallium/frontends/dri/dri_context.c @@ -192,7 +192,7 @@ dri_create_context(struct dri_screen *screen, ctx->st, (void*)st_context_invalidate_state); ctx->hud = hud_create(ctx->st->cso_context, share_ctx ? share_ctx->hud : NULL, - ctx->st, (void*)st_context_invalidate_state); + ctx->st, st_context_invalidate_state); } /* Do this last. */ diff --git a/src/gallium/frontends/glx/xlib/xm_api.c b/src/gallium/frontends/glx/xlib/xm_api.c index aa6de624b36..458c56c1075 100644 --- a/src/gallium/frontends/glx/xlib/xm_api.c +++ b/src/gallium/frontends/glx/xlib/xm_api.c @@ -1014,7 +1014,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list, c->st->frontend_context = (void *) c; c->hud = hud_create(c->st->cso_context, NULL, c->st, - (void*)st_context_invalidate_state); + st_context_invalidate_state); return c; diff --git a/src/gallium/frontends/wgl/stw_context.c b/src/gallium/frontends/wgl/stw_context.c index f10986775be..6005eac8da7 100644 --- a/src/gallium/frontends/wgl/stw_context.c +++ b/src/gallium/frontends/wgl/stw_context.c @@ -253,7 +253,7 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context *shareCt if (ctx->st->cso_context) { ctx->hud = hud_create(ctx->st->cso_context, NULL, ctx->st, - (void*)st_context_invalidate_state); + st_context_invalidate_state); } return ctx;