[PATCH 02/02] dri2: Add DRI2GetParam request

Kristian Høgsberg krh at bitplanet.net
Mon May 14 08:51:43 PDT 2012


On Thu, May 10, 2012 at 3:04 AM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> Bump dri2proto dependency to 2.7.
> Bump DRI2INFOREC_VERSION to 7.
>
> This new protocol request effectively allows clients to perform feature
> detection on the DDX. The request was added in DRI2 protocol 1.4.
>
> If I had DRI2GetParam in June 2011, when I was implementing support in the
> Intel DDX and Mesa for new hardware that required a new DRI2 attachment
> format, then I could have avoided a week of pain caused by the necessity
> of writing a horrid feature detection hack [1] in Mesa. In the future, when
> the work begins to add MSAA support to the Intel DDX, having a clean way
> to do feature detection will allow us to avoid revisiting and expanding
> that hack.

Yeah, that looks fine, should make things simpler than trying to infer
from version numbers.  If we expect to add many parameters or query
them often (per frame), we should think about how to query a batch of
parameters at a time to avoid multiple roundtrips.  EGL uses xcb, so
it's not a big deal there, and for GLX, the protocol code is in mesa,
so we could just pipeline the request/reply code by hand if we have
to.

Also, if I was painting this bikeshed I'd just drop the namespace arg,
and have a CARD32 be the param and put driver params above 0x1000 or
whatever.  CARD64 for the value makes sense, at least some of the
crazy swap parameters are 64 bit.

Kristian

