OSDN Git Service

intel: flush fake front buffer more robustly.
authorPaul Berry <stereotype441@gmail.com>
Wed, 29 May 2013 16:48:26 +0000 (09:48 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 7 Jun 2013 20:26:43 +0000 (13:26 -0700)
When a fake front buffer is in use, if we request the front buffer
(using screen->dri2.loader->getBuffersWithFormat()), the X server
copies the real front buffer to the fake front buffer and returns the
fake front buffer.  We sometimes make redundant requests for the front
buffer (due to using a single counter to track invalidates for both
the front and back buffers), so there's a danger of pending front
buffer rendering getting overwritten when the redundant front buffer
request occurs.

Previous to this patch, intel_update_renderbuffers() worked around
that problem by sometimes doing intel_flush() and intel_flush_front()
before calling intel_query_dri2_buffers().  But it only did the
workaround when the front buffer was bound for drawing; it didn't do
it when the front buffer was bound for reading.

This patch moves the workaround code to intel_query_dri2_buffers(), so
that it happens in exactly the circumstances where it is needed.

This should fix some of the sporadic failures in Piglit tests
fbo-sys-blit and fbo-sys-sub-blit.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/drivers/dri/intel/intel_context.c

index 54d0a69..7f8a2bb 100644 (file)
@@ -186,17 +186,6 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
    int i, count;
    const char *region_name;
 
-   /* If we're rendering to the fake front buffer, make sure all the
-    * pending drawing has landed on the real front buffer.  Otherwise
-    * when we eventually get to DRI2GetBuffersWithFormat the stale
-    * real front buffer contents will get copied to the new fake front
-    * buffer.
-    */
-   if (intel->is_front_buffer_rendering) {
-      intel_flush(&intel->ctx);
-      intel_flush_front(&intel->ctx);
-   }
-
    /* Set this up front, so that in case our buffers get invalidated
     * while we're getting new buffers, we don't clobber the stamp and
     * thus ignore the invalidate. */
@@ -925,6 +914,15 @@ intel_query_dri2_buffers(struct intel_context *intel,
    if ((intel->is_front_buffer_rendering ||
        intel->is_front_buffer_reading ||
        !back_rb) && front_rb) {
+      /* If a fake front buffer is in use, then querying for
+       * __DRI_BUFFER_FRONT_LEFT will cause the server to copy the image from
+       * the real front buffer to the fake front buffer.  So before doing the
+       * query, we need to make sure all the pending drawing has landed in the
+       * real front buffer.
+       */
+      intel_flush(&intel->ctx);
+      intel_flush_front(&intel->ctx);
+
       attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
       attachments[i++] = intel_bits_per_pixel(front_rb);
    }