Mesa (staging/22.1): egl/x11: split large put image requests to avoid server destroy

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 23 16:19:37 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 350afae947cab4c563dc845a3d69e5027a6a7be7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=350afae947cab4c563dc845a3d69e5027a6a7be7

Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Jun 21 10:59:32 2022 +1000

egl/x11: split large put image requests to avoid server destroy

wezterm in fullscreen 4k was exceeding the xcb max request size
on the put image with llvmpipe. This fixes it to send sub-images,
the Xlib put image used in glx does this internally, but not
the xcb one, so just do it in sections here.

Cc: mesa-stable
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17155>
(cherry picked from commit e6082ac62e8aa5922820b219103659c3c4f2f53f)

---

 .pick_status.json                   |  2 +-
 src/egl/drivers/dri2/platform_x11.c | 24 +++++++++++++++++++++---
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index e7733577739..0ac9602bfb4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -634,7 +634,7 @@
         "description": "egl/x11: split large put image requests to avoid server destroy",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index adccc309077..e9a22ba7cfc 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -153,6 +153,10 @@ swrastPutImage(__DRIdrawable * draw, int op,
 {
    struct dri2_egl_surface *dri2_surf = loaderPrivate;
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display);
+   size_t hdr_len = sizeof(xcb_put_image_request_t);
+   int stride_b = dri2_surf->bytes_per_pixel * w;
+   size_t size = (hdr_len + stride_b * h) >> 2;
+   uint64_t max_req_len = xcb_get_maximum_request_length(dri2_dpy->conn);
 
    xcb_gcontext_t gc;
 
@@ -167,9 +171,23 @@ swrastPutImage(__DRIdrawable * draw, int op,
       return;
    }
 
-   xcb_put_image(dri2_dpy->conn, XCB_IMAGE_FORMAT_Z_PIXMAP, dri2_surf->drawable,
-                 gc, w, h, x, y, 0, dri2_surf->depth,
-                 w*h*dri2_surf->bytes_per_pixel, (const uint8_t *)data);
+   if (size < max_req_len) {
+      xcb_put_image(dri2_dpy->conn, XCB_IMAGE_FORMAT_Z_PIXMAP, dri2_surf->drawable,
+                    gc, w, h, x, y, 0, dri2_surf->depth,
+                    h * stride_b, (const uint8_t *)data);
+   } else {
+      int num_lines = ((max_req_len << 2) - hdr_len) / stride_b;
+      int y_start = 0;
+      int y_todo = h;
+      while (y_todo) {
+         int this_lines = MIN2(num_lines, y_todo);
+         xcb_put_image(dri2_dpy->conn, XCB_IMAGE_FORMAT_Z_PIXMAP, dri2_surf->drawable,
+                       gc, w, this_lines, x, y_start, 0, dri2_surf->depth,
+                       this_lines * stride_b, ((const uint8_t *)data + y_start * stride_b));
+         y_start += this_lines;
+         y_todo -= this_lines;
+      }
+   }
 }
 
 static void



More information about the mesa-commit mailing list