From a72e0e57eb27a767ea5929b5a6444754ab464f2e Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Wed, 26 Apr 2023 01:47:43 +0200 Subject: [PATCH] crocus: fix refcnt imbalance related to crocus_create_surface() Indeed, the objects are not freed when the function returns NULL. "psurf->texture = tex;" is redundant with "pipe_resource_reference(&psurf->texture, tex);". For instance, this issue is triggered with "piglit/bin/ext_texture_array-compressed teximage pbo -fbo -auto" while setting GALLIUM_REFCNT_LOG=refcnt.log. Fixes: f3630548f1da ("crocus: initial gallium driver for Intel gfx 4-7") Signed-off-by: Patrick Lerda Part-of: (cherry picked from commit d615dfca409988298d544ca8aa19ac16851629f9) --- .pick_status.json | 2 +- src/gallium/drivers/crocus/crocus_state.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 7db889d9c9f..dccb2991819 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -175,7 +175,7 @@ "description": "crocus: fix refcnt imbalance related to crocus_create_surface()", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "f3630548f1da904ec6c63b43ece7e68afdb8867e" }, diff --git a/src/gallium/drivers/crocus/crocus_state.c b/src/gallium/drivers/crocus/crocus_state.c index 79509abde20..28fa9e3fd65 100644 --- a/src/gallium/drivers/crocus/crocus_state.c +++ b/src/gallium/drivers/crocus/crocus_state.c @@ -2866,7 +2866,6 @@ crocus_create_surface(struct pipe_context *ctx, psurf->format = tmpl->format; psurf->width = tex->width0; psurf->height = tex->height0; - psurf->texture = tex; psurf->u.tex.first_layer = tmpl->u.tex.first_layer; psurf->u.tex.last_layer = tmpl->u.tex.last_layer; psurf->u.tex.level = tmpl->u.tex.level; @@ -2954,6 +2953,7 @@ crocus_create_surface(struct pipe_context *ctx, assert(view->levels == 1); /* TODO: compressed pbo uploads aren't working here */ + pipe_surface_reference(&psurf, NULL); return NULL; uint64_t offset_B = 0; @@ -2974,8 +2974,10 @@ crocus_create_surface(struct pipe_context *ctx, * Return NULL to force the state tracker to take fallback paths. */ // TODO: check if the gen7 check is right, originally gen8 - if (view->array_len > 1 || GFX_VER == 7) + if (view->array_len > 1 || GFX_VER == 7) { + pipe_surface_reference(&psurf, NULL); return NULL; + } const bool is_3d = res->surf.dim == ISL_SURF_DIM_3D; isl_surf_get_image_surf(&screen->isl_dev, &res->surf,