From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/private/vkd3d_debug.h | 2 ++ libs/vkd3d-common/debug.c | 42 ++++++++++++++++++++--------------- libs/vkd3d/device.c | 7 +----- 3 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/include/private/vkd3d_debug.h b/include/private/vkd3d_debug.h index 80c5781d1921..2ef8a003519d 100644 --- a/include/private/vkd3d_debug.h +++ b/include/private/vkd3d_debug.h @@ -22,6 +22,7 @@ #include "vkd3d_common.h"
#include <stdarg.h> +#include <stdbool.h> #include <stdint.h>
#ifdef VKD3D_NO_TRACE_MESSAGES @@ -100,6 +101,7 @@ struct vkd3d_debug_option uint64_t flag; };
+bool vkd3d_debug_list_has_member(const char *string, const char *member) DECLSPEC_HIDDEN; uint64_t vkd3d_parse_debug_options(const char *string, const struct vkd3d_debug_option *options, unsigned int option_count) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-common/debug.c b/libs/vkd3d-common/debug.c index 9a27c22eda5d..33deed6592ab 100644 --- a/libs/vkd3d-common/debug.c +++ b/libs/vkd3d-common/debug.c @@ -323,34 +323,40 @@ static bool is_option_separator(char c) return c == ',' || c == ';' || c == '\0'; }
+bool vkd3d_debug_list_has_member(const char *string, const char *member) +{ + char prev_char, next_char; + const char *p; + + p = string; + while (p) + { + if ((p = strstr(p, member))) + { + prev_char = p > string ? p[-1] : 0; + p += strlen(member); + next_char = *p; + + if (is_option_separator(prev_char) && is_option_separator(next_char)) + return true; + } + } + + return false; +} + uint64_t vkd3d_parse_debug_options(const char *string, const struct vkd3d_debug_option *options, unsigned int option_count) { - char prev_char, next_char; uint64_t flags = 0; unsigned int i; - const char *p;
for (i = 0; i < option_count; ++i) { const struct vkd3d_debug_option *opt = &options[i];
- p = string; - while (p) - { - if ((p = strstr(p, opt->name))) - { - prev_char = p > string ? p[-1] : 0; - p += strlen(opt->name); - next_char = *p; - - if (is_option_separator(prev_char) && is_option_separator(next_char)) - { - flags |= opt->flag; - break; - } - } - } + if (vkd3d_debug_list_has_member(string, opt->name)) + flags |= opt->flag; }
return flags; diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 5c1580808224..5239911b6a06 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -180,16 +180,11 @@ static unsigned int get_spec_version(const VkExtensionProperties *extensions, static bool is_extension_disabled(const char *extension_name) { const char *disabled_extensions; - const char *s; - size_t len;
if (!(disabled_extensions = getenv("VKD3D_DISABLE_EXTENSIONS"))) return false;
- if (!(s = strstr(disabled_extensions, extension_name))) - return false; - len = strlen(extension_name); - return s[len] == ';' || s[len] == '\0'; + return vkd3d_debug_list_has_member(disabled_extensions, extension_name); }
static bool has_extension(const VkExtensionProperties *extensions,