[PATCH v2] dri2: Reuse unused flags in GetBuffers protocol to pass last SBC

Ian Romanick idr at freedesktop.org
Tue Jan 20 13:55:43 PST 2015


On 01/19/2015 06:29 AM, Chris Wilson wrote:
> Allow mesa/dri2 to implement GLX_EXT_buffer_age by reporting the sbc of
> when the current back buffer was defined. As this may require ddx
> support, only set the value if enabled by the ddx and report the new
> semantics via a DRI2GetParam request.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  configure.ac           |  2 +-
>  hw/xfree86/dri2/dri2.c | 25 +++++++++++++++++++++----
>  hw/xfree86/dri2/dri2.h |  1 +
>  3 files changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index b593fc7..e49c35e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -768,7 +768,7 @@ RECORDPROTO="recordproto >= 1.13.99.1"
>  SCRNSAVERPROTO="scrnsaverproto >= 1.1"
>  RESOURCEPROTO="resourceproto >= 1.2.0"
>  DRIPROTO="xf86driproto >= 2.1.0"
> -DRI2PROTO="dri2proto >= 2.8"
> +DRI2PROTO="dri2proto >= 2.9"
>  DRI3PROTO="dri3proto >= 1.0"
>  XINERAMAPROTO="xineramaproto"
>  BIGFONTPROTO="xf86bigfontproto >= 1.2.0"
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index 2c0367e..d70a632 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -49,6 +49,8 @@
>  #include "damage.h"
>  #include "xf86.h"
>  
> +#include <X11/extensions/dri2proto.h> /* for parameter names */
> +
>  CARD8 dri2_major;               /* version of DRI2 supported by DDX */
>  CARD8 dri2_minor;
>  
> @@ -115,6 +117,7 @@ typedef struct _DRI2Screen {
>      unsigned int lastSequence;
>      int prime_id;
>      int scheduleSwap0;
> +    int bufferAge;
>  
>      DRI2CreateBufferProcPtr CreateBuffer;
>      DRI2DestroyBufferProcPtr DestroyBuffer;
> @@ -1117,6 +1120,9 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
>          return BadDrawable;
>      }
>  
> +    if (ds->bufferAge)
> +        pSrcBuffer->flags = *swap_target;
> +
>      /* Old DDX or PRIME, just blit */
>      if (!ds->scheduleSwap0 || pPriv->prime_id) {
>          BoxRec box;
> @@ -1562,6 +1568,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
>  
>      if (info->version >= 10) {
>          ds->scheduleSwap0 = info->scheduleSwap0;
> +        ds->bufferAge = info->bufferAge;
>      }
>  
>      /*
> @@ -1684,10 +1691,20 @@ DRI2GetParam(ClientPtr client,
>  
>      switch (high_byte) {
>      case 0:
> -        /* Parameter names whose high_byte is 0 are reserved for the X
> -         * server. The server currently recognizes no parameters.
> -         */
> -        goto not_recognized;
> +	/* Parameter names whose high_byte is 0 are reserved for the X
> +	 * server.
> +	 */

Why did the whitespace change?  I don't remember what the whitespace
rules are in the server...

> +	switch (param) {
> +	case DRI2ParamXHasBufferAge:
> +	    *value = ds->bufferAge;
> +	    break;
> +	default:
> +	    goto not_recognized;
> +	}
> +
> +	*is_param_recognized = TRUE;
> +	return Success;
> +
>      case 1:
>          /* Parameter names whose high byte is 1 are reserved for the DDX. */
>          if (ds->GetParam)
> diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
> index 1cf4288..e76f7a8 100644
> --- a/hw/xfree86/dri2/dri2.h
> +++ b/hw/xfree86/dri2/dri2.h
> @@ -255,6 +255,7 @@ typedef struct {
>  
>      /* added in version 10 */
>      int scheduleSwap0;
> +    int bufferAge;

Both fields should get added in the patch where the version is bumped,
right?

>  } DRI2InfoRec, *DRI2InfoPtr;
>  
>  extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info);
> 



More information about the dri-devel mailing list