From 0115fc92c6c8a7cf05e8e5b31391aa90da9d81e7 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 16 Mar 2026 12:16:46 -0400 Subject: [PATCH] crocus: clean up surface management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/crocus/crocus_blit.c | 7 ++---- src/gallium/drivers/crocus/crocus_state.c | 27 ++++++++++------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/crocus/crocus_blit.c b/src/gallium/drivers/crocus/crocus_blit.c index 5ebeb5418d0..ce8b9b52f1d 100644 --- a/src/gallium/drivers/crocus/crocus_blit.c +++ b/src/gallium/drivers/crocus/crocus_blit.c @@ -416,13 +416,12 @@ crocus_blit(struct pipe_context *ctx, const struct pipe_blit_info *info) crocus_blitter_begin(ice, CROCUS_SAVE_FRAMEBUFFER | CROCUS_SAVE_TEXTURES | CROCUS_SAVE_FRAGMENT_STATE, info->render_condition_enable); util_blitter_blit(ice->blitter, &depth_blit, NULL); - struct pipe_surface *dst_view, dst_templ; + struct pipe_surface dst_templ; util_blitter_default_dst_texture(&dst_templ, info->dst.resource, info->dst.level, info->dst.box.z); - dst_view = ctx->create_surface(ctx, info->dst.resource, &dst_templ); crocus_blitter_begin(ice, CROCUS_SAVE_FRAMEBUFFER | CROCUS_SAVE_TEXTURES | CROCUS_SAVE_FRAGMENT_STATE, info->render_condition_enable); - util_blitter_clear_depth_stencil(ice->blitter, dst_view, PIPE_CLEAR_STENCIL, + util_blitter_clear_depth_stencil(ice->blitter, &dst_templ, PIPE_CLEAR_STENCIL, 0, 0, info->dst.box.x, info->dst.box.y, info->dst.box.width, info->dst.box.height); crocus_blitter_begin(ice, CROCUS_SAVE_FRAMEBUFFER | CROCUS_SAVE_TEXTURES | CROCUS_SAVE_FRAGMENT_STATE, info->render_condition_enable); @@ -433,8 +432,6 @@ crocus_blit(struct pipe_context *ctx, const struct pipe_blit_info *info) info->src.resource, info->src.level, &info->src.box, NULL); - - pipe_surface_unref(ctx, &dst_view); } return; } diff --git a/src/gallium/drivers/crocus/crocus_state.c b/src/gallium/drivers/crocus/crocus_state.c index a9b26c6e84e..41243e89b8b 100644 --- a/src/gallium/drivers/crocus/crocus_state.c +++ b/src/gallium/drivers/crocus/crocus_state.c @@ -2814,9 +2814,17 @@ crocus_sampler_view_destroy(struct pipe_context *ctx, free(isv); } +static void +crocus_surface_destroy(struct pipe_context *ctx, struct pipe_surface *p_surf) +{ + struct crocus_surface *surf = (void *) p_surf; + pipe_resource_reference(&p_surf->texture, NULL); + + pipe_resource_reference(&surf->align_res, NULL); + free(surf); +} + /** - * The pipe->create_surface() driver hook. - * * In Gallium nomenclature, "surfaces" are a view of a resource that * can be bound as a render target or depth/stencil buffer. */ @@ -2940,7 +2948,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); + crocus_surface_destroy(ctx, psurf); return NULL; uint64_t offset_B = 0; @@ -2962,7 +2970,7 @@ crocus_create_surface(struct pipe_context *ctx, */ // TODO: check if the gen7 check is right, originally gen8 if (view->array_len > 1 || GFX_VER == 7) { - pipe_surface_reference(&psurf, NULL); + crocus_surface_destroy(ctx, psurf); return NULL; } @@ -3191,16 +3199,6 @@ crocus_set_patch_vertices(struct pipe_context *ctx, uint8_t patch_vertices) ice->state.patch_vertices = patch_vertices; } -static void -crocus_surface_destroy(struct pipe_context *ctx, struct pipe_surface *p_surf) -{ - struct crocus_surface *surf = (void *) p_surf; - pipe_resource_reference(&p_surf->texture, NULL); - - pipe_resource_reference(&surf->align_res, NULL); - free(surf); -} - static void crocus_set_clip_state(struct pipe_context *ctx, const struct pipe_clip_state *state) @@ -9293,7 +9291,6 @@ genX(crocus_init_state)(struct crocus_context *ice) ctx->sampler_view_destroy = crocus_sampler_view_destroy; ctx->sampler_view_release = u_default_sampler_view_release; ctx->resource_release = u_default_resource_release; - ctx->surface_destroy = crocus_surface_destroy; ctx->draw_vbo = crocus_draw_vbo; ctx->launch_grid = crocus_launch_grid;