Module: Mesa
Branch: master
Commit: 4ba255dfaaf39ec9835ecb244aa7bf5a2362b5ab
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ba255dfaaf39ec9835ecb244aa7bf5a2362b5ab

Author: Martin Peres <[email protected]>
Date:   Thu Oct 15 15:23:05 2020 +0300

dri/DRI2ConfigQueryExtension: add support for string options

This will be useful to enable extension overriding as a drirc option.

v2 (Adam Jackson):
 - Rename from configQuerystr to configQuerys for symmetry
 - Increase the version number of the interface

Reviewed-by: Adam Jackson <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Signed-off-by: Martin Peres <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7212>

---

 include/GL/internal/dri_interface.h    |  3 ++-
 src/gallium/frontends/dri/dri2.c       | 19 ++++++++++++++++++-
 src/mesa/drivers/dri/common/dri_util.c | 14 +++++++++++++-
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index e40106575c0..76c50ad334f 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1795,7 +1795,7 @@ struct __DRIimageLookupExtensionRec {
  * This extension allows for common DRI2 options
  */
 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
-#define __DRI2_CONFIG_QUERY_VERSION 1
+#define __DRI2_CONFIG_QUERY_VERSION 2
 
 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
 struct __DRI2configQueryExtensionRec {
@@ -1804,6 +1804,7 @@ struct __DRI2configQueryExtensionRec {
    int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char 
*val);
    int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
    int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
+   int (*configQuerys)(__DRIscreen *screen, const char *var, char **val);
 };
 
 /**
diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
index 40cf8ca352c..f7a74df60d2 100644
--- a/src/gallium/frontends/dri/dri2.c
+++ b/src/gallium/frontends/dri/dri2.c
@@ -2017,17 +2017,34 @@ dri2GalliumConfigQueryf(__DRIscreen *sPriv, const char 
*var, float *val)
     return 0;
 }
 
+/**
+ * \brief the DRI2ConfigQueryExtension configQuerys method
+ */
+static int
+dri2GalliumConfigQuerys(__DRIscreen *sPriv, const char *var, char **val)
+{
+   struct dri_screen *screen = dri_screen(sPriv);
+
+   if (!driCheckOption(&screen->dev->option_cache, var, DRI_STRING))
+      return dri2ConfigQueryExtension.configQuerys(sPriv, var, val);
+
+    *val = driQueryOptionstr(&screen->dev->option_cache, var);
+
+    return 0;
+}
+
 /**
  * \brief the DRI2ConfigQueryExtension struct.
  *
  * We first query the driver option cache. Then the dri2 option cache.
  */
 static const __DRI2configQueryExtension dri2GalliumConfigQueryExtension = {
-   .base = { __DRI2_CONFIG_QUERY, 1 },
+   .base = { __DRI2_CONFIG_QUERY, 2 },
 
    .configQueryb        = dri2GalliumConfigQueryb,
    .configQueryi        = dri2GalliumConfigQueryi,
    .configQueryf        = dri2GalliumConfigQueryf,
+   .configQuerys        = dri2GalliumConfigQuerys,
 };
 
 /**
diff --git a/src/mesa/drivers/dri/common/dri_util.c 
b/src/mesa/drivers/dri/common/dri_util.c
index 35d61572d76..430a585f99d 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -767,6 +767,17 @@ dri2ConfigQueryf(__DRIscreen *screen, const char *var, 
float *val)
     return 0;
 }
 
+static int
+dri2ConfigQuerys(__DRIscreen *screen, const char *var, char **val)
+{
+   if (!driCheckOption(&screen->optionCache, var, DRI_STRING))
+      return -1;
+
+    *val = driQueryOptionstr(&screen->optionCache, var);
+
+    return 0;
+}
+
 static unsigned int
 driGetAPIMask(__DRIscreen *screen)
 {
@@ -832,11 +843,12 @@ const __DRIswrastExtension driSWRastExtension = {
 };
 
 const __DRI2configQueryExtension dri2ConfigQueryExtension = {
-   .base = { __DRI2_CONFIG_QUERY, 1 },
+   .base = { __DRI2_CONFIG_QUERY, 2 },
 
    .configQueryb        = dri2ConfigQueryb,
    .configQueryi        = dri2ConfigQueryi,
    .configQueryf        = dri2ConfigQueryf,
+   .configQuerys        = dri2ConfigQuerys,
 };
 
 const __DRI2flushControlExtension dri2FlushControlExtension = {

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to