(Resending. I accidentally sent this to xorg rather than xorg-devel).
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_hi
CC: Alan Coopersmith
CC: Kristian Høgsberg
CC: Ian Romanick
CC: Eric Anholt
CC: Chris Wilson
CC: Jesse Barnes
Signed-off-by: Chad Versace
---
v2:
- Fixed typo "param_is", per anholt.
- Changed param from CARD64 to CARD32, per krh and anholt.
- Removed namespaces, per krh. Instead, there is an enum range reserved
for each the server and the ddx.
v3:
- No change.
configure.ac |2 +-
hw/xfree86/dri2/dri2.c| 37 +
hw/xfree86/dri2/dri2.h| 26 +-
hw/xfree86/dri2/dri2ext.c | 34 ++
4 files changed, 97 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..a4ca2a8 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,34 @@ 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.
+ */
+*is_param_recognized = FALSE;
+return Success;
+case 1:
+/* Parameter names whose high byte is 1 are reserved for the DDX. */
+return ds->GetParam(client, drawable, param,
+is_param_recognized, value);
+default:
+/* Other parameter names are reserved for future use. They are never
+ * recognized.
+ */
+*is_param_recognized = FALSE;
+return Success;
+}
+}
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 00b3668..f849be6 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