vkd3d: Handle lists in debug env vars consistently.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2019-05-17 10:39:14 +02:00 committed by Alexandre Julliard
parent ee1b8cc511
commit 51b930192a
3 changed files with 27 additions and 24 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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,