xserver: Branch 'master' - 3 commits

Keith Packard keithp at kemper.freedesktop.org
Wed Sep 21 14:07:15 PDT 2011


 hw/xfree86/dri2/dri2.c |   41 +++++++++++++++++++++++++++++++++++++++++
 hw/xfree86/dri2/dri2.h |   31 ++++++++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 1 deletion(-)

New commits:
commit 871d65790ec2ac0fd6d5105c2d599f63a86fcaf1
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Mon Nov 1 16:02:11 2010 +0200

    DRI2: Allow DDX to validate swap_limit changes
    
    DDX can now implement validation for swap_limit changes to prevent
    configurations that are not support in driver.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    CC: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Reviewed-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index ae685bb..a97508d 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -103,6 +103,7 @@ typedef struct _DRI2Screen {
     DRI2ScheduleWaitMSCProcPtr	 ScheduleWaitMSC;
     DRI2AuthMagicProcPtr	 AuthMagic;
     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
+    DRI2SwapLimitValidateProcPtr SwapLimitValidate;
 
     HandleExposuresProcPtr       HandleExposures;
 
@@ -196,9 +197,16 @@ Bool
 DRI2SwapLimit(DrawablePtr pDraw, int swap_limit)
 {
     DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+    DRI2ScreenPtr ds;
     if (!pPriv)
 	return FALSE;
 
+    ds = pPriv->dri2_screen;
+
+    if (!ds->SwapLimitValidate
+	|| !ds->SwapLimitValidate(pDraw, swap_limit))
+	return FALSE;
+
     pPriv->swap_limit = swap_limit;
 
     /* Check throttling */
@@ -1156,8 +1164,10 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         ds->AuthMagic = info->AuthMagic;
     }
 
-    if (info->version >= 6)
+    if (info->version >= 6) {
 	ds->ReuseBufferNotify = info->ReuseBufferNotify;
+	ds->SwapLimitValidate = info->SwapLimitValidate;
+    }
 
     /*
      * if the driver doesn't provide an AuthMagic function or the info struct
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 8c0c64b..9c93209 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -169,6 +169,19 @@ typedef void		(*DRI2InvalidateProcPtr)(DrawablePtr pDraw,
 						 void *data);
 
 /**
+ * DRI2 calls this hook when ever swap_limit is going to be changed. Default
+ * implementation for the hook only accepts one as swap_limit. If driver can
+ * support other swap_limits it has to implement supported limits with this
+ * callback.
+ *
+ * \param pDraw drawable whos swap_limit is going to be changed
+ * \param swap_limit new swap_limit that going to be set
+ * \return TRUE if limit is support, FALSE if not.
+ */
+typedef Bool		(*DRI2SwapLimitValidateProcPtr)(DrawablePtr pDraw,
+							int swap_limit);
+
+/**
  * Version of the DRI2InfoRec structure defined in this header
  */
 #define DRI2INFOREC_VERSION 6
@@ -203,6 +216,7 @@ typedef struct {
     /* added in version 6 */
 
     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
+    DRI2SwapLimitValidateProcPtr SwapLimitValidate;
 }  DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;
commit b435e2aac1b3fbb97d0275de73a1e36d16f170c0
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Mon Nov 1 16:22:00 2010 +0200

    DRI2: Expose API to set drawable swap limit.
    
    This allows ddx to set swap_limit if there is more than one back
    buffer for drawable. Setting swap_limit has to also check if change
    affects a client that is blocked.
    
    This can be used to implement N-buffering in driver with minimal
    logic in allocation and selecting next back.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Jesse Barnes <jbarnes at virtuousgeek.org>
    Reviewed-by: Francisco Jerez <currojerez at riseup.net>
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 1e6ee16..ae685bb 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -192,6 +192,29 @@ DRI2AllocateDrawable(DrawablePtr pDraw)
     return pPriv;
 }
 
