gallium/st: Add a method to flush outstanding swapbuffers
authorThomas Hellstrom <thellstrom@vmware.com>
Tue, 20 Jun 2017 16:36:08 +0000 (18:36 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 3 Aug 2017 06:01:25 +0000 (08:01 +0200)
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@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
src/gallium/include/state_tracker/st_api.h
src/mesa/state_tracker/st_cb_flush.c
src/mesa/state_tracker/st_manager.c
src/mesa/state_tracker/st_manager.h

index bc62a69da378ca99f27b7bd39923d61b492cd335..2eaf891ab7afe4862fc657370e5ee9041b2a6b49 100644 (file)
@@ -366,6 +366,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);
 };
 
 /**
index 8375308c3e24c1e4dfaaebd28e9130c55eafb309..5a260184edeaf992166c4d13da26364d94f8b94d 100644 (file)
@@ -73,6 +73,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();
 }
 
 
index 28cf0234cd65d35371b51909822bcfdcd1d32ca3..617a691a67c33871a0c84d90feb9bc3d2986f2af 100644 (file)
@@ -1064,6 +1064,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.
index c54f29e29411d23f9b02a09486d8cbc1ed51ea16..1a1ea79af8ed998259b8256ab9d23efb714ce02e 100644 (file)
@@ -53,4 +53,7 @@ st_framebuffer_reference(struct st_framebuffer **ptr,
 void
 st_framebuffer_interface_destroy(struct st_framebuffer_interface *stfbi);
 
+void
+st_manager_flush_swapbuffers(void);
+
 #endif /* ST_MANAGER_H */