From 8d04be2b856c9330178ddd6ab20848c58fada3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 25 Apr 2026 08:23:47 +0200 Subject: [PATCH] mp_image: force stride to be multiple of bpp Vulkan require all sizes in texels, so we have to make our image multiple of them. Fixes: #17743 --- video/mp_image.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/video/mp_image.c b/video/mp_image.c index f73f44a1d3..8003b06d45 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -68,7 +68,8 @@ static int mp_image_layout(int imgfmt, int w, int h, int stride_align, int alloc_w = mp_chroma_div_up(w, desc.xs[n]); int alloc_h = MP_ALIGN_UP(h, 32) >> desc.ys[n]; int line_bytes = (alloc_w * desc.bpp[n] + 7) / 8; - out_stride[n] = MP_ALIGN_NPOT(line_bytes, stride_align); + int align = mp_lcm(stride_align, (desc.bpp[n] && desc.bpp[n] % 8 == 0) ? desc.bpp[n] / 8 : 1); + out_stride[n] = MP_ALIGN_NPOT(line_bytes, align); out_plane_size[n] = out_stride[n] * alloc_h; } if (desc.flags & MP_IMGFLAG_PAL)