From 2f8982df0e7705e1a43e218dd67b684d70c05d31 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 6 Jan 2022 14:07:18 +0100 Subject: [PATCH] radeonsi/gfx10: fix si_texture_get_offset for mipmapped tex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pitch can be different per-level so adjust stride and offset. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5792 Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_texture.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c index 436b1c7f9f7..9a21fbde988 100644 --- a/src/gallium/drivers/radeonsi/si_texture.c +++ b/src/gallium/drivers/radeonsi/si_texture.c @@ -123,7 +123,14 @@ static unsigned si_texture_get_offset(struct si_screen *sscreen, struct si_textu unsigned *layer_stride) { if (sscreen->info.chip_class >= GFX9) { - *stride = tex->surface.u.gfx9.surf_pitch * tex->surface.bpe; + unsigned pitch; + if (tex->surface.is_linear) { + pitch = tex->surface.u.gfx9.pitch[level]; + } else { + pitch = tex->surface.u.gfx9.surf_pitch; + } + + *stride = pitch * tex->surface.bpe; *layer_stride = tex->surface.u.gfx9.surf_slice_size; if (!box) @@ -133,9 +140,8 @@ static unsigned si_texture_get_offset(struct si_screen *sscreen, struct si_textu * of mipmap levels. */ return tex->surface.u.gfx9.surf_offset + box->z * tex->surface.u.gfx9.surf_slice_size + tex->surface.u.gfx9.offset[level] + - (box->y / tex->surface.blk_h * tex->surface.u.gfx9.surf_pitch + - box->x / tex->surface.blk_w) * - tex->surface.bpe; + (box->y / tex->surface.blk_h * pitch + box->x / tex->surface.blk_w) * + tex->surface.bpe; } else { *stride = tex->surface.u.legacy.level[level].nblk_x * tex->surface.bpe; assert((uint64_t)tex->surface.u.legacy.level[level].slice_size_dw * 4 <= UINT_MAX);