[Mesa-dev] [PATCH 4/7] intel: Add support for the new flush_with_flags extension.

Eric Anholt eric at anholt.net
Wed Jan 9 12:42:24 PST 2013


This gives us more information about why we're flushing that we can
use for handling our throttling.
---
 src/mesa/drivers/dri/intel/intel_screen.c |   40 +++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index e0fe8c1..2d97d4c 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -166,18 +166,27 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
 };
 
 static void
-intelDRI2Flush(__DRIdrawable *drawable)
+intel_dri2_flush_with_flags(__DRIcontext *cPriv,
+                            __DRIdrawable *dPriv,
+                            unsigned flags,
+                            enum __DRI2throttleReason reason)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct intel_context *intel = intel_context(ctx);
-   if (intel == NULL)
+   struct intel_context *intel = cPriv->driverPrivate;
+   struct gl_context *ctx = &intel->ctx;
+
+   if (!intel)
       return;
 
    if (intel->gen < 4)
       INTEL_FIREVERTICES(intel);
 
-   intel_downsample_for_dri2_flush(intel, drawable);
-   intel->need_throttle = true;
+   if (flags & __DRI2_FLUSH_DRAWABLE)
+      intel_downsample_for_dri2_flush(intel, dPriv);
+
+   if (reason == __DRI2_THROTTLE_SWAPBUFFER ||
+       reason == __DRI2_THROTTLE_FLUSHFRONT) {
+      intel->need_throttle = true;
+   }
 
    if (intel->batch.used)
       intel_batchbuffer_flush(intel);
@@ -187,11 +196,26 @@ intelDRI2Flush(__DRIdrawable *drawable)
    }
 }
 
+/**
+ * Provides compatibility with loaders that only support the older (version
+ * 1-3) flush interface.
+ *
+ * That includes libGL up to Mesa 9.0, and the X Server at least up to 1.13.
+ */
+static void
+intel_dri2_flush(__DRIdrawable *drawable)
+{
+   intel_dri2_flush_with_flags(drawable->driContextPriv, drawable,
+                               __DRI2_FLUSH_DRAWABLE,
+                               __DRI2_THROTTLE_SWAPBUFFER);
+}
+
 static const struct __DRI2flushExtensionRec intelFlushExtension = {
-    .base = { __DRI2_FLUSH, 3 },
+    .base = { __DRI2_FLUSH, 4 },
 
-    .flush              = intelDRI2Flush,
+    .flush              = intel_dri2_flush,
     .invalidate         = dri2InvalidateDrawable,
+    .flush_with_flags   = intel_dri2_flush_with_flags,
 };
 
 static struct intel_image_format intel_image_formats[] = {
-- 
1.7.10.4



More information about the mesa-dev mailing list