crocus: clean up surface management

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40462>
This commit is contained in:
Mike Blumenkrantz 2026-03-16 12:16:46 -04:00 committed by Marge Bot
parent a4c0f5ba6f
commit 0115fc92c6
2 changed files with 14 additions and 20 deletions

View file

@ -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;
}

View file

@ -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;