diff options
author | Eric Anholt <eric@anholt.net> | 2020-09-28 11:21:00 -0700 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-10-02 23:59:52 +0000 |
commit | 23c3eb1fe161d9eda0f6adf1d70780e102e20bca (patch) | |
tree | 7c205f6de6163fedfad3a978458b66ebd79e066f | |
parent | 4f37161a8f221cc31493c1ec3fb017f486754626 (diff) | |
download | mesa-23c3eb1fe161d9eda0f6adf1d70780e102e20bca.tar.gz mesa-23c3eb1fe161d9eda0f6adf1d70780e102e20bca.tar.bz2 mesa-23c3eb1fe161d9eda0f6adf1d70780e102e20bca.zip |
driconf: Delete disjoint range support.
The only user was radeon/r200, which was using it to have something that
looks a lot like an enum value return a float from the config option.
Just convert that option to a plain float value (for compat with existing
driconfs) with the min and max of its disjoint range as the range. The
driver's option handling code already correctly deals with other values in
the range.
The disjoint range support was a bunch of extra parsing for this dead
driver, and made turning driconf into static structs difficult.
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_screen.c | 11 | ||||
-rw-r--r-- | src/util/00-mesa-defaults.conf | 4 | ||||
-rw-r--r-- | src/util/tests/xmlconfig.cpp | 4 | ||||
-rw-r--r-- | src/util/xmlconfig.c | 131 | ||||
-rw-r--r-- | src/util/xmlconfig.h | 3 |
5 files changed, 46 insertions, 107 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 3d41c1efdce..d421cfe280f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -86,10 +86,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define DRI_CONF_NO_NEG_LOD_BIAS(def) \ DRI_CONF_OPT_B(no_neg_lod_bias, def, "Forbid negative texture LOD bias") -#define DRI_CONF_DEF_MAX_ANISOTROPY(def,range) \ -DRI_CONF_OPT_BEGIN_V(def_max_anisotropy,float,def,range) \ - DRI_CONF_DESC("Initial maximum value for anisotropic texture filtering") \ -DRI_CONF_OPT_END +#define DRI_CONF_DEF_MAX_ANISOTROPY(def, min, max) \ + DRI_CONF_OPT_F(def_max_anisotropy,def, min, max, \ + "Initial maximum value for anisotropic texture filtering") #if defined(RADEON_R100) /* R100 */ static const __DRIconfigOptionsExtension radeon_config_options = { @@ -105,7 +104,7 @@ DRI_CONF_BEGIN DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) - DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0") + DRI_CONF_DEF_MAX_ANISOTROPY(1.0, 1.0, 16.0) DRI_CONF_NO_NEG_LOD_BIAS("false") DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER) DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC) @@ -129,7 +128,7 @@ DRI_CONF_BEGIN DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) - DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0") + DRI_CONF_DEF_MAX_ANISOTROPY(1.0, 1.0, 16.0) DRI_CONF_NO_NEG_LOD_BIAS("false") DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER) DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC) diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf index f11deb69472..2cd9233411d 100644 --- a/src/util/00-mesa-defaults.conf +++ b/src/util/00-mesa-defaults.conf @@ -41,8 +41,8 @@ TODO: document the other workarounds. <!ELEMENT engine (option+)> <!-- engine_name_match: A regexp matching the engine name --> - <!-- engine_version: A list of version in range format - (version 1 to 4 and version 7 to 8 : "1:4,7:8") --> + <!-- engine_versions: A version in range format + (version 1 to 4 : "1:4") --> <!ATTLIST engine engine_name_match CDATA #REQUIRED engine_versions CDATA #REQUIRED> diff --git a/src/util/tests/xmlconfig.cpp b/src/util/tests/xmlconfig.cpp index 4b04cac1988..e61b0f4eefe 100644 --- a/src/util/tests/xmlconfig.cpp +++ b/src/util/tests/xmlconfig.cpp @@ -78,9 +78,7 @@ TEST_F(xmlconfig_test, ints) TEST_F(xmlconfig_test, floats) { driconf(DRI_CONF_TEST_OPT( - DRI_CONF_OPT_BEGIN_V(opt, float, 2.0, "1.0,2.0,3.0") - DRI_CONF_DESC("option") - DRI_CONF_OPT_END)); + DRI_CONF_OPT_F(opt, 2.0, 1.0, 2.0, "option"))); EXPECT_EQ(driQueryOptionf(&options, "opt"), 2.0); } diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c index 6426f590e92..ad16dc0ce7c 100644 --- a/src/util/xmlconfig.c +++ b/src/util/xmlconfig.c @@ -294,94 +294,53 @@ parseValue(driOptionValue *v, driOptionType type, const XML_Char *string) /** \brief Parse a list of ranges of type info->type. */ static unsigned char -parseRanges(driOptionInfo *info, const XML_Char *string) +parseRange(driOptionInfo *info, const XML_Char *string) { - XML_Char *cp, *range; - uint32_t nRanges, i; - driOptionRange *ranges; + XML_Char *cp; XSTRDUP(cp, string); - /* pass 1: determine the number of ranges (number of commas + 1) */ - range = cp; - for (nRanges = 1; *range; ++range) - if (*range == ',') - ++nRanges; - if ((ranges = malloc(nRanges*sizeof(driOptionRange))) == NULL) { - fprintf(stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); - abort(); + XML_Char *sep; + sep = strchr(cp, ':'); + if (!sep) { + free(cp); + return false; } - /* pass 2: parse all ranges into preallocated array */ - range = cp; - for (i = 0; i < nRanges; ++i) { - XML_Char *end, *sep; - assert(range); - end = strchr(range, ','); - if (end) - *end = '\0'; - sep = strchr(range, ':'); - if (sep) { /* non-empty interval */ - *sep = '\0'; - if (!parseValue(&ranges[i].start, info->type, range) || - !parseValue(&ranges[i].end, info->type, sep+1)) - break; - if (info->type == DRI_INT && - ranges[i].start._int > ranges[i].end._int) - break; - if (info->type == DRI_FLOAT && - ranges[i].start._float > ranges[i].end._float) - break; - } else { /* empty interval */ - if (!parseValue(&ranges[i].start, info->type, range)) - break; - ranges[i].end = ranges[i].start; - } - if (end) - range = end+1; - else - range = NULL; - } - free(cp); - if (i < nRanges) { - free(ranges); + *sep = '\0'; + if (!parseValue(&info->range.start, info->type, cp) || + !parseValue(&info->range.end, info->type, sep+1)) + return false; + if (info->type == DRI_INT && + info->range.start._int >= info->range.end._int) + return false; + if (info->type == DRI_FLOAT && + info->range.start._float >= info->range.end._float) return false; - } else - assert(range == NULL); - info->nRanges = nRanges; - info->ranges = ranges; + free(cp); return true; } -/** \brief Check if a value is in one of info->ranges. */ +/** \brief Check if a value is in info->range. */ static bool checkValue(const driOptionValue *v, const driOptionInfo *info) { - uint32_t i; - assert(info->type != DRI_BOOL); /* should be caught by the parser */ - if (info->nRanges == 0) - return true; switch (info->type) { case DRI_ENUM: /* enum is just a special integer */ case DRI_INT: - for (i = 0; i < info->nRanges; ++i) - if (v->_int >= info->ranges[i].start._int && - v->_int <= info->ranges[i].end._int) - return true; - break; + return (info->range.start._int == info->range.end._int || + (v->_int >= info->range.start._int && + v->_int <= info->range.end._int)); + case DRI_FLOAT: - for (i = 0; i < info->nRanges; ++i) - if (v->_float >= info->ranges[i].start._float && - v->_float <= info->ranges[i].end._float) - return true; - break; - case DRI_STRING: - break; + return (info->range.start._float == info->range.end._float || + (v->_float >= info->range.start._float && + v->_float <= info->range.end._float)); + default: - assert(0); /* should never happen */ + return true; } - return false; } /** @@ -570,7 +529,7 @@ parseOptInfoAttr(struct OptInfoData *data, const XML_Char **attr) if (attrVal[OA_VALID]) { if (cache->info[opt].type == DRI_BOOL) XML_FATAL1("boolean option with valid attribute."); - if (!parseRanges(&cache->info[opt], attrVal[OA_VALID])) + if (!parseRange(&cache->info[opt], attrVal[OA_VALID])) XML_FATAL("illegal valid attribute: %s.", attrVal[OA_VALID]); if (!checkValue(&cache->values[opt], &cache->info[opt])) XML_FATAL("default value out of valid range '%s': %s.", @@ -578,8 +537,7 @@ parseOptInfoAttr(struct OptInfoData *data, const XML_Char **attr) } else if (cache->info[opt].type == DRI_ENUM) { XML_FATAL1("valid attribute missing in option (mandatory for enums)."); } else { - cache->info[opt].nRanges = 0; - cache->info[opt].ranges = NULL; + memset(&cache->info[opt].range, 0, sizeof(cache->info[opt].range)); } } @@ -762,20 +720,6 @@ parseDeviceAttr(struct OptConfData *data, const XML_Char **attr) } } -static bool -valueInRanges(const driOptionInfo *info, uint32_t value) -{ - uint32_t i; - - for (i = 0; i < info->nRanges; i++) { - if (info->ranges[i].start._int <= value && - info->ranges[i].end._int >= value) - return true; - } - - return false; -} - /** \brief Parse attributes of an application element. */ static void parseAppAttr(struct OptConfData *data, const XML_Char **attr) @@ -785,7 +729,7 @@ parseAppAttr(struct OptConfData *data, const XML_Char **attr) const XML_Char *sha1 = NULL; const XML_Char *application_name_match = NULL; const XML_Char *application_versions = NULL; - driOptionInfo version_ranges = { + driOptionInfo version_range = { .type = DRI_INT, }; @@ -836,8 +780,9 @@ parseAppAttr(struct OptConfData *data, const XML_Char **attr) XML_WARNING("Invalid application_name_match=\"%s\".", application_name_match); } if (application_versions) { - if (parseRanges(&version_ranges, application_versions) && - !valueInRanges(&version_ranges, data->applicationVersion)) + driOptionValue v = { ._int = data->applicationVersion }; + if (parseRange(&version_range, application_versions) && + !checkValue(&v, &version_range)) data->ignoringApp = data->inApp; } } @@ -848,7 +793,7 @@ parseEngineAttr(struct OptConfData *data, const XML_Char **attr) { uint32_t i; const XML_Char *engine_name_match = NULL, *engine_versions = NULL; - driOptionInfo version_ranges = { + driOptionInfo version_range = { .type = DRI_INT, }; for (i = 0; attr[i]; i += 2) { @@ -868,12 +813,11 @@ parseEngineAttr(struct OptConfData *data, const XML_Char **attr) XML_WARNING("Invalid engine_name_match=\"%s\".", engine_name_match); } if (engine_versions) { - if (parseRanges(&version_ranges, engine_versions) && - !valueInRanges(&version_ranges, data->engineVersion)) + driOptionValue v = { ._int = data->engineVersion }; + if (parseRange(&version_range, engine_versions) && + !checkValue(&v, &version_range)) data->ignoringApp = data->inApp; } - - free(version_ranges.ranges); } /** \brief Parse attributes of an option element. */ @@ -1167,7 +1111,6 @@ driDestroyOptionInfo(driOptionCache *info) for (i = 0; i < size; ++i) { if (info->info[i].name) { free(info->info[i].name); - free(info->info[i].ranges); } } free(info->info); diff --git a/src/util/xmlconfig.h b/src/util/xmlconfig.h index 39123475d48..adb25612bb1 100644 --- a/src/util/xmlconfig.h +++ b/src/util/xmlconfig.h @@ -66,8 +66,7 @@ typedef struct driOptionRange { typedef struct driOptionInfo { char *name; /**< \brief Name */ driOptionType type; /**< \brief Type */ - driOptionRange *ranges; /**< \brief Array of ranges */ - unsigned int nRanges; /**< \brief Number of ranges */ + driOptionRange range; /**< \brief Valid range of the option (or 0:0) */ } driOptionInfo; /** \brief Option cache |