From 735cf1cb78ea53f45b341bd75456e3b30c950011 Mon Sep 17 00:00:00 2001 From: Jose Maria Casanova Crespo Date: Fri, 28 Mar 2025 12:44:25 +0100 Subject: [PATCH] v3d: Remove padded_height_of_output_image_in_uif_blocks from v3d_surface Reviewed-by: Iago Toral Quiroga Part-of: --- src/gallium/drivers/v3d/v3d_resource.c | 13 +----- src/gallium/drivers/v3d/v3d_resource.h | 2 - src/gallium/drivers/v3d/v3dx_rcl.c | 55 ++++++++++++++------------ 3 files changed, 30 insertions(+), 40 deletions(-) diff --git a/src/gallium/drivers/v3d/v3d_resource.c b/src/gallium/drivers/v3d/v3d_resource.c index 90a9b8c5bee..9505ae270c1 100644 --- a/src/gallium/drivers/v3d/v3d_resource.c +++ b/src/gallium/drivers/v3d/v3d_resource.c @@ -1087,20 +1087,16 @@ v3d_create_surface(struct pipe_context *pctx, return NULL; struct pipe_surface *psurf = &surface->base; - unsigned level = surf_tmpl->level; - struct v3d_resource_slice *slice = &rsc->slices[level]; pipe_reference_init(&psurf->reference, 1); pipe_resource_reference(&psurf->texture, ptex); psurf->context = pctx; psurf->format = surf_tmpl->format; - psurf->level = level; + psurf->level = surf_tmpl->level; psurf->first_layer = surf_tmpl->first_layer; psurf->last_layer = surf_tmpl->last_layer; - enum v3d_tiling_mode tiling = slice->tiling; - if (util_format_is_depth_or_stencil(psurf->format)) { switch (psurf->format) { case PIPE_FORMAT_Z16_UNORM: @@ -1122,13 +1118,6 @@ v3d_create_surface(struct pipe_context *pctx, surface->internal_bpp = bpp; } - 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))); - } - if (rsc->separate_stencil) { surface->separate_stencil = v3d_create_surface(pctx, &rsc->separate_stencil->base, diff --git a/src/gallium/drivers/v3d/v3d_resource.h b/src/gallium/drivers/v3d/v3d_resource.h index 848edcc5fe0..f13901126ef 100644 --- a/src/gallium/drivers/v3d/v3d_resource.h +++ b/src/gallium/drivers/v3d/v3d_resource.h @@ -62,8 +62,6 @@ struct v3d_surface { */ uint8_t internal_bpp; - uint32_t padded_height_of_output_image_in_uif_blocks; - /* If the resource being referenced is separate stencil, then this is * the surface to use when reading/writing stencil. */ diff --git a/src/gallium/drivers/v3d/v3dx_rcl.c b/src/gallium/drivers/v3d/v3dx_rcl.c index f98d17934aa..26ff1e1a2ae 100644 --- a/src/gallium/drivers/v3d/v3dx_rcl.c +++ b/src/gallium/drivers/v3d/v3dx_rcl.c @@ -44,6 +44,23 @@ v3d_surface_get_tiling(struct pipe_surface *psurf) return rsc->slices[psurf->level].tiling; } +static uint32_t +v3d_surface_get_height_in_ub_or_stride(struct pipe_surface *psurf) +{ + assert(psurf && psurf->texture); + struct v3d_resource *rsc = v3d_resource(psurf->texture); + struct v3d_resource_slice *slice = &rsc->slices[psurf->level]; + + if (slice->tiling == V3D_TILING_UIF_NO_XOR || + slice->tiling == V3D_TILING_UIF_XOR) { + return (slice->padded_height / + (2 * v3d_utile_height(rsc->cpp))); + } else if (slice->tiling == V3D_TILING_RASTER) { + return slice->stride; + } + return 0; +} + static void load_general(struct v3d_cl *cl, struct pipe_surface *psurf, int buffer, int layer, uint32_t pipe_bit, uint32_t *loads_pending) @@ -60,13 +77,12 @@ 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 = tiling; + load.memory_format = v3d_surface_get_tiling(psurf); if (separate_stencil) load.input_image_format = V3D_OUTPUT_IMAGE_FORMAT_S8; else @@ -76,15 +92,8 @@ 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 (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 (tiling == V3D_TILING_RASTER) { - struct v3d_resource_slice *slice = - &rsc->slices[psurf->level]; - load.height_in_ub_or_stride = slice->stride; - } + load.height_in_ub_or_stride = + v3d_surface_get_height_in_ub_or_stride(psurf); if (psurf->texture->nr_samples > 1) load.decimate_mode = V3D_DECIMATE_MODE_ALL_SAMPLES; @@ -121,7 +130,6 @@ 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; @@ -138,17 +146,9 @@ store_general(struct v3d_job *job, psurf->format); store.r_b_swap = v3d_format_needs_tlb_rb_swap(psurf->format); - store.memory_format = tiling; - - 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 (tiling == V3D_TILING_RASTER) { - struct v3d_resource_slice *slice = - &rsc->slices[psurf->level]; - store.height_in_ub_or_stride = slice->stride; - } + store.memory_format = v3d_surface_get_tiling(psurf); + store.height_in_ub_or_stride = + v3d_surface_get_height_in_ub_or_stride(psurf); if (psurf->texture->nr_samples > 1) { store.decimate_mode = V3D_DECIMATE_MODE_ALL_SAMPLES; @@ -755,13 +755,16 @@ v3dX(emit_rcl)(struct v3d_job *job) 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); - if (surf->padded_height_of_output_image_in_uif_blocks - + uint32_t padded_height_of_output_image_in_uif_blocks = + v3d_surface_get_height_in_ub_or_stride(psurf); + + if (padded_height_of_output_image_in_uif_blocks - implicit_padded_height < 15) { - config_pad = (surf->padded_height_of_output_image_in_uif_blocks - + config_pad = (padded_height_of_output_image_in_uif_blocks - implicit_padded_height); } else { config_pad = 15; - clear_pad = surf->padded_height_of_output_image_in_uif_blocks; + clear_pad = padded_height_of_output_image_in_uif_blocks; } }