[3/3] st/mesa: don't flush the front buffer if it's a pbuffer

Submitted by Marek Olšák on April 27, 2019, 3:31 a.m.

Details

Message ID 20190427033147.12859-4-maraeo@gmail.com
State New
Headers show
Series "Pbuffer fixes" ( rev: 2 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Marek Olšák April 27, 2019, 3:31 a.m.
From: Marek Olšák <marek.olsak@amd.com>

This is the best guess I can make here.
---
 src/mesa/state_tracker/st_manager.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 5efbd1fa1d2..bee1f6b1366 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -1123,23 +1123,33 @@  st_api_destroy(struct st_api *stapi)
 
 /**
  * Flush the front buffer if the current context renders to the front buffer.
  */
 void
 st_manager_flush_frontbuffer(struct st_context *st)
 {
    struct st_framebuffer *stfb = st_ws_framebuffer(st->ctx->DrawBuffer);
    struct st_renderbuffer *strb = NULL;
 
-   if (stfb)
-      strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_FRONT_LEFT].
-                             Renderbuffer);
+   if (!stfb)
+      return;
+
+   /* If the context uses a doublebuffered visual, but the buffer is
+    * single-buffered, guess that it's a pbuffer, which doesn't need
+    * flushing.
+    */
+   if (st->ctx->Visual.doubleBufferMode &&
+       !stfb->Base.Visual.doubleBufferMode)
+      return;
+
+   strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_FRONT_LEFT].
+                          Renderbuffer);
 
    /* Do we have a front color buffer and has it been drawn to since last
     * frontbuffer flush?
     */
    if (strb && strb->defined) {
       stfb->iface->flush_front(&st->iface, stfb->iface,
                                ST_ATTACHMENT_FRONT_LEFT);
       strb->defined = GL_FALSE;
 
       /* Trigger an update of strb->defined on next draw */