llvmpipe: Stop aligning height to raster block size for unbacked handles

This code path is usually used by lavapipe when importing dmabufs, not
for output.
The resulting size_required is then used to calculate the size
requirements for VkMemoryRequirements2 etc. Requiring a multiple of
LP_RASTER_BLOCK_SIZE - 4 - can eventually result in lavapipe rejecting
dmabuf imports.

An example is YUV420 at a resolution of 1680x1050 produced by Gstreamer
1.28 - e.g. from a screencasts. In this case we currently compute a size
of 3235840, while other drivers like radv compute 3225600. The actual
size is 3227648, fitting into the later but not the former.

Removing the alignment brings lavapipe in line with other drivers.

Cc: mesa-stable
Signed-off-by: Robert Mader <robert.mader@collabora.com>
(cherry picked from commit 0bbc26d2c4)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40752>
This commit is contained in:
Robert Mader 2026-03-15 17:10:25 +01:00 committed by Eric Engestrom
parent 676c9c7f0e
commit eccd9df749
2 changed files with 14 additions and 5 deletions

View file

@ -6164,7 +6164,7 @@
"description": "llvmpipe: Stop aligning height to raster block size for unbacked handles",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -751,11 +751,20 @@ llvmpipe_resource_from_handle(struct pipe_screen *_screen,
assert(lpr->base.height0 == height);
#endif
unsigned nblocksy = util_format_get_nblocksy(template->format, align(template->height0, LP_RASTER_BLOCK_SIZE));
if (whandle->type == WINSYS_HANDLE_TYPE_UNBACKED && whandle->image_stride)
lpr->img_stride[0] = whandle->image_stride;
else
if (whandle->type == WINSYS_HANDLE_TYPE_UNBACKED) {
if (whandle->image_stride) {
lpr->img_stride[0] = whandle->image_stride;
} else {
unsigned nblocksy = util_format_get_nblocksy(template->format,
template->height0);
lpr->img_stride[0] = whandle->stride * nblocksy;
}
} else {
unsigned nblocksy = util_format_get_nblocksy(template->format,
align(template->height0,
LP_RASTER_BLOCK_SIZE));
lpr->img_stride[0] = whandle->stride * nblocksy;
}
lpr->sample_stride = lpr->img_stride[0];
lpr->size_required = lpr->sample_stride;