From 1fe03272552dd8c434e2ee27d7544b745cea6f07 Mon Sep 17 00:00:00 2001 From: Jose Maria Casanova Crespo Date: Fri, 28 Mar 2025 12:22:12 +0100 Subject: [PATCH] v3d: Remove tiling from v3d_surface Reviewed-by: Iago Toral Quiroga Part-of: --- src/gallium/drivers/v3d/v3d_resource.c | 7 +++--- src/gallium/drivers/v3d/v3d_resource.h | 3 --- src/gallium/drivers/v3d/v3dx_rcl.c | 34 ++++++++++++++++++-------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/v3d/v3d_resource.c b/src/gallium/drivers/v3d/v3d_resource.c index 0cdeec6c3c3..90a9b8c5bee 100644 --- a/src/gallium/drivers/v3d/v3d_resource.c +++ b/src/gallium/drivers/v3d/v3d_resource.c @@ -1098,7 +1098,8 @@ v3d_create_surface(struct pipe_context *pctx, psurf->level = level; psurf->first_layer = surf_tmpl->first_layer; psurf->last_layer = surf_tmpl->last_layer; - surface->tiling = slice->tiling; + + enum v3d_tiling_mode tiling = slice->tiling; if (util_format_is_depth_or_stencil(psurf->format)) { switch (psurf->format) { @@ -1121,8 +1122,8 @@ v3d_create_surface(struct pipe_context *pctx, surface->internal_bpp = bpp; } - if (surface->tiling == V3D_TILING_UIF_NO_XOR || - surface->tiling == V3D_TILING_UIF_XOR) { + if (tiling == V3D_TILING_UIF_NO_XOR || + tiling == V3D_TILING_UIF_XOR) { surface->padded_height_of_output_image_in_uif_blocks = (slice->padded_height / (2 * v3d_utile_height(rsc->cpp))); diff --git a/src/gallium/drivers/v3d/v3d_resource.h b/src/gallium/drivers/v3d/v3d_resource.h index ef2a9221d05..848edcc5fe0 100644 --- a/src/gallium/drivers/v3d/v3d_resource.h +++ b/src/gallium/drivers/v3d/v3d_resource.h @@ -50,8 +50,6 @@ struct v3d_resource_slice { struct v3d_surface { struct pipe_surface base; - enum v3d_tiling_mode tiling; - /** * Internal format of the tile buffer for * TILE_RENDERING_MODE_CONFIGURATION. @@ -159,5 +157,4 @@ void v3d_update_shadow_texture(struct pipe_context *pctx, uint32_t v3d_layer_offset(struct pipe_resource *prsc, uint32_t level, uint32_t layer); - #endif /* V3D_RESOURCE_H */ diff --git a/src/gallium/drivers/v3d/v3dx_rcl.c b/src/gallium/drivers/v3d/v3dx_rcl.c index 4a424d08b24..f98d17934aa 100644 --- a/src/gallium/drivers/v3d/v3dx_rcl.c +++ b/src/gallium/drivers/v3d/v3dx_rcl.c @@ -36,6 +36,14 @@ #define PIPE_FIRST_COLOR_BUFFER_BIT (ffs(PIPE_CLEAR_COLOR0) - 1) +static inline enum v3d_tiling_mode +v3d_surface_get_tiling(struct pipe_surface *psurf) +{ + assert(psurf && psurf->texture); + struct v3d_resource *rsc = v3d_resource(psurf->texture); + return rsc->slices[psurf->level].tiling; +} + static void load_general(struct v3d_cl *cl, struct pipe_surface *psurf, int buffer, int layer, uint32_t pipe_bit, uint32_t *loads_pending) @@ -52,11 +60,13 @@ load_general(struct v3d_cl *cl, struct pipe_surface *psurf, int buffer, uint32_t layer_offset = v3d_layer_offset(&rsc->base, psurf->level, psurf->first_layer + layer); + enum v3d_tiling_mode tiling = v3d_surface_get_tiling(psurf); + cl_emit(cl, LOAD_TILE_BUFFER_GENERAL, load) { load.buffer_to_load = buffer; load.address = cl_address(rsc->bo, layer_offset); - load.memory_format = surf->tiling; + load.memory_format = tiling; if (separate_stencil) load.input_image_format = V3D_OUTPUT_IMAGE_FORMAT_S8; else @@ -66,11 +76,11 @@ load_general(struct v3d_cl *cl, struct pipe_surface *psurf, int buffer, psurf->format); load.r_b_swap = v3d_format_needs_tlb_rb_swap(psurf->format); load.force_alpha_1 = util_format_has_alpha1(psurf->format); - if (surf->tiling == V3D_TILING_UIF_NO_XOR || - surf->tiling == V3D_TILING_UIF_XOR) { + if (tiling == V3D_TILING_UIF_NO_XOR || + tiling == V3D_TILING_UIF_XOR) { load.height_in_ub_or_stride = surf->padded_height_of_output_image_in_uif_blocks; - } else if (surf->tiling == V3D_TILING_RASTER) { + } else if (tiling == V3D_TILING_RASTER) { struct v3d_resource_slice *slice = &rsc->slices[psurf->level]; load.height_in_ub_or_stride = slice->stride; @@ -111,6 +121,8 @@ store_general(struct v3d_job *job, uint32_t layer_offset = v3d_layer_offset(&rsc->base, psurf->level, psurf->first_layer + layer); + enum v3d_tiling_mode tiling = v3d_surface_get_tiling(psurf); + cl_emit(cl, STORE_TILE_BUFFER_GENERAL, store) { store.buffer_to_store = buffer; store.address = cl_address(rsc->bo, layer_offset); @@ -126,13 +138,13 @@ store_general(struct v3d_job *job, psurf->format); store.r_b_swap = v3d_format_needs_tlb_rb_swap(psurf->format); - store.memory_format = surf->tiling; + store.memory_format = tiling; - if (surf->tiling == V3D_TILING_UIF_NO_XOR || - surf->tiling == V3D_TILING_UIF_XOR) { + if (tiling == V3D_TILING_UIF_NO_XOR || + tiling == V3D_TILING_UIF_XOR) { store.height_in_ub_or_stride = surf->padded_height_of_output_image_in_uif_blocks; - } else if (surf->tiling == V3D_TILING_RASTER) { + } else if (tiling == V3D_TILING_RASTER) { struct v3d_resource_slice *slice = &rsc->slices[psurf->level]; store.height_in_ub_or_stride = slice->stride; @@ -735,9 +747,11 @@ v3dX(emit_rcl)(struct v3d_job *job) UNUSED uint32_t config_pad = 0; UNUSED uint32_t clear_pad = 0; + enum v3d_tiling_mode tiling = v3d_surface_get_tiling(psurf); + /* XXX: Set the pad for raster. */ - if (surf->tiling == V3D_TILING_UIF_NO_XOR || - surf->tiling == V3D_TILING_UIF_XOR) { + if (tiling == V3D_TILING_UIF_NO_XOR || + tiling == V3D_TILING_UIF_XOR) { int uif_block_height = v3d_utile_height(rsc->cpp) * 2; uint32_t implicit_padded_height = (align(job->draw_height, uif_block_height) / uif_block_height);