From 75f56b79234bf428455fa0bef741a86fc5919889 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 21 Sep 2023 16:45:08 +0300 Subject: [PATCH] glamor: check BPP by render_format. Check actual BPP by render_format in upload_boxes, not by drawable BPP. It is required when we used different BPP formats for storing and rendering (for example, in the case of UYVY). The problem of UYVY size lies inside method of glamor downloading boxes. When we set GLAMOR_CREATE_FORMAT_CBCR, it actually uses 16-bit GL and Pixman formats, but before this change in glamor_download_boxes, that function deduces GL and Pixman formats from BPP, which is wrong in this case (will be deduced to 32). When GL and Pixman format BPP is identical to drawable BPP, this change does nothing, but when it is different - it will prioritize Pixman format, not the format deduced from BPP. Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1730 Signed-off-by: Konstantin Pugin Part-of: --- glamor/glamor_transfer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c index eefeb552b..9efb505f0 100644 --- a/glamor/glamor_transfer.c +++ b/glamor/glamor_transfer.c @@ -37,8 +37,8 @@ glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox, PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); int box_index; - int bytes_per_pixel = drawable->bitsPerPixel >> 3; const struct glamor_format *f = glamor_format_for_pixmap(pixmap); + int bytes_per_pixel = PICT_FORMAT_BPP(f->render_format) >> 3; char *tmp_bits = NULL; if (glamor_drawable_effective_depth(drawable) == 24 && pixmap->drawable.depth == 32) @@ -145,8 +145,8 @@ glamor_download_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox, PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); int box_index; - int bytes_per_pixel = drawable->bitsPerPixel >> 3; const struct glamor_format *f = glamor_format_for_pixmap(pixmap); + int bytes_per_pixel = PICT_FORMAT_BPP(f->render_format) >> 3; glamor_make_current(glamor_priv);