From e8bec58de0138ba1e6118b45b1c0240e25cdf11b Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 30 Jan 2024 18:31:37 -0600 Subject: [PATCH] nil: Set the level offset to 0 in nil_image_for_level The offset_B member of levels[0] should always be 0. In this case, we're copying the level from the previous image but we've already taken the offset into account via the offset_B_out parameter. Leaving the offset non-zero risks it getting added in twice if nil_image_for_level gets called again. In particular, NVK can hit this with 3D compressed textures with VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT set. Part-of: --- src/nouveau/nil/nil_image.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nouveau/nil/nil_image.c b/src/nouveau/nil/nil_image.c index 3f905e4bddd..17d6732e2a5 100644 --- a/src/nouveau/nil/nil_image.c +++ b/src/nouveau/nil/nil_image.c @@ -527,7 +527,7 @@ nil_image_for_level(const struct nil_image *image_in, const struct nil_extent4d lvl_extent_px = nil_image_level_extent_px(image_in, level); - const struct nil_image_level lvl = image_in->levels[level]; + struct nil_image_level lvl = image_in->levels[level]; const uint32_t align_B = nil_tiling_size_B(lvl.tiling); uint64_t size_B = image_in->size_B - lvl.offset_B; @@ -542,6 +542,8 @@ nil_image_for_level(const struct nil_image *image_in, } *offset_B_out = lvl.offset_B; + lvl.offset_B = 0; + *lvl_image_out = (struct nil_image) { .dim = image_in->dim, .format = image_in->format,