[PATCH] modesetting: prefer primary crtc when picking over nothing

Dave Airlie airlied at gmail.com
Wed Aug 3 00:24:03 UTC 2016


So we had a bug report that epiphany was rendering slow on
modesetting + DRI3, that I tracked down to the fact it was
rendering offscreen to a single buffer. However due to this
rendering being offscreen we were getting the fake crtc
chosen by the X server as the window didn't overlap any
active CRTCs.

This didn't happen on amdgpu and I ported this patch across,
but I believe this only fixed this problem by accident,
it always picks the primary crtc when it needs one.

But this fixes it here for me, the question is whether
we should do better at picking the fake crtc and whether
we should be throttling things.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85064
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/drivers/modesetting/vblank.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c
index 77e0848..0f28f9d 100644
--- a/hw/xfree86/drivers/modesetting/vblank.c
+++ b/hw/xfree86/drivers/modesetting/vblank.c
@@ -102,17 +102,26 @@ ms_covering_crtc(ScrnInfoPtr scrn,
                  BoxPtr box, xf86CrtcPtr desired, BoxPtr crtc_box_ret)
 {
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-    xf86CrtcPtr crtc, best_crtc;
+    xf86CrtcPtr crtc, best_crtc = NULL, primary_crtc = NULL;
     int coverage, best_coverage;
     int c;
     BoxRec crtc_box, cover_box;
+    RROutputPtr primary_output = NULL;
 
-    best_crtc = NULL;
     best_coverage = 0;
     crtc_box_ret->x1 = 0;
     crtc_box_ret->x2 = 0;
     crtc_box_ret->y1 = 0;
     crtc_box_ret->y2 = 0;
+
+    /* Prefer the CRTC of the primary output */
+    if (dixPrivateKeyRegistered(rrPrivKey))
+    {
+        primary_output = RRFirstOutput(scrn->pScreen);
+    }
+    if (primary_output && primary_output->crtc)
+        primary_crtc = primary_output->crtc->devPrivate;
+
     for (c = 0; c < xf86_config->num_crtc; c++) {
         crtc = xf86_config->crtc[c];
 
@@ -127,7 +136,9 @@ ms_covering_crtc(ScrnInfoPtr scrn,
             *crtc_box_ret = crtc_box;
             return crtc;
         }
-        if (coverage > best_coverage) {
+        if (coverage > best_coverage ||
+            (coverage == best_coverage &&
+             crtc == primary_crtc)) {
             *crtc_box_ret = crtc_box;
             best_crtc = crtc;
             best_coverage = coverage;
-- 
2.7.4



More information about the xorg-devel mailing list