From eccd9df74958f8aadfd31f4eb0f437c39c3be468 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Sun, 15 Mar 2026 17:10:25 +0100 Subject: [PATCH] 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 (cherry picked from commit 0bbc26d2c4794c4427f311efc57d6141ea6056cc) Part-of: --- .pick_status.json | 2 +- src/gallium/drivers/llvmpipe/lp_texture.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 232c8be4872..6d9542f9eed 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 08d73d3be3d..2d19021f8eb 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -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;