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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26990>
This commit is contained in:
Faith Ekstrand 2024-01-30 18:31:37 -06:00 committed by Marge Bot
parent 445aacb421
commit e8bec58de0

View file

@ -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,