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 <ajax@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Martin Peres <martin.peres@mupuf.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7212>
This commit is contained in:
Martin Peres
2020-10-15 15:23:05 +03:00
parent f9763b2054
commit 4ba255dfaa
3 changed files with 33 additions and 3 deletions

View File

@@ -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);
};
/**

View File

@@ -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,
};
/**

View File

@@ -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 = {