summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2014-08-14 18:26:55 +0100
committerEmil Velikov <[email protected]>2014-08-15 17:35:37 +0100
commit679c2ef8a058824615fbc4c5aba40d65d1ed9170 (patch)
tree7a63d191e5c1b8dd3024f440507e6581fc7e1d6a /src
parent1bccf99c306372f2c281601be67c805952fd6bf6 (diff)
glx/drisw: add support for DRI2rendererQueryExtension
The extension is used by GLX_MESA_query_renderer, which can be provided for by hardware and software drivers. v2: Use designated initializers. v3: Move drisw_query_renderer_*() to dri2_query_renderer.c Signed-off-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glx/dri2_query_renderer.c40
-rw-r--r--src/glx/drisw_glx.c12
-rw-r--r--src/glx/drisw_priv.h8
3 files changed, 58 insertions, 2 deletions
diff --git a/src/glx/dri2_query_renderer.c b/src/glx/dri2_query_renderer.c
index eb5884aba63..247ec1ca6bd 100644
--- a/src/glx/dri2_query_renderer.c
+++ b/src/glx/dri2_query_renderer.c
@@ -31,6 +31,7 @@
#if defined(HAVE_DRI3)
#include "dri3_priv.h"
#endif
+#include "drisw_priv.h"
#define __RENDERER(attrib) \
{ GLX_RENDERER_##attrib##_MESA, __DRI2_RENDERER_##attrib }
@@ -143,4 +144,43 @@ dri3_query_renderer_string(struct glx_screen *base, int attribute,
}
#endif /* HAVE_DRI3 */
+_X_HIDDEN int
+drisw_query_renderer_integer(struct glx_screen *base, int attribute,
+ unsigned int *value)
+{
+ struct drisw_screen *const psc = (struct drisw_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
+drisw_query_renderer_string(struct glx_screen *base, int attribute,
+ const char **value)
+{
+ struct drisw_screen *const psc = (struct drisw_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 /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index fab9e70d63a..749ceb08aac 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -599,8 +599,8 @@ driOpenSwrast(void)
static const struct glx_screen_vtable drisw_screen_vtable = {
.create_context = drisw_create_context,
.create_context_attribs = drisw_create_context_attribs,
- .query_renderer_integer = NULL,
- .query_renderer_string = NULL,
+ .query_renderer_integer = drisw_query_renderer_integer,
+ .query_renderer_string = drisw_query_renderer_string,
};
static void
@@ -629,6 +629,14 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions)
psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
__glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap");
}
+ /* DRISW version 3 is also required because GLX_MESA_query_renderer
+ * requires GLX_ARB_create_context_profile.
+ */
+ if (psc->swrast->base.version >= 3
+ && strcmp(extensions[i]->name, __DRI2_RENDERER_QUERY) == 0) {
+ psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
+ __glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
+ }
}
}
diff --git a/src/glx/drisw_priv.h b/src/glx/drisw_priv.h
index a8de2a7b60d..5d479003114 100644
--- a/src/glx/drisw_priv.h
+++ b/src/glx/drisw_priv.h
@@ -45,6 +45,7 @@ struct drisw_screen
const __DRIswrastExtension *swrast;
const __DRItexBufferExtension *texBuffer;
const __DRIcopySubBufferExtension *copySubBuffer;
+ const __DRI2rendererQueryExtension *rendererQuery;
const __DRIconfig **driver_configs;
@@ -62,3 +63,10 @@ struct drisw_drawable
XVisualInfo *visinfo;
XImage *ximage;
};
+
+_X_HIDDEN int
+drisw_query_renderer_integer(struct glx_screen *base, int attribute,
+ unsigned int *value);
+_X_HIDDEN int
+drisw_query_renderer_string(struct glx_screen *base, int attribute,
+ const char **value);