wined3d: Properly compare integers in wined3d_pipeline_layout_vk_compare().

As pointed out by Giovanni, modular subtraction doesn't produce a total order;
in particular, it's not transitive. For the values likely to be encountered by
wined3d_pipeline_layout_vk_compare(), this is perhaps unlikely to be an issue
in practice. However, that's not necessarily the case for e.g. handles or
masks.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2022-01-20 17:30:56 +01:00 committed by Alexandre Julliard
parent 0a1b3fc136
commit 9b98d86f29
2 changed files with 8 additions and 2 deletions

View File

@ -1797,9 +1797,10 @@ static int wined3d_pipeline_layout_vk_compare(const void *key, const struct wine
const struct wined3d_pipeline_layout_key_vk *a = key;
const struct wined3d_pipeline_layout_key_vk *b = &WINE_RB_ENTRY_VALUE(entry,
const struct wined3d_pipeline_layout_vk, entry)->key;
int ret;
if (a->binding_count != b->binding_count)
return a->binding_count - b->binding_count;
if ((ret = wined3d_uint32_compare(a->binding_count, b->binding_count)))
return ret;
return memcmp(a->bindings, b->bindings, a->binding_count * sizeof(*a->bindings));
}

View File

@ -447,6 +447,11 @@ static inline unsigned int wined3d_popcount(unsigned int x)
#endif
}
static inline int wined3d_uint32_compare(uint32_t x, uint32_t y)
{
return (x > y) - (x < y);
}
#define ORM_BACKBUFFER 0
#define ORM_FBO 1