From 27bde4b420043036d36e8aa3b73b38aaf7c7df04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Mon, 11 Mar 2024 09:31:12 +0100 Subject: [PATCH] zink: Return early if the source could not have been acquired MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the success case the main one. Signed-off-by: Corentin Noël Part-of: --- src/gallium/drivers/zink/zink_surface.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c index e1f73ca1dc5..987ecc91284 100644 --- a/src/gallium/drivers/zink/zink_surface.c +++ b/src/gallium/drivers/zink/zink_surface.c @@ -330,15 +330,16 @@ zink_create_surface(struct pipe_context *pctx, if (res->obj->dt) { /* don't cache swapchain surfaces. that's weird. */ struct zink_surface *surface = do_create_surface(pctx, pres, templ, &ivci, 0, false); - if (surface) { - surface->is_swapchain = true; - psurf = &surface->base; - } + if (unlikely(!surface)) + return NULL; + + surface->is_swapchain = true; + psurf = &surface->base; } else if (!needs_mutable) { psurf = zink_get_surface(zink_context(pctx), pres, templ, &ivci); + if (unlikely(!psurf)) + return NULL; } - if (!psurf && !needs_mutable) - return NULL; struct zink_ctx_surface *csurf = wrap_surface(pctx, needs_mutable ? NULL : psurf, needs_mutable ? templ : psurf); csurf->needs_mutable = needs_mutable;