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 <ria.freelander@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1633>
This commit is contained in:
Konstantin 2023-09-21 16:45:08 +03:00
parent 0525b9a5b9
commit 75f56b7923

View File

@ -37,8 +37,8 @@ glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
int box_index; int box_index;
int bytes_per_pixel = drawable->bitsPerPixel >> 3;
const struct glamor_format *f = glamor_format_for_pixmap(pixmap); 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; char *tmp_bits = NULL;
if (glamor_drawable_effective_depth(drawable) == 24 && pixmap->drawable.depth == 32) 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); PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
int box_index; int box_index;
int bytes_per_pixel = drawable->bitsPerPixel >> 3;
const struct glamor_format *f = glamor_format_for_pixmap(pixmap); 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); glamor_make_current(glamor_priv);