From d54be8ef219e9c8a42873c9a1fa353de7563780d Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 22 Jul 2024 13:46:56 -0700 Subject: [PATCH] crocus: check for depth+stencil before creating resource This avoid leaking memory if we return early. Fixes: 5f7df5df0d8 ("crocus: disable depth and d+s formats with memory objects") Reviewed-by: Nanley Chery Part-of: (cherry picked from commit 4ef0cbaf055c077c5cb65326f9642ea1c37bf825) --- .pick_status.json | 2 +- src/gallium/drivers/crocus/crocus_resource.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 0c0cbf94df4..935d7d01d71 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1854,7 +1854,7 @@ "description": "crocus: check for depth+stencil before creating resource", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "5f7df5df0d8410925edcfb926509f6b17ef6b619", "notes": null diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c index 778d2b735b8..9ce8f27562b 100644 --- a/src/gallium/drivers/crocus/crocus_resource.c +++ b/src/gallium/drivers/crocus/crocus_resource.c @@ -841,6 +841,10 @@ crocus_resource_from_memobj(struct pipe_screen *pscreen, struct pipe_memory_object *pmemobj, uint64_t offset) { + /* Disable Depth, and combined Depth+Stencil for now. */ + if (util_format_has_depth(util_format_description(templ->format))) + return NULL; + struct crocus_screen *screen = (struct crocus_screen *)pscreen; struct crocus_memory_object *memobj = (struct crocus_memory_object *)pmemobj; struct crocus_resource *res = crocus_alloc_resource(pscreen, templ); @@ -848,10 +852,6 @@ crocus_resource_from_memobj(struct pipe_screen *pscreen, if (!res) return NULL; - /* Disable Depth, and combined Depth+Stencil for now. */ - if (util_format_has_depth(util_format_description(templ->format))) - return NULL; - if (templ->flags & PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY) { UNUSED const bool isl_surf_created_successfully = crocus_resource_configure_main(screen, res, templ, DRM_FORMAT_MOD_INVALID, 0);