From df3d3ea33e723a7e971698a44b4a155ad5313b7e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Sep 2020 17:06:07 -0700 Subject: [PATCH] driconf: Make a DRI_CONF_OPT_S() for string options. This gets rid of most of the remaining special case option definitions. Reviewed-by: Eric Engestrom Part-of: --- src/util/driconf.h | 18 +++++++++--------- src/util/tests/xmlconfig.cpp | 8 ++------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/util/driconf.h b/src/util/driconf.h index fc7244ed46c..35d8fe1fa48 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -127,6 +127,12 @@ DRI_CONF_DESC(desc) \ DRI_CONF_OPT_END +/* Note that def should not be quoted in the caller! */ +#define DRI_CONF_OPT_S(name, def, desc) \ + DRI_CONF_OPT_BEGIN(name, string, def) \ + DRI_CONF_DESC(desc) \ + DRI_CONF_OPT_END + #define DRI_CONF_OPT_E(name, def, min, max, desc, values) \ DRI_CONF_OPT_BEGIN_V(name, enum, def, #min ":" #max) \ DRI_CONF_DESC_BEGIN(desc) \ @@ -222,9 +228,7 @@ DRI_CONF_SECTION_BEGIN \ "Allow out-of-order draw optimizations. Set when Z fighting doesn't have to be accurate.") #define DRI_CONF_FORCE_GL_VENDOR(def) \ -DRI_CONF_OPT_BEGIN(force_gl_vendor, string, def) \ - DRI_CONF_DESC("Override GPU vendor string.") \ -DRI_CONF_OPT_END + DRI_CONF_OPT_S(force_gl_vendor, def, "Override GPU vendor string.") #define DRI_CONF_FORCE_COMPAT_PROFILE(def) \ DRI_CONF_OPT_B(force_compat_profile, def, \ @@ -380,14 +384,10 @@ DRI_CONF_SECTION_BEGIN \ DRI_CONF_DESC("Initialization") #define DRI_CONF_DEVICE_ID_PATH_TAG(def) \ -DRI_CONF_OPT_BEGIN(device_id, string, def) \ - DRI_CONF_DESC("Define the graphic device to use if possible") \ -DRI_CONF_OPT_END + DRI_CONF_OPT_S(device_id, def, "Define the graphic device to use if possible") #define DRI_CONF_DRI_DRIVER(def) \ -DRI_CONF_OPT_BEGIN(dri_driver, string, def) \ - DRI_CONF_DESC("Override the DRI driver to load") \ -DRI_CONF_OPT_END + DRI_CONF_OPT_S(dri_driver, def, "Override the DRI driver to load") /** * \brief Gallium-Nine specific configuration options diff --git a/src/util/tests/xmlconfig.cpp b/src/util/tests/xmlconfig.cpp index a5a0f49f9a5..4b04cac1988 100644 --- a/src/util/tests/xmlconfig.cpp +++ b/src/util/tests/xmlconfig.cpp @@ -96,9 +96,7 @@ TEST_F(xmlconfig_test, enums) TEST_F(xmlconfig_test, string) { driconf(DRI_CONF_TEST_OPT( - DRI_CONF_OPT_BEGIN(opt, string, value) - DRI_CONF_DESC("option") - DRI_CONF_OPT_END)); + DRI_CONF_OPT_S(opt, value, "option"))); EXPECT_STREQ(driQueryOptionstr(&options, "opt"), "value"); } @@ -123,9 +121,7 @@ TEST_F(xmlconfig_test, copy_cache) { driconf(DRI_CONF_TEST_OPT( DRI_CONF_OPT_B(mesa_b_option, "true", "description") - DRI_CONF_OPT_BEGIN(mesa_s_option, string, value) - DRI_CONF_DESC("option") - DRI_CONF_OPT_END)); + DRI_CONF_OPT_S(mesa_s_option, value, "description"))); driOptionCache cache;