zink: fix direct image mapping offset

the x and y offsets here were improperly calculated without taking into account:
* layer/level offset
* x/y coord bpp

Fixes: 8d46e35d16 ("zink: introduce opengl over vulkan")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8058>
This commit is contained in:
Mike Blumenkrantz 2020-12-11 10:53:53 -05:00 committed by Marge Bot
parent 84c8a35aa2
commit 456b57802e

View file

@ -613,9 +613,12 @@ zink_transfer_map(struct pipe_context *pctx,
vkGetImageSubresourceLayout(screen->dev, res->image, &isr, &srl);
trans->base.stride = srl.rowPitch;
trans->base.layer_stride = srl.arrayPitch;
ptr = ((uint8_t *)ptr) + box->z * srl.depthPitch +
box->y * srl.rowPitch +
box->x;
const struct util_format_description *desc = util_format_description(res->format);
unsigned offset = srl.offset +
box->z * srl.depthPitch +
(box->y / desc->block.height) * srl.rowPitch +
(box->x / desc->block.width) * (util_format_get_blocksize(res->format) / desc->nr_channels);
ptr = ((uint8_t *)ptr) + offset;
}
}