Mesa (10.1): dri3: Enable GLX_MESA_query_renderer on DRI3 too

Carl Worth cworth at kemper.freedesktop.org
Fri May 2 23:56:30 UTC 2014


Module: Mesa
Branch: 10.1
Commit: 93e9038e6a7668ff4a8043cfb49624abf3ab106e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=93e9038e6a7668ff4a8043cfb49624abf3ab106e

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Feb 20 11:47:14 2014 -0800

dri3: Enable GLX_MESA_query_renderer on DRI3 too

This should have happend around the time of commit 4680d23, but Keith's
DRI3 patches and my GLX_MESA_query_renderer patches crossed in the mail.

I don't have a working DRI3 setup, so I haven't been able to actually
verify this.  I'm hoping that someone can piglit this for me on DRI3...
It's also unfortunate the DRI2 and DRI3 can't share more code.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Keith Packard <keithp at keithp.com>
Cc: "10.1" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
(cherry picked from commit 625bdd64e5ea3327d4459b1ccccff8dab89129d0)

Conflicts:
	src/glx/dri3_glx.c

During the cherry-pick, the following commit was squashed in as well:

glx: Conditionally compile GLX_MESA_query_renderer DRI3 support

Missed out with commit 625bdd64e5ea3327d4459b1ccccff8dab89129d0.

Cc: "10.1" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
(cherry picked from commit 0b307afd57082f0d4a0e8ba19093d313c9fb46ad)

---

 src/glx/dri2.h                |    8 ++++++++
 src/glx/dri2_query_renderer.c |   43 +++++++++++++++++++++++++++++++++++++++++
 src/glx/dri3_glx.c            |   10 +++++++++-
 src/glx/dri3_priv.h           |    1 +
 4 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/src/glx/dri2.h b/src/glx/dri2.h
index 90efde8..7977d83 100644
--- a/src/glx/dri2.h
+++ b/src/glx/dri2.h
@@ -95,4 +95,12 @@ _X_HIDDEN int
 dri2_query_renderer_string(struct glx_screen *base, int attribute,
                            const char **value);
 
+_X_HIDDEN int
+dri3_query_renderer_integer(struct glx_screen *base, int attribute,
+                            unsigned int *value);
+
+_X_HIDDEN int
+dri3_query_renderer_string(struct glx_screen *base, int attribute,
+                           const char **value);
+
 #endif
diff --git a/src/glx/dri2_query_renderer.c b/src/glx/dri2_query_renderer.c
index 95560cb..80edcca 100644
--- a/src/glx/dri2_query_renderer.c
+++ b/src/glx/dri2_query_renderer.c
@@ -29,6 +29,9 @@
 #include "dri2.h"
 #include "dri_interface.h"
 #include "dri2_priv.h"
+#if defined(HAVE_DRI3)
+#include "dri3_priv.h"
+#endif
 
 static int
 dri2_convert_glx_query_renderer_attribs(int attribute)
@@ -99,4 +102,44 @@ dri2_query_renderer_string(struct glx_screen *base, int attribute,
    return psc->rendererQuery->queryString(psc->driScreen, dri_attribute, value);
 }
 
+#if defined(HAVE_DRI3)
+_X_HIDDEN int
+dri3_query_renderer_integer(struct glx_screen *base, int attribute,
+                            unsigned int *value)
+{
+   struct dri3_screen *const psc = (struct dri3_screen *) base;
+
+   /* Even though there are invalid values (and
+    * dri2_convert_glx_query_renderer_attribs may return -1), the higher level
+    * GLX code is required to perform the filtering.  Assume that we got a
+    * good value.
+    */
+   const int dri_attribute = dri2_convert_glx_query_renderer_attribs(attribute);
+
+   if (psc->rendererQuery == NULL)
+      return -1;
+
+   return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute,
+                                           value);
+}
+
+_X_HIDDEN int
+dri3_query_renderer_string(struct glx_screen *base, int attribute,
+                           const char **value)
+{
+   struct dri3_screen *const psc = (struct dri3_screen *) base;
+
+   /* Even though queryString only accepts a subset of the possible GLX
+    * queries, the higher level GLX code is required to perform the filtering.
+    * Assume that we got a good value.
+    */
+   const int dri_attribute = dri2_convert_glx_query_renderer_attribs(attribute);
+
+   if (psc->rendererQuery == NULL)
+      return -1;
+
+   return psc->rendererQuery->queryString(psc->driScreen, dri_attribute, value);
+}
+#endif /* HAVE_DRI3 */
+
 #endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index 70ec057..3b7ee1e 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -79,6 +79,7 @@
 #include "dri_common.h"
 #include "dri3_priv.h"
 #include "loader.h"
+#include "dri2.h"
 
 static const struct glx_context_vtable dri3_context_vtable;
 
@@ -1580,12 +1581,19 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv,
       if (strcmp(extensions[i]->name, __DRI2_ROBUSTNESS) == 0)
          __glXEnableDirectExtension(&psc->base,
                                     "GLX_ARB_create_context_robustness");
+
+      if (strcmp(extensions[i]->name, __DRI2_RENDERER_QUERY) == 0) {
+         psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
+         __glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
+      }
    }
 }
 
 static const struct glx_screen_vtable dri3_screen_vtable = {
    dri3_create_context,
-   dri3_create_context_attribs
+   dri3_create_context_attribs,
+   dri3_query_renderer_integer,
+   dri3_query_renderer_string,
 };
 
 /** dri3_create_screen
diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h
index 1d124f8..3346a17 100644
--- a/src/glx/dri3_priv.h
+++ b/src/glx/dri3_priv.h
@@ -129,6 +129,7 @@ struct dri3_screen {
    const __DRI2flushExtension *f;
    const __DRI2configQueryExtension *config;
    const __DRItexBufferExtension *texBuffer;
+   const __DRI2rendererQueryExtension *rendererQuery;
    const __DRIconfig **driver_configs;
 
    void *driver;




More information about the mesa-commit mailing list