vkd3d-shader/hlsl: Properly compare integers in compare_param_hlsl_types().

As pointed out by Giovanni Mascellani, modular subtraction doesn't produce a
total order; in particular, it's not transitive. The nature of the types being
compared here makes it unlikely this will be an issue in practice, but it's
both fragile and setting a poor example.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet
2022-02-28 12:23:48 +01:00
committed by Alexandre Julliard
parent 850badd38c
commit 790ab754d5
2 changed files with 17 additions and 12 deletions

View File

@@ -158,6 +158,11 @@ static inline uint32_t vkd3d_make_u32(uint16_t low, uint16_t high)
return low | ((uint32_t)high << 16);
}
static inline int vkd3d_u32_compare(uint32_t x, uint32_t y)
{
return (x > y) - (x < y);
}
static inline int ascii_isupper(int c)
{
return 'A' <= c && c <= 'Z';