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>
(cherry picked from commit 456b57802e)
This commit is contained in:
Mike Blumenkrantz 2020-12-11 10:53:53 -05:00 committed by Dylan Baker
parent 5534e540a4
commit 76870cfae2
2 changed files with 7 additions and 4 deletions

View file

@ -301,7 +301,7 @@
"description": "zink: fix direct image mapping offset",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "8d46e35d16e3936968958bcab86d61967a673305"
},

View file

@ -523,9 +523,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;
}
}