[2/5] st/dri: flush before throttling in SwapBuffers

Submitted by Marek Olšák on April 23, 2019, 1:29 a.m.

Details

Message ID 20190423012947.30976-2-maraeo@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Marek Olšák April 23, 2019, 1:29 a.m.
From: Marek Olšák <marek.olsak@amd.com>

for better CPU-GPU parallelism
---
 src/gallium/state_trackers/dri/dri_drawable.c | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index 26bfdbecc53..c1de3bed9dd 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -555,33 +555,33 @@  dri_flush(__DRIcontext *cPriv,
        *
        * This pulls a fence off the throttling queue and waits for it if the
        * number of fences on the throttling queue has reached the desired
        * number.
        *
        * Then flushes to insert a fence at the current rendering position, and
        * pushes that fence on the queue. This requires that the st_context_iface
        * flush method returns a fence even if there are no commands to flush.
        */
       struct pipe_screen *screen = drawable->screen->base.screen;
-      struct pipe_fence_handle *fence;
+      struct pipe_fence_handle *oldest_fence, *new_fence = NULL;
 
-      fence = swap_fences_pop_front(drawable);
-      if (fence) {
-         (void) screen->fence_finish(screen, NULL, fence, PIPE_TIMEOUT_INFINITE);
-         screen->fence_reference(screen, &fence, NULL);
-      }
+      st->flush(st, flush_flags, &new_fence);
 
-      st->flush(st, flush_flags, &fence);
+      oldest_fence = swap_fences_pop_front(drawable);
+      if (oldest_fence) {
+         screen->fence_finish(screen, NULL, oldest_fence, PIPE_TIMEOUT_INFINITE);
+         screen->fence_reference(screen, &oldest_fence, NULL);
+      }
 
-      if (fence) {
-         swap_fences_push_back(drawable, fence);
-         screen->fence_reference(screen, &fence, NULL);
+      if (new_fence) {
+         swap_fences_push_back(drawable, new_fence);
+         screen->fence_reference(screen, &new_fence, NULL);
       }
    }
    else if (flags & (__DRI2_FLUSH_DRAWABLE | __DRI2_FLUSH_CONTEXT)) {
       st->flush(st, flush_flags, NULL);
    }
 
    if (drawable) {
       drawable->flushing = FALSE;
    }
 

Comments