lima: Take offset in account when checking BO size

BO resources imported from a handle may have an offset provided, which
reduces the available size within the BO. Take this in account when
checking that the size is sufficient in lima.

Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Reviewed-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Andreas Baierl <ichgeh@imkreisrum.de>
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11076>
This commit is contained in:
Paul Kocialkowski
2021-05-28 23:06:49 +02:00
committed by Marge Bot
parent c880bdeb40
commit eefd93c176

View File

@@ -370,9 +370,9 @@ lima_resource_from_handle(struct pipe_screen *pscreen,
goto err_out;
}
if (res->bo->size < size) {
if ((res->bo->size - res->levels[0].offset) < size) {
fprintf(stderr, "imported bo size is smaller than expected: %d (BO) < %d (expected)\n",
res->bo->size, size);
(res->bo->size - res->levels[0].offset), size);
goto err_out;
}