From faaa65a1a31041c97f23a0706df6196cd8635fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Fri, 8 Mar 2024 14:29:45 +0100 Subject: [PATCH] zink: Make wrap_surface return a zink_ctx_surface directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids to cast if back to zink_ctx_surface afterwards. Signed-off-by: Corentin Noël Part-of: --- src/gallium/drivers/zink/zink_surface.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c index 31a57e85c85..dd80463497f 100644 --- a/src/gallium/drivers/zink/zink_surface.c +++ b/src/gallium/drivers/zink/zink_surface.c @@ -268,7 +268,7 @@ zink_get_surface(struct zink_context *ctx, } /* wrap a surface for use as a framebuffer attachment */ -static struct pipe_surface * +static struct zink_ctx_surface * wrap_surface(struct pipe_context *pctx, const struct pipe_surface *psurf) { struct zink_ctx_surface *csurf = CALLOC_STRUCT(zink_ctx_surface); @@ -276,13 +276,13 @@ wrap_surface(struct pipe_context *pctx, const struct pipe_surface *psurf) mesa_loge("ZINK: failed to allocate csurf!"); return NULL; } - + csurf->base = *psurf; pipe_reference_init(&csurf->base.reference, 1); csurf->surf = (struct zink_surface*)psurf; csurf->base.context = pctx; - return &csurf->base; + return csurf; } /* this the context hook that returns a zink_ctx_surface */ @@ -338,7 +338,7 @@ zink_create_surface(struct pipe_context *pctx, if (!psurf && !needs_mutable) return NULL; - struct zink_ctx_surface *csurf = (struct zink_ctx_surface*)wrap_surface(pctx, needs_mutable ? templ : psurf); + struct zink_ctx_surface *csurf = wrap_surface(pctx, needs_mutable ? templ : psurf); csurf->needs_mutable = needs_mutable; if (needs_mutable) { csurf->surf = NULL; @@ -355,7 +355,7 @@ zink_create_surface(struct pipe_context *pctx, if (!transient) return NULL; ivci.image = transient->obj->image; - csurf->transient = (struct zink_ctx_surface*)wrap_surface(pctx, (struct pipe_surface*)create_surface(pctx, &transient->base.b, templ, &ivci, true)); + csurf->transient = wrap_surface(pctx, (struct pipe_surface*)create_surface(pctx, &transient->base.b, templ, &ivci, true)); if (!csurf->transient) { pipe_resource_reference((struct pipe_resource**)&transient, NULL); pipe_surface_release(pctx, &psurf);