[Mesa-dev] [PATCH 3/5] gallium/st: Add a method to flush outstanding swapbuffers

Thomas Hellstrom thellstrom at vmware.com
Thu Jun 22 10:42:35 UTC 2017


Add a state tracker interface method to flush outstanding swapbuffers, and
add a call to it from the mesa state tracker during glFinish().
This doesn't strictly mean the outstanding swapbuffers have actually finished
executing but is sufficient for glFinish()
to be able to be used as a replacement for glXWaitGL().

Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
---
 src/gallium/include/state_tracker/st_api.h |  2 ++
 src/mesa/state_tracker/st_cb_flush.c       |  2 ++
 src/mesa/state_tracker/st_manager.c        | 22 ++++++++++++++++++++++
 src/mesa/state_tracker/st_manager.h        |  3 +++
 4 files changed, 29 insertions(+)

diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index e566b19..a7b2bba 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -365,6 +365,8 @@ struct st_framebuffer_iface
                        const enum st_attachment_type *statts,
                        unsigned count,
                        struct pipe_resource **out);
+   boolean (*flush_swapbuffers) (struct st_context_iface *stctx,
+                                 struct st_framebuffer_iface *stfbi);
 };
 
 /**
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c
index 6442fc9..e8c6672 100644
--- a/src/mesa/state_tracker/st_cb_flush.c
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -102,6 +102,8 @@ void st_finish( struct st_context *st )
                                      PIPE_TIMEOUT_INFINITE);
       st->pipe->screen->fence_reference(st->pipe->screen, &fence, NULL);
    }
+
+   st_manager_flush_swapbuffers();
 }
 
 
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index cc781f4..9978e3f 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -863,6 +863,28 @@ st_manager_validate_framebuffers(struct st_context *st)
    st_context_validate(st, stdraw, stread);
 }
 
+
+/**
+ * Flush any outstanding swapbuffers on the current draw framebuffer.
+ */
+void
+st_manager_flush_swapbuffers(void)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct st_context *st = (ctx) ? ctx->st : NULL;
+   struct st_framebuffer *stfb;
+
+   if (!st)
+      return;
+
+   stfb = st_ws_framebuffer(ctx->DrawBuffer);
+   if (!stfb || !stfb->iface->flush_swapbuffers)
+      return;
+
+   stfb->iface->flush_swapbuffers(&st->iface, stfb->iface);
+}
+
+
 /**
  * Add a color renderbuffer on demand.  The FBO must correspond to a window,
  * not a user-created FBO.
diff --git a/src/mesa/state_tracker/st_manager.h b/src/mesa/state_tracker/st_manager.h
index 65874b0..b363f74 100644
--- a/src/mesa/state_tracker/st_manager.h
+++ b/src/mesa/state_tracker/st_manager.h
@@ -44,4 +44,7 @@ boolean
 st_manager_add_color_renderbuffer(struct st_context *st, struct gl_framebuffer *fb,
                                   gl_buffer_index idx);
 
+void
+st_manager_flush_swapbuffers(void);
+
 #endif /* ST_MANAGER_H */
-- 
2.7.4



More information about the mesa-dev mailing list