From 490abd0a2653742796230c2e9c19ee746051f6fe Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Fri, 4 Jul 2025 15:28:46 +0200 Subject: [PATCH] r600: refactor step 10 - drop create_surface This change removes create_surface, surface_destroy and pipe_surface_reference which are no longer needed. Only r600_create_surface_custom remains which returns now a simple pipe_surface. The arguments width0 and height0 of r600_create_surface_custom are not used and are removed. Signed-off-by: Patrick Lerda Part-of: --- src/gallium/drivers/r600/r600_blit.c | 23 ++++++------- src/gallium/drivers/r600/r600_pipe_common.h | 4 +-- src/gallium/drivers/r600/r600_texture.c | 36 ++------------------- 3 files changed, 14 insertions(+), 49 deletions(-) diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c index c18c9e7b025..2197a16cb30 100644 --- a/src/gallium/drivers/r600/r600_blit.c +++ b/src/gallium/drivers/r600/r600_blit.c @@ -171,19 +171,18 @@ static void r600_blit_decompress_depth(struct pipe_context *ctx, surf_tmpl.first_layer = layer; surf_tmpl.last_layer = layer; - zsurf = ctx->create_surface(ctx, &texture->resource.b.b, &surf_tmpl); + zsurf = r600_create_surface_custom(ctx, &texture->resource.b.b, &surf_tmpl); surf_tmpl.format = flushed_depth_texture->resource.b.b.format; - cbsurf = ctx->create_surface(ctx, - &flushed_depth_texture->resource.b.b, &surf_tmpl); + cbsurf = r600_create_surface_custom(ctx, &flushed_depth_texture->resource.b.b, &surf_tmpl); r600_blitter_begin(ctx, R600_DECOMPRESS); util_blitter_custom_depth_stencil(rctx->blitter, zsurf, cbsurf, 1 << sample, rctx->custom_dsa_flush, depth); r600_blitter_end(ctx); - pipe_surface_reference(&zsurf, NULL); - pipe_surface_reference(&cbsurf, NULL); + r600_destroy_surface_custom(zsurf); + r600_destroy_surface_custom(cbsurf); } } @@ -238,14 +237,14 @@ static void r600_blit_decompress_depth_in_place(struct r600_context *rctx, surf_tmpl.first_layer = layer; surf_tmpl.last_layer = layer; - zsurf = rctx->b.b.create_surface(&rctx->b.b, &texture->resource.b.b, &surf_tmpl); + zsurf = r600_create_surface_custom(&rctx->b.b, &texture->resource.b.b, &surf_tmpl); r600_blitter_begin(&rctx->b.b, R600_DECOMPRESS); util_blitter_custom_depth_stencil(rctx->blitter, zsurf, NULL, ~0, rctx->custom_dsa_flush, 1.0f); r600_blitter_end(&rctx->b.b); - pipe_surface_reference(&zsurf, NULL); + r600_destroy_surface_custom(zsurf); } /* The texture will always be dirty if some layers or samples aren't flushed. @@ -356,14 +355,14 @@ static void r600_blit_decompress_color(struct pipe_context *ctx, surf_tmpl.level = level; surf_tmpl.first_layer = layer; surf_tmpl.last_layer = layer; - cbsurf = ctx->create_surface(ctx, &rtex->resource.b.b, &surf_tmpl); + cbsurf = r600_create_surface_custom(ctx, &rtex->resource.b.b, &surf_tmpl); r600_blitter_begin(ctx, R600_DECOMPRESS); util_blitter_custom_color(rctx->blitter, cbsurf, rtex->fmask.size ? rctx->custom_blend_decompress : rctx->custom_blend_fastclear); r600_blitter_end(ctx); - pipe_surface_reference(&cbsurf, NULL); + r600_destroy_surface_custom(cbsurf); } /* The texture will always be dirty if some layers aren't flushed. @@ -988,9 +987,7 @@ void r600_resource_copy_region(struct pipe_context *ctx, } } - dst_view = r600_create_surface_custom(ctx, dst, &dst_templ, - /* we don't care about these two for r600g */ - dst->width0, dst->height0); + dst_view = r600_create_surface_custom(ctx, dst, &dst_templ); if (rctx->b.gfx_level >= EVERGREEN) { src_view = evergreen_create_sampler_view_custom(ctx, src, &src_templ, @@ -1012,7 +1009,7 @@ void r600_resource_copy_region(struct pipe_context *ctx, false, false, 0, NULL); r600_blitter_end(ctx); - pipe_surface_reference(&dst_view, NULL); + r600_destroy_surface_custom(dst_view); pipe_sampler_view_reference(&src_view, NULL); } diff --git a/src/gallium/drivers/r600/r600_pipe_common.h b/src/gallium/drivers/r600/r600_pipe_common.h index ce4803fa701..ea06b0c3936 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.h +++ b/src/gallium/drivers/r600/r600_pipe_common.h @@ -825,8 +825,8 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen, const struct pipe_resource *templ); struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe, struct pipe_resource *texture, - const struct pipe_surface *templ, - unsigned width0, unsigned height0); + const struct pipe_surface *templ); +void r600_destroy_surface_custom(struct pipe_surface *); unsigned r600_translate_colorswap(enum pipe_format format, bool do_endian_swap); void r600_texture_alloc_cmask_separate(struct r600_common_screen *rscreen, struct r600_texture *rtex); diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c index 5f28cff064f..b178db051ec 100644 --- a/src/gallium/drivers/r600/r600_texture.c +++ b/src/gallium/drivers/r600/r600_texture.c @@ -1489,8 +1489,7 @@ void r600_texture_transfer_unmap(struct pipe_context *ctx, struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe, struct pipe_resource *texture, - const struct pipe_surface *templ, - unsigned width0, unsigned height0) + const struct pipe_surface *templ) { struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface); @@ -1511,36 +1510,7 @@ struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe, return surface; } -static struct pipe_surface *r600_create_surface(struct pipe_context *pipe, - struct pipe_resource *tex, - const struct pipe_surface *templ) -{ - unsigned width0 = tex->width0; - unsigned height0 = tex->height0; - - if (tex->target != PIPE_BUFFER && templ->format != tex->format) { - const struct util_format_description *tex_desc - = util_format_description(tex->format); - const struct util_format_description *templ_desc - = util_format_description(templ->format); - - assert(tex_desc->block.bits == templ_desc->block.bits); - - /* Adjust size of surface if and only if the block width or - * height is changed. */ - if (tex_desc->block.width != templ_desc->block.width || - tex_desc->block.height != templ_desc->block.height) { - width0 = util_format_get_nblocksx(tex->format, width0); - height0 = util_format_get_nblocksy(tex->format, height0); - } - } - - return r600_create_surface_custom(pipe, tex, templ, - width0, height0); -} - -static void r600_surface_destroy(struct pipe_context *pipe, - struct pipe_surface *surface) +void r600_destroy_surface_custom(struct pipe_surface *surface) { pipe_resource_reference(&surface->texture, NULL); FREE(surface); @@ -1727,7 +1697,5 @@ void r600_init_screen_texture_functions(struct r600_common_screen *rscreen) void r600_init_context_texture_functions(struct r600_common_context *rctx) { - rctx->b.create_surface = r600_create_surface; - rctx->b.surface_destroy = r600_surface_destroy; rctx->b.clear_texture = u_default_clear_texture; }