diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2012-05-02 16:18:49 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-05-31 12:14:17 -0700 |
commit | 78f0d9cdc441a575e15e5f7200ce74750d2f7ad2 (patch) | |
tree | 35586357d39df95ad8f5fe8a91216bde013a5838 /hw | |
parent | 594b4a4f0601066d09e49a84c5af8c2eb6f07240 (diff) |
dri2: Add DRI2GetParam request (v2)
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
to write 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.
[1] mesa, commit aea2236a, function intel_verify_dri2_has_hiz
v2: If driver doesn't define ds->GetParam, dont' crash. Fall back to
default behavior, per keithp.
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net> (v1)
Reviewed-by: Ian Romanick <idr@freedesktop.org> (v1)
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xfree86/dri2/dri2.c | 41 | ||||
-rw-r--r-- | hw/xfree86/dri2/dri2.h | 26 | ||||
-rw-r--r-- | hw/xfree86/dri2/dri2ext.c | 33 |
3 files changed, 99 insertions, 1 deletions
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 591ff3ace..babf32f13 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,38 @@ DRI2Version(int *major, int *minor) if (minor != NULL) *minor = DRI2VersRec.minorversion; } + +int +DRI2GetParam(ClientPtr client, + DrawablePtr drawable, + CARD64 param, + BOOL *is_param_recognized, + CARD64 *value) +{ + DRI2ScreenPtr ds = DRI2GetScreen(drawable->pScreen); + char high_byte = (param >> 24); + + 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; + case 1: + /* Parameter names whose high byte is 1 are reserved for the DDX. */ + if (ds->GetParam) + return ds->GetParam(client, drawable, param, + is_param_recognized, value); + else + goto not_recognized; + default: + /* Other parameter names are reserved for future use. They are never + * recognized. + */ + goto not_recognized; + } + +not_recognized: + *is_param_recognized = FALSE; + return Success; +} diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h index 00b3668cc..f849be67a 100644 --- a/hw/xfree86/dri2/dri2.h +++ b/hw/xfree86/dri2/dri2.h @@ -176,9 +176,23 @@ typedef Bool (*DRI2SwapLimitValidateProcPtr) (DrawablePtr pDraw, int swap_limit); /** + * \brief Get the value of a parameter. + * + * The parameter's \a value is looked up on the screen associated with + * \a pDrawable. + * + * \return \c Success or error code. + */ +typedef int (*DRI2GetParamProcPtr) (ClientPtr client, + DrawablePtr pDrawable, + 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 +225,10 @@ typedef struct { DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify; DRI2SwapLimitValidateProcPtr SwapLimitValidate; + + /* added in version 7 */ + + DRI2GetParamProcPtr GetParam; } DRI2InfoRec, *DRI2InfoPtr; extern _X_EXPORT int DRI2EventBase; @@ -308,4 +326,10 @@ 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, + CARD64 param, + BOOL *is_param_recognized, + CARD64 *value); + #endif diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c index 61578f3c1..c6f5b4e11 100644 --- a/hw/xfree86/dri2/dri2ext.c +++ b/hw/xfree86/dri2/dri2ext.c @@ -535,6 +535,37 @@ ProcDRI2WaitSBC(ClientPtr client) } static int +ProcDRI2GetParam(ClientPtr client) +{ + REQUEST(xDRI2GetParamReq); + xDRI2GetParamReply rep; + DrawablePtr pDrawable; + 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; + + status = DRI2GetParam(client, pDrawable, stuff->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 +603,8 @@ ProcDRI2Dispatch(ClientPtr client) return ProcDRI2WaitSBC(client); case X_DRI2SwapInterval: return ProcDRI2SwapInterval(client); + case X_DRI2GetParam: + return ProcDRI2GetParam(client); default: return BadRequest; } |