Commit 9b98d86f authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0a1b3fc1
......@@ -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));
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment