Mesa (mesa_7_7_branch): st/xorg: render throttling in block handler

Keith Whitwell keithw at kemper.freedesktop.org
Thu Nov 26 11:58:44 UTC 2009


Module: Mesa
Branch: mesa_7_7_branch
Commit: 7b0e4adaf21d4c788657eff41cb51d5c89647309
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b0e4adaf21d4c788657eff41cb51d5c89647309

Author: Keith Whitwell <keithw at vmware.com>
Date:   Thu Nov 26 11:55:47 2009 +0000

st/xorg: render throttling in block handler

Similar to the classic swapbuffer throttling in GL drivers, put an
upper bound on the number of outstanding chunks of rendering the state
tracker can generate -- where calling the block handler denotes a
chunk.

Currently that number is set at around 4 "chunks", but could be
tweaked up or down.  If a better measure for the amount of outstanding
rendering is found, that would be fine too.

As it stands, this improves interactivity by preventing the X server
from queueing up arbitary amounts of rendering.

---

 src/gallium/state_trackers/xorg/xorg_driver.c   |   20 ++++++++++++++++++--
 src/gallium/state_trackers/xorg/xorg_renderer.c |    5 -----
 src/gallium/state_trackers/xorg/xorg_tracker.h  |    4 ++++
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index c74fb28..4c66354 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -450,8 +450,24 @@ static void drv_block_handler(int i, pointer blockData, pointer pTimeout,
     pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
     pScreen->BlockHandler = drv_block_handler;
 
-    if (ms->ctx)
-	ms->ctx->flush(ms->ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
+    if (ms->ctx) {
+       int j;
+
+       ms->ctx->flush(ms->ctx, PIPE_FLUSH_RENDER_CACHE, &ms->fence[XORG_NR_FENCES-1]);
+       
+       if (ms->fence[0])
+          ms->ctx->screen->fence_finish(ms->ctx->screen, ms->fence[0], 0);
+  
+       /* The amount of rendering generated by a block handler can be
+        * quite small.  Let us get a fair way ahead of hardware before
+        * throttling.
+        */
+       for (j = 0; j < XORG_NR_FENCES; j++)
+          ms->screen->fence_reference(ms->screen,
+                                      &ms->fence[j],
+                                      ms->fence[j+1]);
+    }
+        
 
 #ifdef DRM_MODE_FEATURE_DIRTYFB
     {
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index 16ac5d2..d9698e3 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -13,11 +13,6 @@
 
 #include <math.h>
 
-enum AxisOrientation {
-   Y0_BOTTOM,
-   Y0_TOP
-};
-
 #define floatsEqual(x, y) (fabs(x - y) <= 0.00001f * MIN2(fabs(x), fabs(y)))
 #define floatIsZero(x) (floatsEqual((x) + 1, 1))
 
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
index 31e11b4..c6c7b2f 100644
--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -63,6 +63,8 @@ typedef struct
     ScrnInfoPtr pScrn_2;
 } EntRec, *EntPtr;
 
+#define XORG_NR_FENCES 3
+
 typedef struct _modesettingRec
 {
     /* drm */
@@ -86,6 +88,8 @@ typedef struct _modesettingRec
     unsigned int SaveGeneration;
 
     void (*blockHandler)(int, pointer, pointer, pointer);
+    struct pipe_fence_handle *fence[XORG_NR_FENCES];
+
     CreateScreenResourcesProcPtr createScreenResources;
 
     /* for frontbuffer backing store */




More information about the mesa-commit mailing list