mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests: Use compare_uint() in compare_float().
Comparing the result of abs() is broken in the case that x - y == INT_MIN.
This commit is contained in:
parent
bdfec4886d
commit
69ecfdfb0b
Notes:
Alexandre Julliard
2023-06-27 23:35:17 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/247
@ -74,13 +74,6 @@ static void set_viewport(D3D12_VIEWPORT *vp, float x, float y,
|
|||||||
vp->MaxDepth = max_depth;
|
vp->MaxDepth = max_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
|
|
||||||
{
|
|
||||||
unsigned int diff = x > y ? x - y : y - x;
|
|
||||||
|
|
||||||
return diff <= max_diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool compare_color(DWORD c1, DWORD c2, BYTE max_diff)
|
static bool compare_color(DWORD c1, DWORD c2, BYTE max_diff)
|
||||||
{
|
{
|
||||||
return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)
|
return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)
|
||||||
|
@ -82,6 +82,13 @@ static inline bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
|
||||||
|
{
|
||||||
|
unsigned int diff = x > y ? x - y : y - x;
|
||||||
|
|
||||||
|
return diff <= max_diff;
|
||||||
|
}
|
||||||
|
|
||||||
static bool compare_float(float f, float g, unsigned int ulps)
|
static bool compare_float(float f, float g, unsigned int ulps)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -101,10 +108,7 @@ static bool compare_float(float f, float g, unsigned int ulps)
|
|||||||
if (y < 0)
|
if (y < 0)
|
||||||
y = INT_MIN - y;
|
y = INT_MIN - y;
|
||||||
|
|
||||||
if (abs(x - y) > ulps)
|
return compare_uint(x, y, ulps);
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool compare_uvec4(const struct uvec4 *v1, const struct uvec4 *v2)
|
static inline bool compare_uvec4(const struct uvec4 *v1, const struct uvec4 *v2)
|
||||||
|
Loading…
Reference in New Issue
Block a user