From fdec3529030cacea8ba82aba0ed8db703813549e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 27 Nov 2022 13:08:53 -0500 Subject: [PATCH] gallium/hud: don't use st_context_iface, use an explicit callback st_context_iface will be removed. Reviewed-by: Emma Anholt Reviewed-by: Adam Jackson Reviewed-by: Yonggang Luo Part-of: --- src/gallium/auxiliary/hud/hud_context.c | 20 +++++++++++--------- src/gallium/auxiliary/hud/hud_context.h | 5 ++--- src/gallium/auxiliary/hud/hud_private.h | 5 ++++- src/gallium/frontends/dri/dri_context.c | 5 +++-- src/gallium/frontends/glx/xlib/xm_api.c | 3 ++- src/gallium/frontends/nine/device9.c | 2 +- src/gallium/frontends/wgl/stw_context.c | 3 ++- 7 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 49d6856..61f7b0d 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -640,10 +640,10 @@ done: /* restore states not restored by cso */ if (hud->st) { - hud->st->invalidate_state(hud->st, - ST_INVALIDATE_FS_SAMPLER_VIEWS | - ST_INVALIDATE_VS_CONSTBUF0 | - ST_INVALIDATE_VERTEX_BUFFERS); + hud->st_invalidate_state(hud->st, + ST_INVALIDATE_FS_SAMPLER_VIEWS | + ST_INVALIDATE_VS_CONSTBUF0 | + ST_INVALIDATE_VERTEX_BUFFERS); } pipe_surface_reference(&surf, NULL); @@ -1673,7 +1673,8 @@ hud_unset_draw_context(struct hud_context *hud) static bool hud_set_draw_context(struct hud_context *hud, struct cso_context *cso, - struct st_context_iface *st) + void *st, + void (*st_invalidate_state)(void *st, unsigned flags)) { struct pipe_context *pipe = cso_get_pipe_context(cso); @@ -1681,6 +1682,7 @@ hud_set_draw_context(struct hud_context *hud, struct cso_context *cso, hud->pipe = pipe; hud->cso = cso; hud->st = st; + hud->st_invalidate_state = st_invalidate_state; struct pipe_sampler_view view_templ; u_sampler_view_default_template( @@ -1854,8 +1856,8 @@ hud_set_record_context(struct hud_context *hud, struct pipe_context *pipe) * record queries in one context and draw them in another. */ struct hud_context * -hud_create(struct cso_context *cso, struct st_context_iface *st, - struct hud_context *share) +hud_create(struct cso_context *cso, struct hud_context *share, + void *st, void (*st_invalidate_state)(void *st, unsigned flags)) { const char *share_env = debug_get_option("GALLIUM_HUD_SHARE", NULL); unsigned record_ctx = 0, draw_ctx = 0; @@ -1879,7 +1881,7 @@ hud_create(struct cso_context *cso, struct st_context_iface *st, if (context_id == draw_ctx) { assert(!share->pipe); - hud_set_draw_context(share, cso, st); + hud_set_draw_context(share, cso, st, st_invalidate_state); } return share; @@ -2002,7 +2004,7 @@ hud_create(struct cso_context *cso, struct st_context_iface *st, if (record_ctx == 0) hud_set_record_context(hud, cso_get_pipe_context(cso)); if (draw_ctx == 0) - hud_set_draw_context(hud, cso, st); + hud_set_draw_context(hud, cso, st, st_invalidate_state); hud_parse_env_var(hud, screen, env); return hud; diff --git a/src/gallium/auxiliary/hud/hud_context.h b/src/gallium/auxiliary/hud/hud_context.h index ed5dd5d..f02466a 100644 --- a/src/gallium/auxiliary/hud/hud_context.h +++ b/src/gallium/auxiliary/hud/hud_context.h @@ -33,11 +33,10 @@ struct cso_context; struct pipe_context; struct pipe_resource; struct util_queue_monitoring; -struct st_context_iface; struct hud_context * -hud_create(struct cso_context *cso, struct st_context_iface *st, - struct hud_context *share); +hud_create(struct cso_context *cso, struct hud_context *share, + void *st, void (*st_invalidate_state)(void *st, unsigned flags)); 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 e0ebdf3..fb48508 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -51,7 +51,10 @@ struct hud_context { /* Context where the HUD is drawn: */ struct pipe_context *pipe; struct cso_context *cso; - struct st_context_iface *st; + + /* For notifying st_context to rebind states that we clobbered. */ + void *st; + void (*st_invalidate_state)(void *st, unsigned flags); 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 6b2b275..a42e8a7 100644 --- a/src/gallium/frontends/dri/dri_context.c +++ b/src/gallium/frontends/dri/dri_context.c @@ -202,8 +202,9 @@ dri_create_context(struct dri_screen *screen, if (ctx->st->cso_context) { ctx->pp = pp_init(ctx->st->pipe, screen->pp_enabled, ctx->st->cso_context, ctx->st); - ctx->hud = hud_create(ctx->st->cso_context, ctx->st, - share_ctx ? share_ctx->hud : NULL); + ctx->hud = hud_create(ctx->st->cso_context, + share_ctx ? share_ctx->hud : NULL, + ctx->st, (void*)ctx->st->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 cdafc89..48b4105 100644 --- a/src/gallium/frontends/glx/xlib/xm_api.c +++ b/src/gallium/frontends/glx/xlib/xm_api.c @@ -1011,7 +1011,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list, c->st->frontend_context = (void *) c; - c->hud = hud_create(c->st->cso_context, c->st, NULL); + c->hud = hud_create(c->st->cso_context, NULL, c->st, + (void*)c->st->invalidate_state); return c; diff --git a/src/gallium/frontends/nine/device9.c b/src/gallium/frontends/nine/device9.c index 306c607..693b914 100644 --- a/src/gallium/frontends/nine/device9.c +++ b/src/gallium/frontends/nine/device9.c @@ -269,7 +269,7 @@ NineDevice9_ctor( struct NineDevice9 *This, if (!This->cso_sw) { return E_OUTOFMEMORY; } /* Create first, it messes up our state. */ - This->hud = hud_create(This->context.cso, NULL, NULL); /* NULL result is fine */ + This->hud = hud_create(This->context.cso, NULL, NULL, NULL); /* NULL result is fine */ This->allocator = nine_allocator_create(This, pCTX->memfd_virtualsizelimit); diff --git a/src/gallium/frontends/wgl/stw_context.c b/src/gallium/frontends/wgl/stw_context.c index bfb06af..4d06c86 100644 --- a/src/gallium/frontends/wgl/stw_context.c +++ b/src/gallium/frontends/wgl/stw_context.c @@ -249,7 +249,8 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context *shareCt ctx->st->frontend_context = (void *) ctx; if (ctx->st->cso_context) { - ctx->hud = hud_create(ctx->st->cso_context, ctx->st, NULL); + ctx->hud = hud_create(ctx->st->cso_context, NULL, ctx->st, + (void*)ctx->st->invalidate_state); } return ctx; -- 2.7.4