etnaviv: fix wrong surface TS clear size
authorLucas Stach <l.stach@pengutronix.de>
Thu, 17 Nov 2022 14:56:40 +0000 (15:56 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 25 Nov 2022 21:30:40 +0000 (21:30 +0000)
Clearing ts_size - ts_offset bytes in a level means we are clearing the
TS region of all layers in the level starting from the surface layer, so
clearing one surface might corrupt all other layers of a resource level.
Use the correct size to clear only the requested TS region.

Cc: mesa-stable
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19814>

src/gallium/drivers/etnaviv/etnaviv_surface.c

index 89cae6a..7c0143c 100644 (file)
@@ -158,7 +158,6 @@ etna_create_surface(struct pipe_context *pctx, struct pipe_resource *prsc,
       assert(layer_offset < surf->surf.ts_size);
 
       surf->surf.ts_offset += layer_offset;
-      surf->surf.ts_size -= layer_offset;
       surf->surf.ts_valid = false;
 
       surf->ts_reloc.bo = rsc->ts_bo;
@@ -179,7 +178,7 @@ etna_create_surface(struct pipe_context *pctx, struct pipe_resource *prsc,
             .dest_tiling = ETNA_LAYOUT_TILED,
             .dither = {0xffffffff, 0xffffffff},
             .width = 16,
-            .height = align(surf->surf.ts_size / 0x40, 4),
+            .height = align(lev->ts_layer_stride / 0x40, 4),
             .clear_value = {screen->specs.ts_clear_value},
             .clear_mode = VIVS_RS_CLEAR_CONTROL_MODE_ENABLED1,
             .clear_bits = 0xffff