Fix XLibre TearFree rotation, st dirty-rect CPU usage, and SPM deep-sleep wake

This commit is contained in:
Luxferre committed 2026-11-24 20:07:33 +02:00
1 parent dbc0275979
commit 1b93479666
14 files changed
+549 -62

No files matched your search

@@ -1,13 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Geminux Project <dev@geminux.local>
Date: Tue, 24 Nov 2026 10:25:00 +0200
Subject: [PATCH] geminux: skip redundant shadow->front_bo copy and add 16x16 tiled 32bpp rotation
Subject: [PATCH] geminux: CPU TearFree with direct 16x16 tiled rotation and shadow copy skip
---
diff --git a/hw/xfree86/drivers/video/modesetting/driver.c b/hw/xfree86/drivers/video/modesetting/driver.c
--- a/hw/xfree86/drivers/video/modesetting/driver.c
+++ b/hw/xfree86/drivers/video/modesetting/driver.c
@@ -1666,6 +1666,28 @@
@@ -1543,8 +1543,9 @@
if (pScrn->is_gpu) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"TearFree cannot synchronize PRIME; use 'PRIME Synchronization' instead\n");
- } else if (ms->drmmode.glamor_gbm) {
+ } else if (ms->drmmode.glamor_gbm || ms->drmmode.shadow_enable) {
if (!ms->drmmode.pageflip || cap_universal_planes) {
ms->drmmode.tearfree_enable = TRUE;
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "TearFree: enabled\n");
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "TearFree: enabled%s\n",
+ ms->drmmode.glamor_gbm ? "" : " (CPU/ShadowFB)");
} else {
@@ -1666,6 +1667,31 @@
{
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
modesettingPtr ms = modesettingPTR(pScrn);
@@ -15,19 +27,22 @@ diff --git a/hw/xfree86/drivers/video/modesetting/driver.c b/hw/xfree86/drivers/
+
+ if (xf86_config && xf86_config->num_crtc > 0) {
+ int enabled_crtcs = 0;
+ Bool all_rotated = TRUE;
+ Bool all_direct_scanout = TRUE;
+
+ for (int c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+ drmmode_crtc_private_ptr drmmode_crtc;
+ if (!crtc || !crtc->enabled)
+ continue;
+ enabled_crtcs++;
+ if (!crtc->transform_in_use || !crtc->rotatedPixmap) {
+ all_rotated = FALSE;
+ drmmode_crtc = crtc->driver_private;
+ if (!(drmmode_crtc && drmmode_crtc->tearfree.buf[0].px) &&
+ (!crtc->transform_in_use || !crtc->rotatedPixmap)) {
+ all_direct_scanout = FALSE;
+ break;
+ }
+ }
+ if (enabled_crtcs > 0 && all_rotated) {
+ if (enabled_crtcs > 0 && all_direct_scanout) {
+ DamageEmpty(pBuf->pDamage);
+ return;
+ }
@@ -36,6 +51,77 @@ diff --git a/hw/xfree86/drivers/video/modesetting/driver.c b/hw/xfree86/drivers/
bool use_3224 = ms->drmmode.force_24_32 && pScrn->bitsPerPixel == 32;
if (ms->drmmode.shadow_enable2 && ms->drmmode.shadow_fb2) do {
diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.c b/hw/xfree86/drivers/video/modesetting/drmmode_display.c
--- a/hw/xfree86/drivers/video/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.c
@@ -1429,19 +1429,24 @@
/* Copy the screen's pixmap into the destination pixmap */
if (crtc->rotatedPixmap) {
src = &crtc->rotatedPixmap->drawable;
xf86RotateCrtcRedisplay(crtc, dst, src, dmg, FALSE);
+ } else if ((crtc->driverIsPerformingTransform & XF86DriverTransformOutput) &&
+ crtc->transform_in_use) {
+ src = &pScreen->GetScreenPixmap(pScreen)->drawable;
+ xf86RotateCrtcRedisplay(crtc, dst, src, dmg, TRUE);
} else {
src = &pScreen->GetScreenPixmap(pScreen)->drawable;
PixmapDirtyCopyArea(dst, src, 0, 0, -crtc->x, -crtc->y, dmg);
}
/* Reset the damages if requested */
if (empty)
RegionEmpty(dmg);
#ifdef GLAMOR
/* Wait until the GC operations finish */
- modesettingPTR(crtc->scrn)->glamor.finish(pScreen);
+ if (modesettingPTR(crtc->scrn)->drmmode.glamor_gbm)
+ modesettingPTR(crtc->scrn)->glamor.finish(pScreen);
#endif
}
@@ -1582,7 +1587,9 @@
crtc->x = x;
crtc->y = y;
crtc->rotation = rotation;
+ if (drmmode->tearfree_enable)
+ crtc->driverIsPerformingTransform |= XF86DriverTransformOutput;
if (!xf86CrtcRotate(crtc)) {
goto done;
}
@@ -2863,6 +2870,8 @@
drmmode_crtc->vblank_pipe = drmmode_crtc_vblank_pipe(num);
xorg_list_init(&drmmode_crtc->mode_list);
xorg_list_init(&drmmode_crtc->tearfree.dri_flip_list);
drmmode_crtc->next_msc = UINT64_MAX;
+ if (drmmode->tearfree_enable)
+ crtc->driverIsPerformingTransform |= XF86DriverTransformOutput;
/* Setup the fallback cursor immediately. */
@@ -4324,7 +4333,9 @@
crtc->mode = crtc->desiredMode;
crtc->rotation = crtc->desiredRotation;
crtc->x = crtc->desiredX;
crtc->y = crtc->desiredY;
+ if (drmmode->tearfree_enable)
+ crtc->driverIsPerformingTransform |= XF86DriverTransformOutput;
if (!xf86CrtcRotate(crtc))
return FALSE;
}
diff --git a/hw/xfree86/drivers/video/modesetting/pageflip.c b/hw/xfree86/drivers/video/modesetting/pageflip.c
--- a/hw/xfree86/drivers/video/modesetting/pageflip.c
+++ b/hw/xfree86/drivers/video/modesetting/pageflip.c
@@ -414,6 +414,9 @@
return TRUE;
}
+ if (!ms->drmmode.glamor_gbm)
+ goto error_free_event;
+
ms->glamor.block_handler(screen);
new_front_bo = ms->glamor.gbm_bo_from_pixmap(screen, new_front);
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -222,8 +308,10 @@ diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
void
xf86RotateCrtcRedisplay(xf86CrtcPtr crtc, PixmapPtr dst_pixmap,
DrawableRec *src_drawable, RegionPtr region,
@@ -57,6 +226,10 @@
if (crtc->driverIsPerformingTransform & XF86DriverTransformOutput)
@@ -57,6 +226,11 @@
- if (crtc->driverIsPerformingTransform & XF86DriverTransformOutput)
+ if ((crtc->driverIsPerformingTransform & XF86DriverTransformOutput) &&
+ (!dst_pixmap || dst_pixmap == crtc->rotatedPixmap))
return;
+ if (xf86RotateTryFast32(crtc, dst_pixmap, src_drawable, region,