From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/private/vkd3d_common.h | 23 +++++++++++++++++++++++ libs/vkd3d-shader/spirv.c | 2 +- libs/vkd3d-shader/vkd3d_shader_main.c | 2 +- tests/vkd3d_shader_api.c | 6 +++++- 4 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index 1129f1e3001a..244209243594 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -88,6 +88,29 @@ static inline unsigned int vkd3d_log2i(unsigned int x) #endif }
+static inline int ascii_isupper(int c) +{ + return 'A' <= c && c <= 'Z'; +} + +static inline int ascii_tolower(int c) +{ + return ascii_isupper(c) ? c - 'A' + 'a' : c; +} + +static inline int ascii_strcasecmp(const char *a, const char *b) +{ + int c_a, c_b; + + do + { + c_a = ascii_tolower(*a++); + c_b = ascii_tolower(*b++); + } while (c_a == c_b && c_a != '\0'); + + return c_a - c_b; +} + #ifndef _WIN32 # if HAVE_SYNC_ADD_AND_FETCH static inline LONG InterlockedIncrement(LONG volatile *x) diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index ad927b2538f4..dc51644db1d0 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -3709,7 +3709,7 @@ static void vkd3d_dxbc_compiler_decorate_xfb_output(struct vkd3d_dxbc_compiler * const struct vkd3d_shader_transform_feedback_element *e = &xfb_info->elements[i];
if (e->stream_index == signature_element->stream_index - && !strcasecmp(e->semantic_name, signature_element->semantic_name) + && !ascii_strcasecmp(e->semantic_name, signature_element->semantic_name) && e->semantic_index == signature_element->semantic_index) { xfb_element = e; diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 9848202a0c72..aa486cca609a 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -401,7 +401,7 @@ struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element( e = signature->elements; for (i = 0; i < signature->element_count; ++i) { - if (!strcasecmp(e[i].semantic_name, semantic_name) + if (!ascii_strcasecmp(e[i].semantic_name, semantic_name) && e[i].semantic_index == semantic_index && e[i].stream_index == stream_index) return &e[i]; diff --git a/tests/vkd3d_shader_api.c b/tests/vkd3d_shader_api.c index 41067c063312..f9bec7e41a37 100644 --- a/tests/vkd3d_shader_api.c +++ b/tests/vkd3d_shader_api.c @@ -19,6 +19,8 @@ #include "vkd3d_test.h" #include <vkd3d_shader.h>
+#include <locale.h> + static void test_invalid_shaders(void) { struct vkd3d_shader_code spirv; @@ -112,7 +114,7 @@ static void test_vkd3d_shader_pfns(void)
rc = pfn_vkd3d_shader_parse_input_signature(&vs, &signature); ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc); - element = pfn_vkd3d_shader_find_signature_element(&signature, "POSITION", 0, 0); + element = pfn_vkd3d_shader_find_signature_element(&signature, "position", 0, 0); ok(element, "Could not find shader signature element.\n"); pfn_vkd3d_shader_free_shader_signature(&signature);
@@ -128,6 +130,8 @@ static void test_vkd3d_shader_pfns(void)
START_TEST(vkd3d_shader_api) { + setlocale(LC_ALL, ""); + run_test(test_invalid_shaders); run_test(test_vkd3d_shader_pfns); }