From 9496b7a2fa0ffb1167b7b15d89a546615045832b Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 10 Aug 2022 21:24:03 +0200 Subject: [PATCH] etnaviv: fix TS buffer allocation for 3D textures For 3D textures the number of layers is the resource depth. As the TS buffer allocation only looked at the array size it does not allocate enough TS storage for 3D textures. Fixes piglit spec@!opengl 1.2@copyteximage 3d Signed-off-by: Lucas Stach Reviewed-by: Christian Gmeiner Part-of: --- src/gallium/drivers/etnaviv/etnaviv_resource.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c index 6ad02dda152..ac72387a25e 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c @@ -84,9 +84,11 @@ etna_screen_resource_alloc_ts(struct pipe_screen *pscreen, struct etna_resource *rsc) { struct etna_screen *screen = etna_screen(pscreen); + struct pipe_resource *prsc = &rsc->base; size_t rt_ts_size, ts_layer_stride; uint8_t ts_mode = TS_MODE_128B; int8_t ts_compress_fmt; + unsigned layers; assert(!rsc->ts_bo); @@ -94,8 +96,8 @@ etna_screen_resource_alloc_ts(struct pipe_screen *pscreen, * v4 compression can be enabled everywhere without any known drawback, * except that in-place resolve must go through a slower path */ - ts_compress_fmt = (screen->specs.v4_compression || rsc->base.nr_samples > 1) ? - translate_ts_format(rsc->base.format) : -1; + ts_compress_fmt = (screen->specs.v4_compression || prsc->nr_samples > 1) ? + translate_ts_format(prsc->format) : -1; /* enable 256B ts mode with compression, as it improves performance * the size of the resource might also determine if we want to use it or not @@ -104,11 +106,12 @@ etna_screen_resource_alloc_ts(struct pipe_screen *pscreen, ts_compress_fmt >= 0) ts_mode = TS_MODE_256B; + layers = prsc->target == PIPE_TEXTURE_3D ? prsc->depth0 : prsc->array_size; ts_layer_stride = align(DIV_ROUND_UP(rsc->levels[0].layer_stride, etna_screen_get_tile_size(screen, ts_mode) * 8 / screen->specs.bits_per_tile), 0x100 * screen->specs.pixel_pipes); - rt_ts_size = ts_layer_stride * rsc->base.array_size; + rt_ts_size = ts_layer_stride * layers; if (rt_ts_size == 0) return true;