From 1c798434636ce0bd5d8bca408d31427017603335 Mon Sep 17 00:00:00 2001 From: Jocelyn Falempe Date: Tue, 6 Jan 2026 15:54:22 +0100 Subject: [PATCH] Fix performance regression with Xorg Add 0001-drisw-Modify-drisw_swap_buffers_with_damage-to-swap-.patch Add 0002-Revert-drisw-Copy-entire-buffer-ignoring-damage-regi.patch Resolves: https://issues.redhat.com/browse/RHEL-105157 --- ...sw_swap_buffers_with_damage-to-swap-.patch | 74 +++++++++++++++++++ ...y-entire-buffer-ignoring-damage-regi.patch | 72 ++++++++++++++++++ mesa.spec | 9 ++- 3 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 0001-drisw-Modify-drisw_swap_buffers_with_damage-to-swap-.patch create mode 100644 0002-Revert-drisw-Copy-entire-buffer-ignoring-damage-regi.patch diff --git a/0001-drisw-Modify-drisw_swap_buffers_with_damage-to-swap-.patch b/0001-drisw-Modify-drisw_swap_buffers_with_damage-to-swap-.patch new file mode 100644 index 0000000..02281ab --- /dev/null +++ b/0001-drisw-Modify-drisw_swap_buffers_with_damage-to-swap-.patch @@ -0,0 +1,74 @@ +From 17ab0f2ece0a45dd5df507a466ecf6f40d452e1a Mon Sep 17 00:00:00 2001 +From: Lucas Fryzek +Date: Wed, 3 Dec 2025 19:33:57 -0500 +Subject: [PATCH 1/2] drisw: Modify drisw_swap_buffers_with_damage to swap + entire buffer + +When swapping buffer with damage regions, to be strictly correct we +need to swap the entire back buffer to the front buffer. This needs to +be done in case the compositor does not support damage regions. This +means we need to ignore the input damage region and tell drisw to swap +the entire buffer. + +Cc: mesa-stable +Part-of: +--- + src/gallium/frontends/dri/drisw.c | 28 ++++++++-------------------- + 1 file changed, 8 insertions(+), 20 deletions(-) + +diff --git a/src/gallium/frontends/dri/drisw.c b/src/gallium/frontends/dri/drisw.c +index 4359ca569e5..394b6986832 100644 +--- a/src/gallium/frontends/dri/drisw.c ++++ b/src/gallium/frontends/dri/drisw.c +@@ -225,6 +225,13 @@ drisw_copy_to_front(struct pipe_context *pipe, + static void + drisw_swap_buffers_with_damage(struct dri_drawable *drawable, int nrects, const int *rects) + { ++ /* Damage regions still require us to update the whole front buffer ++ * in case the compositor doesn't obey them, so we will just ignore ++ * the passed in damage regions and swap the whole buffer ++ */ ++ (void)nrects; ++ (void)rects; ++ + struct dri_context *ctx = dri_get_current(); + struct dri_screen *screen = drawable->screen; + struct pipe_resource *ptex; +@@ -242,25 +249,6 @@ drisw_swap_buffers_with_damage(struct dri_drawable *drawable, int nrects, const + if (ptex) { + struct pipe_fence_handle *fence = NULL; + +- struct pipe_box stack_boxes[64]; +- if (nrects > ARRAY_SIZE(stack_boxes)) +- nrects = 0; +- if (nrects) { +- for (unsigned int i = 0; i < nrects; i++) { +- const int *rect = &rects[i * 4]; +- +- int w = MIN2(rect[2], ptex->width0); +- int h = MIN2(rect[3], ptex->height0); +- int x = CLAMP(rect[0], 0, ptex->width0); +- int y = CLAMP(ptex->height0 - rect[1] - h, 0, ptex->height0); +- +- if (h > ptex->height0 - y) +- h = ptex->height0 - y; +- +- u_box_2d(x, y, w, h, &stack_boxes[i]); +- } +- } +- + if (ctx->pp) + pp_run(ctx->pp, ptex, ptex, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]); + +@@ -279,7 +267,7 @@ drisw_swap_buffers_with_damage(struct dri_drawable *drawable, int nrects, const + screen->base.screen->fence_finish(screen->base.screen, ctx->st->pipe, + fence, OS_TIMEOUT_INFINITE); + screen->base.screen->fence_reference(screen->base.screen, &fence, NULL); +- drisw_copy_to_front(ctx->st->pipe, drawable, ptex, nrects, nrects ? stack_boxes : NULL); ++ drisw_copy_to_front(ctx->st->pipe, drawable, ptex, 0, NULL); + drawable->buffer_age = 1; + + /* TODO: remove this if the framebuffer state doesn't change. */ +-- +2.52.0 + diff --git a/0002-Revert-drisw-Copy-entire-buffer-ignoring-damage-regi.patch b/0002-Revert-drisw-Copy-entire-buffer-ignoring-damage-regi.patch new file mode 100644 index 0000000..a0384e1 --- /dev/null +++ b/0002-Revert-drisw-Copy-entire-buffer-ignoring-damage-regi.patch @@ -0,0 +1,72 @@ +From 48799005d7f3b099cb2e93d09ce6dc211f619887 Mon Sep 17 00:00:00 2001 +From: Lucas Fryzek +Date: Wed, 3 Dec 2025 19:19:56 -0500 +Subject: [PATCH 2/2] Revert "drisw: Copy entire buffer ignoring damage + regions" + +This reverts commit 755e795e4c0d2660129c14998425f7dd3299bdf9. + +Cc: mesa-stable +Part-of: +--- + src/gallium/winsys/sw/dri/dri_sw_winsys.c | 38 +++++++++++++++++------ + 1 file changed, 29 insertions(+), 9 deletions(-) + +diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c +index 7d18b6138ea..0b2c8754ec5 100644 +--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c ++++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c +@@ -352,21 +352,41 @@ dri_sw_displaytarget_display(struct sw_winsys *ws, + struct dri_sw_winsys *dri_sw_ws = dri_sw_winsys(ws); + struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt); + struct dri_drawable *dri_drawable = (struct dri_drawable *)context_private; +- unsigned width, height; ++ unsigned width, height, x = 0, y = 0; + unsigned blsize = util_format_get_blocksize(dri_sw_dt->format); + bool is_shm = dri_sw_dt->shmid != -1; + /* Set the width to 'stride / cpp'. + * + * PutImage correctly clips to the width of the dst drawable. + */ +- width = dri_sw_dt->stride / blsize; +- height = dri_sw_dt->height; +- if (is_shm) +- dri_sw_ws->lf->put_image_shm(dri_drawable, dri_sw_dt->shmid, dri_sw_dt->data, 0, 0, +- 0, 0, width, height, dri_sw_dt->stride); +- else +- dri_sw_ws->lf->put_image(dri_drawable, dri_sw_dt->data, width, height); +- return; ++ if (!nboxes) { ++ width = dri_sw_dt->stride / blsize; ++ height = dri_sw_dt->height; ++ if (is_shm) ++ dri_sw_ws->lf->put_image_shm(dri_drawable, dri_sw_dt->shmid, dri_sw_dt->data, 0, 0, ++ 0, 0, width, height, dri_sw_dt->stride); ++ else ++ dri_sw_ws->lf->put_image(dri_drawable, dri_sw_dt->data, width, height); ++ return; ++ } ++ for (unsigned i = 0; i < nboxes; i++) { ++ unsigned offset = dri_sw_dt->stride * box[i].y; ++ unsigned offset_x = box[i].x * blsize; ++ char *data = dri_sw_dt->data + offset; ++ x = box[i].x; ++ y = box[i].y; ++ width = box[i].width; ++ height = box[i].height; ++ if (is_shm) { ++ /* don't add x offset for shm, the put_image_shm will deal with it */ ++ dri_sw_ws->lf->put_image_shm(dri_drawable, dri_sw_dt->shmid, dri_sw_dt->data, offset, offset_x, ++ x, y, width, height, dri_sw_dt->stride); ++ } else { ++ data += offset_x; ++ dri_sw_ws->lf->put_image2(dri_drawable, data, ++ x, y, width, height, dri_sw_dt->stride); ++ } ++ } + } + + static void +-- +2.52.0 + diff --git a/mesa.spec b/mesa.spec index ac2ec31..bacd53e 100644 --- a/mesa.spec +++ b/mesa.spec @@ -82,7 +82,7 @@ Name: mesa Summary: Mesa graphics libraries %global ver 25.2.7 Version: %{lua:ver = string.gsub(rpm.expand("%{ver}"), "-", "~"); print(ver)} -Release: 1%{?dist} +Release: 2%{?dist} License: MIT AND BSD-3-Clause AND SGI-B-2.0 URL: http://www.mesa3d.org @@ -144,6 +144,10 @@ Source15: https://crates.io/api/v1/crates/rustc-hash/%{rustc_hash_ver}/dow Patch11: 0001-device-select-add-a-layer-setting-to-disable-device-.patch Patch12: 0002-zink-use-device-select-layer-settings-to-disable-dev.patch +# Fix performance issue with Xorg +Patch21: 0001-drisw-Modify-drisw_swap_buffers_with_damage-to-swap-.patch +Patch22: 0002-Revert-drisw-Copy-entire-buffer-ignoring-damage-regi.patch + BuildRequires: meson BuildRequires: gcc BuildRequires: gcc-c++ @@ -878,6 +882,9 @@ popd %endif %changelog +* Tue Jan 6 2026 Jocelyn Falempe - 25.2.7-1 - Resolves: https://issues.redhat.com/browse/RHEL-132415