> [1] mesa, commit aea2236a, function intel_verify_dri2_has_hiz
>
> CC: Keith Packard <keithp at keithp.com>
> CC: Kristian Høgsberg <krh at bitplanet.net>
> CC: Ian Romanick <idr at freedesktop.org>
> CC: Eric Anholt <eric at anholt.net>
> CC: Ville Syrjälä <syrjala at sci.fi>
> CC: Michel Dänzer <daenzer at vmware.com>
> CC: Jesse Barnes <jbarnes at virtuousgeek.org>
> CC: Chris Wilson <chris at chris-wilson.co.uk>
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
> ---
>  configure.ac              |    2 +-
>  hw/xfree86/dri2/dri2.c    |   30 ++++++++++++++++++++++++++++++
>  hw/xfree86/dri2/dri2.h    |   34 +++++++++++++++++++++++++++++++++-
>  hw/xfree86/dri2/dri2ext.c |   36 ++++++++++++++++++++++++++++++++++++
>  4 files changed, 100 insertions(+), 2 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 6a41ea8..a2e22f7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -773,7 +773,7 @@ RECORDPROTO="recordproto >= 1.13.99.1"
>  SCRNSAVERPROTO="scrnsaverproto >= 1.1"
>  RESOURCEPROTO="resourceproto >= 1.2.0"
>  DRIPROTO="xf86driproto >= 2.1.0"
> -DRI2PROTO="dri2proto >= 2.6"
> +DRI2PROTO="dri2proto >= 2.7"
>  XINERAMAPROTO="xineramaproto"
>  BIGFONTPROTO="xf86bigfontproto >= 1.2.0"
>  DGAPROTO="xf86dgaproto >= 2.0.99.1"
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index 591ff3a..d40cea2 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -107,6 +107,7 @@ typedef struct _DRI2Screen {
>     DRI2AuthMagicProcPtr AuthMagic;
>     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
>     DRI2SwapLimitValidateProcPtr SwapLimitValidate;
> +    DRI2GetParamProcPtr GetParam;
>
>     HandleExposuresProcPtr HandleExposures;
>
> @@ -1210,6 +1211,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
>         ds->SwapLimitValidate = info->SwapLimitValidate;
>     }
>
> +    if (info->version >= 7) {
> +        ds->GetParam = info->GetParam;
> +        cur_minor = 4;
> +    }
> +
>     /*
>      * 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
> @@ -1332,3 +1338,27 @@ DRI2Version(int *major, int *minor)
>     if (minor != NULL)
>         *minor = DRI2VersRec.minorversion;
>  }
> +
> +int
> +DRI2GetParam(ClientPtr client,
> +             DrawablePtr drawable,
> +             CARD32 namespace_,
> +             CARD64 param,
> +             BOOL *is_param_recognized,
> +             CARD64 *value)
> +{
> +    DRI2ScreenPtr ds = DRI2GetScreen(drawable->pScreen);
> +
> +    switch (namespace_) {
> +    case DRI2ParamNamespaceServer:
> +        /* The server currently recognizes no parameters. */
> +        *is_param_recognized = FALSE;
> +        return Success;
> +    case DRI2ParamNamespaceDriver:
> +        return ds->GetParam(client, drawable, namespace_, param,
> +                            is_param_recognized, value);
> +    default:
> +        client->errorValue = namespace_;
> +        return BadValue;
> +    }
> +}
> diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
> index 00b3668..49489c7 100644
> --- a/hw/xfree86/dri2/dri2.h
> +++ b/hw/xfree86/dri2/dri2.h
> @@ -176,9 +176,30 @@ typedef Bool (*DRI2SwapLimitValidateProcPtr) (DrawablePtr pDraw,
>                                               int swap_limit);
>
>  /**
> + * \brief Get the value of a parameter.
> + *
> + * The parameter's \a value is looked up in the \a namespace_ on the screen
> + * associated with \a pDrawable.
> + *
> + * Parameter names in the server  namespace are invariant with
> + * respect to the loaded driver. Parameter names in the driver
> + * namespace are specific to the loaded driver.
> + *
> + * \param namespace_ is one of DRI2ParamNamespaceServer,
> + *        DRI2ParamNamespaceDriver.
> + * \return \c Success or error code.
> + */
> +typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
> +                                    DrawablePtr pDrawable,
> +                                    CARD32 namespace_,
> +                                    CARD64 param,
> +                                    BOOL *is_param_recognized,
> +                                    CARD64 *value);
> +
> +/**
>  * Version of the DRI2InfoRec structure defined in this header
>  */
> -#define DRI2INFOREC_VERSION 6
> +#define DRI2INFOREC_VERSION 7
>
>  typedef struct {
>     unsigned int version;       /**< Version of this struct */
> @@ -211,6 +232,10 @@ typedef struct {
>
>     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
>     DRI2SwapLimitValidateProcPtr SwapLimitValidate;
> +
> +    /* added in version 7 */
> +
> +    DRI2GetParamProcPtr GetParam;
>  } DRI2InfoRec, *DRI2InfoPtr;
>
>  extern _X_EXPORT int DRI2EventBase;
> @@ -308,4 +333,11 @@ extern _X_EXPORT void DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw,
>                                           int frame, unsigned int tv_sec,
>                                           unsigned int tv_usec);
>
> +extern _X_EXPORT int DRI2GetParam(ClientPtr client,
> +                                  DrawablePtr pDrawable,
> +                                  CARD32 namespace_,
> +                                  CARD64 param,
> +                                  BOOL *is_param_recognized,
> +                                  CARD64 *value);
> +
>  #endif
> diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
> index 2579a5c..67a5aec 100644
> --- a/hw/xfree86/dri2/dri2ext.c
> +++ b/hw/xfree86/dri2/dri2ext.c
> @@ -535,6 +535,40 @@ ProcDRI2WaitSBC(ClientPtr client)
>  }
>
>  static int
> +ProcDRI2GetParam(ClientPtr client)
> +{
> +    REQUEST(xDRI2GetParamReq);
> +    xDRI2GetParamReply rep;
> +    DrawablePtr pDrawable;
> +    CARD64 param;
> +    CARD64 value;
> +    int status;
> +
> +    REQUEST_SIZE_MATCH(xDRI2GetParamReq);
> +    rep.type = X_Reply;
> +    rep.length = 0;
> +    rep.sequenceNumber = client->sequence;
> +
> +    if (!validDrawable(client, stuff->drawable, DixReadAccess,
> +                       &pDrawable, &status))
> +        return status;
> +
> +    param = vals_to_card64(stuff->param_lo, stuff->param_hi);
> +    status = DRI2GetParam(client,
> +                          pDrawable, stuff->namespace_, param,
> +                          &rep.is_param_recognized, &value);
> +    rep.value_hi = value >> 32;
> +    rep.value_lo = value & 0xffffffff;
> +
> +    if (status != Success)
> +        return status;
> +
> +    WriteToClient(client, sizeof(xDRI2GetParamReply), &rep);
> +
> +    return status;
> +}
> +
> +static int
>  ProcDRI2Dispatch(ClientPtr client)
>  {
>     REQUEST(xReq);
> @@ -572,6 +606,8 @@ ProcDRI2Dispatch(ClientPtr client)
>         return ProcDRI2WaitSBC(client);
>     case X_DRI2SwapInterval:
>         return ProcDRI2SwapInterval(client);
> +    case X_DRI2GetParam:
> +        return ProcDRI2GetParam(client);
>     default:
>         return BadRequest;
>     }
> --
> 1.7.10.1
>


More information about the xorg-devel mailing list