+Bool
+DRI2SwapLimit(DrawablePtr pDraw, int swap_limit)
+{
+    DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+    if (!pPriv)
+	return FALSE;
+
+    pPriv->swap_limit = swap_limit;
+
+    /* Check throttling */
+    if (pPriv->swapsPending >= pPriv->swap_limit)
+	return TRUE;
+
+    if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
+	if (pPriv->blockedClient) {
+	    AttendClient(pPriv->blockedClient);
+	    pPriv->blockedClient = NULL;
+	}
+    }
+
+    return TRUE;
+}
+
 typedef struct DRI2DrawableRefRec {
     XID		  id;
     XID		  dri2_id;
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 7afba8e..8c0c64b 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -265,6 +265,7 @@ extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffersWithFormat(DrawablePtr pDraw,
 	int *out_count);
 
 extern _X_EXPORT void DRI2SwapInterval(DrawablePtr pDrawable, int interval);
+extern _X_EXPORT Bool DRI2SwapLimit(DrawablePtr pDraw, int swap_limit);
 extern _X_EXPORT int DRI2SwapBuffers(ClientPtr client, DrawablePtr pDrawable,
 				     CARD64 target_msc, CARD64 divisor,
 				     CARD64 remainder, CARD64 *swap_target,
commit 86f8da0aa7612558e6563f5de0d9f9793854053f
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Mon Nov 1 16:21:59 2010 +0200

    DRI2: Add ReuseBufferNotify hook
    
    ReuseBufferNotify hook is called whenever old buffer is reused in DRI2
    code.
    
    Driver can use this hook to rewrite the buffer name if hardware requires
    shared buffers. Shared buffer might be some hardware limited resources like
    framebuffer that is preallocated in boot.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Jesse Barnes <jbarnes at virtuousgeek.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index af3bcae..1e6ee16 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -102,6 +102,7 @@ typedef struct _DRI2Screen {
     DRI2GetMSCProcPtr		 GetMSC;
     DRI2ScheduleWaitMSCProcPtr	 ScheduleWaitMSC;
     DRI2AuthMagicProcPtr	 AuthMagic;
+    DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
 
     HandleExposuresProcPtr       HandleExposures;
 
@@ -352,6 +353,10 @@ allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
 
     } else {
 	*buffer = pPriv->buffers[old_buf];
+
+	if (ds->ReuseBufferNotify)
+		(*ds->ReuseBufferNotify)(pDraw, *buffer);
+
 	pPriv->buffers[old_buf] = NULL;
 	return FALSE;
     }
@@ -1128,6 +1133,9 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         ds->AuthMagic = info->AuthMagic;
     }
 
+    if (info->version >= 6)
+	ds->ReuseBufferNotify = info->ReuseBufferNotify;
+
     /*
      * if the driver doesn't provide an AuthMagic function or the info struct
      * version is too low, it relies on the old method (using libdrm) or fail
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 2a41ead..7afba8e 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -110,6 +110,16 @@ typedef DRI2BufferPtr	(*DRI2CreateBufferProcPtr)(DrawablePtr pDraw,
 typedef void		(*DRI2DestroyBufferProcPtr)(DrawablePtr pDraw,
 						    DRI2BufferPtr buffer);
 /**
+ * Notifies driver when DRI2GetBuffers reuses a dri2 buffer.
+ *
+ * Driver may rename the dri2 buffer in this notify if it is required.
+ *
+ * \param pDraw drawable whose count we want
+ * \param buffer buffer that will be returned to client
+ */
+typedef void		(*DRI2ReuseBufferNotifyProcPtr)(DrawablePtr pDraw,
+						      DRI2BufferPtr buffer);
+/**
  * Get current media stamp counter values
  *
  * This callback is used to support the SGI_video_sync and OML_sync_control
@@ -161,7 +171,7 @@ typedef void		(*DRI2InvalidateProcPtr)(DrawablePtr pDraw,
 /**
  * Version of the DRI2InfoRec structure defined in this header
  */
-#define DRI2INFOREC_VERSION 5
+#define DRI2INFOREC_VERSION 6
 
 typedef struct {
     unsigned int version;	/**< Version of this struct */
@@ -189,6 +199,10 @@ typedef struct {
     /* added in version 5 */
 
     DRI2AuthMagicProcPtr	AuthMagic;
+
+    /* added in version 6 */
+
+    DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
 }  DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;


More information about the xorg-commit mailing list