gallium/pp: typedef and use pp_st_invalidate_state_func to avoid cast
authorYonggang Luo <luoyonggang@gmail.com>
Fri, 9 Dec 2022 20:11:32 +0000 (04:11 +0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 14 Dec 2022 05:47:52 +0000 (05:47 +0000)
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20042>

src/gallium/auxiliary/postprocess/postprocess.h
src/gallium/auxiliary/postprocess/pp_init.c
src/gallium/auxiliary/postprocess/pp_private.h
src/gallium/auxiliary/postprocess/pp_program.c
src/gallium/frontends/dri/dri_context.c
src/gallium/frontends/osmesa/osmesa.c
src/gallium/targets/haiku-softpipe/GalliumContext.cpp

index e6f3c82..c215b03 100644 (file)
@@ -35,6 +35,7 @@ extern "C" {
 #endif
 
 struct cso_context;
+struct st_context;
 
 struct pp_queue_t;              /* Forward definition */
 struct pp_program;
@@ -43,6 +44,9 @@ struct pp_program;
 typedef void (*pp_func) (struct pp_queue_t *, struct pipe_resource *,
                          struct pipe_resource *, unsigned int);
 
+typedef void (*pp_st_invalidate_state_func)(struct st_context *st,
+                                            unsigned flags);
+
 /* Main functions */
 
 /**
@@ -53,8 +57,8 @@ typedef void (*pp_func) (struct pp_queue_t *, struct pipe_resource *,
 struct pp_queue_t *pp_init(struct pipe_context *pipe,
                            const unsigned int *enabled,
                            struct cso_context *,
-                           void *st,
-                           void (*st_invalidate_state)(void *st, unsigned flags));
+                           struct st_context *st,
+                           pp_st_invalidate_state_func st_invalidate_state);
 
 void pp_run(struct pp_queue_t *, struct pipe_resource *,
             struct pipe_resource *, struct pipe_resource *);
index 7733e25..4d551db 100644 (file)
@@ -40,8 +40,8 @@
 /** Initialize the post-processing queue. */
 struct pp_queue_t *
 pp_init(struct pipe_context *pipe, const unsigned int *enabled,
-        struct cso_context *cso, void *st,
-        void (*st_invalidate_state)(void *st, unsigned flags))
+        struct cso_context *cso, struct st_context *st,
+        pp_st_invalidate_state_func st_invalidate_state)
 {
    unsigned int num_filters = 0;
    unsigned int curpos = 0, i, tmp_req = 0;
index 45fbe84..32e7c3a 100644 (file)
@@ -43,8 +43,8 @@ struct pp_program
    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;
+   pp_st_invalidate_state_func st_invalidate_state;
 
    struct pipe_blend_state blend;
    struct pipe_depth_stencil_alpha_state depthstencil;
@@ -98,8 +98,8 @@ void pp_free_fbos(struct pp_queue_t *);
 void pp_debug(const char *, ...);
 
 struct pp_program *pp_init_prog(struct pp_queue_t *, struct pipe_context *pipe,
-                                struct cso_context *, void *st,
-                                void (*st_invalidate_state)(void *st, unsigned flags));
+                                struct cso_context *, struct st_context *st,
+                                pp_st_invalidate_state_func st_invalidate_state);
 
 void pp_blit(struct pipe_context *pipe,
              struct pipe_resource *src_tex,
index c078678..3f36434 100644 (file)
@@ -41,8 +41,8 @@
 /** Initialize the internal details */
 struct pp_program *
 pp_init_prog(struct pp_queue_t *ppq, struct pipe_context *pipe,
-             struct cso_context *cso, void *st,
-             void (*st_invalidate_state)(void *st, unsigned flags))
+             struct cso_context *cso, struct st_context *st,
+             pp_st_invalidate_state_func st_invalidate_state)
 {
    struct pp_program *p;
 
index de21c78..7676f55 100644 (file)
@@ -189,7 +189,7 @@ 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, (void*)st_context_invalidate_state);
+                        ctx->st, st_context_invalidate_state);
       ctx->hud = hud_create(ctx->st->cso_context,
                             share_ctx ? share_ctx->hud : NULL,
                             ctx->st, st_context_invalidate_state);
index 0fdf878..ce07c92 100644 (file)
@@ -796,7 +796,7 @@ OSMesaMakeCurrent(OSMesaContext osmesa, void *buffer, GLenum type,
                               osmesa->pp_enabled,
                               osmesa->st->cso_context,
                               osmesa->st,
-                              (void*)st_context_invalidate_state);
+                              st_context_invalidate_state);
 
          pp_init_fbos(osmesa->pp, width, height);
       }
index 3f80275..6cef5ad 100644 (file)
@@ -204,13 +204,13 @@ GalliumContext::CreateContext(HGLWinsysContext *wsContext)
        assert(!context->st->frontend_context);
        context->st->frontend_context = (void*)context;
 
-       struct st_context *stContext = (struct st_context*)context->st;
+       struct st_context *stContext = context->st;
 
        // Init Gallium3D Post Processing
        // TODO: no pp filters are enabled yet through postProcessEnable
        context->postProcess = pp_init(stContext->pipe, context->postProcessEnable,
                stContext->cso_context, stContext,
-                (void*)st_context_invalidate_state);
+               st_context_invalidate_state);
 
        context_id contextNext = -1;
        Lock();