summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2013-10-11 13:28:21 -0700
committerIan Romanick <ian.d.romanick@intel.com>2013-11-07 18:08:15 -0800
commit9dbc14abcffe92c5aa3057a5b62f585f61cce644 (patch)
tree27120a68b23a5f5ccfc557a0b6727d5ba831232e /src
parent83ffe47be0e26dcbaf917807447d82d53bb2c13b (diff)
downloadexternal_mesa3d-9dbc14abcffe92c5aa3057a5b62f585f61cce644.zip
external_mesa3d-9dbc14abcffe92c5aa3057a5b62f585f61cce644.tar.gz
external_mesa3d-9dbc14abcffe92c5aa3057a5b62f585f61cce644.tar.bz2
dri: Add function to implement queries common to all Mesa drivers
v2: Add assertions that the version string has the expected format. This will catch build errors (or changes to the version string format) in debug build without exposing release builds to buffer over-runs. Suggested by Ken. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/common/utils.c64
-rw-r--r--src/mesa/drivers/dri/common/utils.h3
2 files changed, 67 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c
index f3780d9..b30fca9 100644
--- a/src/mesa/drivers/dri/common/utils.c
+++ b/src/mesa/drivers/dri/common/utils.c
@@ -37,6 +37,7 @@
#include "main/cpuinfo.h"
#include "main/extensions.h"
#include "utils.h"
+#include "dri_util.h"
unsigned
@@ -477,3 +478,66 @@ driIndexConfigAttrib(const __DRIconfig *config, int index,
return GL_FALSE;
}
+
+/**
+ * Implement queries for values that are common across all Mesa drivers
+ *
+ * Currently only the following queries are supported by this function:
+ *
+ * - \c __DRI2_RENDERER_VERSION
+ * - \c __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION
+ * - \c __DRI2_RENDERER_OPENGL_COMPATIBLITY_PROFILE_VERSION
+ * - \c __DRI2_RENDERER_ES_PROFILE_VERSION
+ * - \c __DRI2_RENDERER_ES2_PROFILE_VERSION
+ *
+ * \returns
+ * Zero if a recognized value of \c param is supplied, -1 otherwise.
+ */
+int
+driQueryRendererIntegerCommon(__DRIscreen *psp, int param, int *value)
+{
+ switch (param) {
+ case __DRI2_RENDERER_VERSION: {
+ static const char *const ver = PACKAGE_VERSION;
+ char *endptr;
+ int v[3];
+
+ v[0] = strtol(ver, &endptr, 10);
+ assert(endptr[0] == '.');
+ if (endptr[0] != '.')
+ return -1;
+
+ v[1] = strtol(endptr + 1, &endptr, 10);
+ assert(endptr[0] == '.');
+ if (endptr[0] != '.')
+ return -1;
+
+ v[2] = strtol(endptr + 1, &endptr, 10);
+
+ value[0] = v[0];
+ value[1] = v[1];
+ value[2] = v[2];
+ return 0;
+ }
+ case __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION:
+ value[0] = psp->max_gl_core_version / 10;
+ value[1] = psp->max_gl_core_version % 10;
+ return 0;
+ case __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION:
+ value[0] = psp->max_gl_compat_version / 10;
+ value[1] = psp->max_gl_compat_version % 10;
+ return 0;
+ case __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION:
+ value[0] = psp->max_gl_es1_version / 10;
+ value[1] = psp->max_gl_es1_version % 10;
+ return 0;
+ case __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION:
+ value[0] = psp->max_gl_es2_version / 10;
+ value[1] = psp->max_gl_es2_version % 10;
+ return 0;
+ default:
+ break;
+ }
+
+ return -1;
+}
diff --git a/src/mesa/drivers/dri/common/utils.h b/src/mesa/drivers/dri/common/utils.h
index e3b3940..5d6ef87 100644
--- a/src/mesa/drivers/dri/common/utils.h
+++ b/src/mesa/drivers/dri/common/utils.h
@@ -65,4 +65,7 @@ int
driIndexConfigAttrib(const __DRIconfig *config, int index,
unsigned int *attrib, unsigned int *value);
+int
+driQueryRendererIntegerCommon(__DRIscreen *psp, int param, int *value);
+
#endif /* DRI_DEBUG_H */