zink: Make wrap_surface return a zink_ctx_surface directly
Avoids to cast if back to zink_ctx_surface afterwards.
Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28025>
diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c
index 31a57e8..dd80463 100644
--- a/src/gallium/drivers/zink/zink_surface.c
+++ b/src/gallium/drivers/zink/zink_surface.c
@@ -268,7 +268,7 @@
}
/* 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 @@
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 @@
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 @@
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);