Mesa (staging/22.1): wsi/x11: add xcb_put_image support for larger transfers.

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


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Jun 22 05:53:52 2022 +1000

wsi/x11: add xcb_put_image support for larger transfers.

This was noticed as a problem in the EGL code, just fixup wsi.

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

---

 .pick_status.json               |  2 +-
 src/vulkan/wsi/wsi_common_x11.c | 43 ++++++++++++++++++++++++++++++++---------
 2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 6bd1354ff03..0681c714761 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -616,7 +616,7 @@
         "description": "wsi/x11: add xcb_put_image support for larger transfers.",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 2860ff3eb06..8bcfab852a4 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -1269,21 +1269,46 @@ x11_present_to_x11_sw(struct x11_swapchain *chain, uint32_t image_index,
 
    xcb_void_cookie_t cookie;
    void *myptr;
+   size_t hdr_len = sizeof(xcb_put_image_request_t);
+   int stride_b = image->base.row_pitches[0];
+   size_t size = (hdr_len + stride_b * chain->extent.height) >> 2;
+   uint64_t max_req_len = xcb_get_maximum_request_length(chain->conn);
+
    chain->base.wsi->MapMemory(chain->base.device,
                               image->base.memory,
                               0, 0, 0, &myptr);
 
-   cookie = xcb_put_image(chain->conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
-                          chain->window,
-                          chain->gc,
-			  image->base.row_pitches[0] / 4,
-                          chain->extent.height,
-                          0,0,0,24,
-                          image->base.row_pitches[0] * chain->extent.height,
-                          myptr);
+   if (size < max_req_len) {
+      cookie = xcb_put_image(chain->conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
+                             chain->window,
+                             chain->gc,
+                             image->base.row_pitches[0] / 4,
+                             chain->extent.height,
+                             0,0,0,24,
+                             image->base.row_pitches[0] * chain->extent.height,
+                             myptr);
+      xcb_discard_reply(chain->conn, cookie.sequence);
+   } else {
+      int num_lines = ((max_req_len << 2) - hdr_len) / stride_b;
+      int y_start = 0;
+      int y_todo = chain->extent.height;
+      while (y_todo) {
+         int this_lines = MIN2(num_lines, y_todo);
+         cookie = xcb_put_image(chain->conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
+                                chain->window,
+                                chain->gc,
+                                image->base.row_pitches[0] / 4,
+                                this_lines,
+                                0,y_start,0,24,
+                                this_lines * stride_b,
+                                (const uint8_t *)myptr + (y_start * stride_b));
+         xcb_discard_reply(chain->conn, cookie.sequence);
+         y_start += this_lines;
+         y_todo -= this_lines;
+      }
+   }
 
    chain->base.wsi->UnmapMemory(chain->base.device, image->base.memory);
-   xcb_discard_reply(chain->conn, cookie.sequence);
    xcb_flush(chain->conn);
    return x11_swapchain_result(chain, VK_SUCCESS);
 }



More information about the mesa-commit mailing list