From 617969d8a28f3b086b1b6cbd2be5471c5bed110d Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 10 Jul 2025 15:58:14 -0700 Subject: [PATCH] freedreno: Move layout init to backends Export the existing helper, and call it from the legacy backends which are not using fdl. This moves all the layout initialization to the backends (and eventually to fdl for the backends using that). Signed-off-by: Rob Clark Part-of: --- src/gallium/drivers/freedreno/a2xx/fd2_resource.c | 2 ++ src/gallium/drivers/freedreno/a3xx/fd3_resource.c | 2 ++ src/gallium/drivers/freedreno/a4xx/fd4_resource.c | 2 ++ src/gallium/drivers/freedreno/freedreno_resource.c | 5 ++--- src/gallium/drivers/freedreno/freedreno_resource.h | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_resource.c b/src/gallium/drivers/freedreno/a2xx/fd2_resource.c index 7074a44c7d2..e6d490066dc 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_resource.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_resource.c @@ -17,6 +17,8 @@ fd2_layout_resource(struct fd_resource *rsc, enum fd_layout_type type) uint32_t height0 = util_format_get_nblocksy(format, prsc->height0); uint32_t level, size = 0; + fd_resource_layout_init(prsc); + /* 32 pixel alignment */ fdl_set_pitchalign(&rsc->layout, fdl_cpp_shift(&rsc->layout) + 5); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_resource.c b/src/gallium/drivers/freedreno/a3xx/fd3_resource.c index 00f91967492..032c2a972d2 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_resource.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_resource.c @@ -56,6 +56,8 @@ fd3_layout_resource(struct fd_resource *rsc, enum fd_layout_type type) { uint32_t alignment; + fd_resource_layout_init(&rsc->b.b); + if (type >= FD_LAYOUT_TILED) rsc->layout.tile_mode = fd3_tile_mode(&rsc->b.b); if (type == FD_LAYOUT_UBWC) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_resource.c b/src/gallium/drivers/freedreno/a4xx/fd4_resource.c index 90efd8f089e..481961f6693 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_resource.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_resource.c @@ -26,6 +26,8 @@ fd4_layout_resource(struct fd_resource *rsc, enum fd_layout_type type) assert(type == FD_LAYOUT_LINEAR); + fd_resource_layout_init(prsc); + if (prsc->target == PIPE_TEXTURE_3D) { rsc->layout.layer_first = false; layers_in_level = prsc->array_size; diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 946cccf4f18..40c01cc02b6 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -1180,7 +1180,8 @@ fd_resource_resize(struct pipe_resource *prsc, uint32_t sz) realloc_bo(rsc, rsc->layout.size); } -static void +/* Helper for legacy backends not using fdl: */ +void fd_resource_layout_init(struct pipe_resource *prsc) { struct fd_resource *rsc = fd_resource(prsc); @@ -1368,8 +1369,6 @@ fd_resource_allocate_and_resolve(struct pipe_screen *pscreen, if (tmpl->bind & PIPE_BIND_SHARED) rsc->b.is_shared = true; - fd_resource_layout_init(prsc); - enum fd_layout_type layout = get_best_layout(screen, tmpl, modifiers, count); if (layout == FD_LAYOUT_ERROR) { diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h index 59b68018787..cbaf9de6ef8 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.h +++ b/src/gallium/drivers/freedreno/freedreno_resource.h @@ -344,6 +344,7 @@ void fd_resource_context_init(struct pipe_context *pctx); uint32_t fd_setup_slices(struct fd_resource *rsc); void fd_resource_resize(struct pipe_resource *prsc, uint32_t sz); +void fd_resource_layout_init(struct pipe_resource *prsc); void fd_replace_buffer_storage(struct pipe_context *ctx, struct pipe_resource *dst, struct pipe_resource *src,