xserver: Branch 'master' - 3 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 5 07:48:22 UTC 2024


 glamor/glamor_transfer.c |    4 +--
 glamor/glamor_xv.c       |   52 +++++++++++++++++++++++++++++------------------
 2 files changed, 35 insertions(+), 21 deletions(-)

New commits:
commit 39c8a6f367154b1110a1e6845566a3388be4f90e
Author: Nicolas Dufresne <nicolas.dufresne at collabora.com>
Date:   Tue Jul 30 15:53:25 2024 -0400

    glamor: xv: Rewrite UYVY shader to match NV12/I420 CSC
    
    This rewrites the shader so that we use the same (more flexible) CSC as
    we have for I420 and NV12. This also fixes the reverse of odd/even which
    caused chroma shift.
    
    Signed-off-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1633>

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index d4e7ced69..328769ab1 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -141,24 +141,22 @@ static const glamor_facet glamor_facet_xv_uyvy = {
                 "in vec2 tcs;\n"
                 ),
     .fs_exec = (
-        "    vec3 uyv;\n"
-        "    vec4 frameOut = texture2D(sampler, tcs.st);\n"
-        "\n"
-        "    vec4 prevPixel = texture2D(sampler, vec2(tcs.s - texelSize.x, tcs.t));\n"
-        "    vec4 nextPixel = texture2D(sampler, vec2(tcs.s + texelSize.x, tcs.t));\n"
-        "\n"
-        "    float delta = 0.50;\n"
-        "\n"
-        "    int even = int(mod(tcs.x / texelSize.x, 2.0));\n"
-        "\n"
-        "    uyv.rgb = float(even)*vec3(frameOut.rg, nextPixel.r) + (1.0-float(even))*vec3(prevPixel.r, frameOut.gr);\n"
-        "\n"
-        "    frameOut.r = uyv.g + 1.403*(uyv.r - delta);\n"
-        "    frameOut.g = uyv.g - 0.714*(uyv.r - delta) - 0.344*(uyv.b - delta);\n"
-        "    frameOut.b = uyv.g + 1.773*(uyv.b - delta);\n"
-        "    frameOut.a = 1.0;\n"
-        "    frag_color = frameOut;\n"
-        ),
+                "        vec4 temp1;\n"
+                "        vec2 xy = texture(sampler, tcs.st).xy;\n"
+                "        vec2 prev_xy = texture(sampler, vec2(tcs.s - texelSize.x, tcs.t)).xy;\n"
+                "        vec2 next_xy = texture(sampler, vec2(tcs.s + texelSize.x, tcs.t)).xy;\n"
+                "\n"
+                "        vec3 sample_yuv;\n"
+                "        int odd = int(mod(tcs.x / texelSize.x, 2.0));\n"
+                "        int even = 1 - odd;\n"
+                "        sample_yuv.yxz = float(even)*vec3(xy, next_xy.x) + float(odd)*vec3(prev_xy.x, xy.yx);\n"
+                "\n"
+                "        temp1.xyz = offsetyco.www * vec3(sample_yuv.x) + offsetyco.xyz;\n"
+                "        temp1.xyz = ucogamma.xyz * vec3(sample_yuv.y) + temp1.xyz;\n"
+                "        temp1.xyz = clamp(vco.xyz * vec3(sample_yuv.z) + temp1.xyz, 0.0, 1.0);\n"
+                "        temp1.w = 1.0;\n"
+                "        frag_color = temp1;\n"
+                ),
 };
 
 static const glamor_facet glamor_facet_xv_rgb_raw = {
commit eb26f3236804389f2006388936322dc8115d00e0
Author: Konstantin <ria.freelander at gmail.com>
Date:   Wed Jul 31 11:12:38 2024 +0300

    glamor: xv: fix UYVY alignment
    
    UYVY videos should be aligned by 2 to avoid breakups in the shader
    
    Fixes: 832b392f7 - glamor: xv: enable UYVY acceleration
    Suggested-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>
    Signed-off-by: Konstantin <ria.freelander at gmail.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1633>

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 40b9ca4ea..d4e7ced69 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -379,9 +379,16 @@ glamor_xv_query_image_attributes(int id,
             offsets[0] = 0;
         size *= *h;
         break;
-    case FOURCC_RGB565:
     case FOURCC_UYVY:
         /* UYVU is single-plane really, all tranformation is processed inside a shader */
+        size = ALIGN(*w, 2) * 2;
+        if (pitches)
+            pitches[0] = size;
+        if (offsets)
+            offsets[0] = 0;
+        size *= *h;
+        break;
+    case FOURCC_RGB565:
         size = *w * 2;
         if (pitches)
             pitches[0] = size;
@@ -787,6 +794,15 @@ glamor_xv_put_image(glamor_port_private *port_priv,
                             buf + s2offset, srcPitch);
         break;
     case FOURCC_UYVY:
+        srcPitch = ALIGN(width, 2) * 2;
+        full_box.x1 = 0;
+        full_box.y1 = 0;
+        full_box.x2 = width;
+        full_box.y2 = height;
+        glamor_upload_boxes(&port_priv->src_pix[0]->drawable, &full_box, 1,
+                            0, 0, 0, 0,
+                            buf, srcPitch);
+        break;
     case FOURCC_RGB565:
         srcPitch = width * 2;
         full_box.x1 = 0;
commit 75f56b79234bf428455fa0bef741a86fc5919889
Author: Konstantin <ria.freelander at gmail.com>
Date:   Thu Sep 21 16:45:08 2023 +0300

    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 at gmail.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1633>

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);
 


More information about the xorg-commit mailing list