st/xorg: Add a function to flush pending rendering and damage
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 24 Nov 2010 14:15:42 +0000 (15:15 +0100)
committerThomas Hellstrom <thellstrom@vmware.com>
Wed, 24 Nov 2010 14:23:10 +0000 (15:23 +0100)
This is needed to properly sync with host side rendering. For example,
make sure we flush colorkey painting before updating the overlay.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
src/gallium/state_trackers/xorg/xorg_driver.c
src/gallium/state_trackers/xorg/xorg_tracker.h

index 1ee79ae177e72bd9e73f6075ad63c3ebdad1039f..66685ecec646649313f617518c0bb9e8b7780899 100644 (file)
@@ -538,44 +538,37 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags)
     return TRUE;
 }
 
-static void drv_block_handler(int i, pointer blockData, pointer pTimeout,
-                              pointer pReadmask)
+void xorg_flush(ScreenPtr pScreen)
 {
-    ScreenPtr pScreen = screenInfo.screens[i];
     modesettingPtr ms = modesettingPTR(xf86Screens[pScreen->myNum]);
 
-    pScreen->BlockHandler = ms->blockHandler;
-    pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
-    pScreen->BlockHandler = drv_block_handler;
-
     if (ms->ctx) {
-       int j;
+       int j;
 
-       ms->ctx->flush(ms->ctx, PIPE_FLUSH_RENDER_CACHE,
-                     ms->dirtyThrottling ?
-                     &ms->fence[XORG_NR_FENCES-1] :
-                     NULL);
+       ms->ctx->flush(ms->ctx, PIPE_FLUSH_RENDER_CACHE,
+                      ms->dirtyThrottling ?
+                      &ms->fence[XORG_NR_FENCES-1] :
+                      NULL);
        
-       if (ms->dirtyThrottling) {
-          if (ms->fence[0])
-              ms->ctx->screen->fence_finish(ms->ctx->screen,
-                                            ms->fence[0], 0);
+       if (ms->dirtyThrottling) {
+           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 - 1; j++)
-              ms->screen->fence_reference(ms->screen,
-                                          &ms->fence[j],
-                                          ms->fence[j+1]);
-
-          ms->screen->fence_reference(ms->screen,
-                                      &ms->fence[XORG_NR_FENCES-1],
-                                      NULL);
-       }
+           /* 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 - 1; j++)
+               ms->screen->fence_reference(ms->screen,
+                                           &ms->fence[j],
+                                           ms->fence[j+1]);
+
+           ms->screen->fence_reference(ms->screen,
+                                       &ms->fence[XORG_NR_FENCES-1],
+                                       NULL);
+       }
     }
-        
 
 #ifdef DRM_MODE_FEATURE_DIRTYFB
     {
@@ -608,6 +601,19 @@ static void drv_block_handler(int i, pointer blockData, pointer pTimeout,
 #endif
 }
 
+static void drv_block_handler(int i, pointer blockData, pointer pTimeout,
+                              pointer pReadmask)
+{
+    ScreenPtr pScreen = screenInfo.screens[i];
+    modesettingPtr ms = modesettingPTR(xf86Screens[pScreen->myNum]);
+
+    pScreen->BlockHandler = ms->blockHandler;
+    pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
+    pScreen->BlockHandler = drv_block_handler;
+
+    xorg_flush(pScreen);
+}
+
 static Bool
 drv_create_screen_resources(ScreenPtr pScreen)
 {
index a3fb5e5dad0551402147dbc218fd55d84f91ac60..56397b8fea8c331652c77ec6bb9026fc5b8ccda6 100644 (file)
@@ -156,6 +156,7 @@ CustomizerPtr xorg_customizer(ScrnInfoPtr pScrn);
 
 Bool xorg_has_gallium(ScrnInfoPtr pScrn);
 
+void xorg_flush(ScreenPtr pScreen);
 /***********************************************************************
  * xorg_exa.c
  */