The result of abs(INT_MIN) is INT_MIN, which breaks the ulps comparison.
See also: https://gitlab.winehq.org/wine/vkd3d/-/commit/69ecfdfb
From: Jeff Smith whydoubt@gmail.com
The result of abs(INT_MIN) is INT_MIN, which breaks the ulps comparison. --- dlls/d3dx9_36/tests/effect.c | 12 ++++++++---- dlls/d3dx9_36/tests/math.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index aed30118a44..edc35235c3e 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -23,6 +23,13 @@ #include "d3dx9.h"
/* helper functions */ +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, UINT ulps) { INT x = *(INT *)&f; @@ -33,10 +40,7 @@ static BOOL compare_float(FLOAT f, FLOAT g, UINT ulps) if (y < 0) y = INT_MIN - y;
- if (abs(x - y) > ulps) - return FALSE; - - return TRUE; + return compare_uint(x, y, ulps); }
static inline INT get_int(D3DXPARAMETER_TYPE type, const void *data) diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c index 5d112bd4b92..79f02e6536e 100644 --- a/dlls/d3dx9_36/tests/math.c +++ b/dlls/d3dx9_36/tests/math.c @@ -24,6 +24,13 @@ #include <math.h> #include <stdint.h>
+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) { int x = *(int *)&f; @@ -34,10 +41,7 @@ static BOOL compare_float(float f, float g, unsigned int ulps) if (y < 0) y = INT_MIN - y;
- if (abs(x - y) > ulps) - return FALSE; - - return TRUE; + return compare_uint(x, y, ulps); }
static BOOL compare_vec2(const D3DXVECTOR2 *v1, const D3DXVECTOR2 *v2, unsigned int ulps)
From: Jeff Smith whydoubt@gmail.com
The result of abs(INT_MIN) is INT_MIN, which breaks the ulps comparison. --- dlls/d3dx10_43/tests/d3dx10.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 8257ab1e919..e9c215d3c45 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -1120,6 +1120,13 @@ static ULONG get_refcount(void *iface) return IUnknown_Release(unknown); }
+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) { int x = *(int *)&f; @@ -1130,10 +1137,7 @@ static BOOL compare_float(float f, float g, unsigned int ulps) if (y < 0) y = INT_MIN - y;
- if (abs(x - y) > ulps) - return FALSE; - - return TRUE; + return compare_uint(x, y, ulps); }
static char *get_str_a(const WCHAR *wstr)
From: Jeff Smith whydoubt@gmail.com
The result of abs(INT_MIN) is INT_MIN, which breaks the ulps comparison. --- dlls/d3dcompiler_43/tests/hlsl_d3d11.c | 12 ++++++++---- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c index ac0cf20e5ee..c853b14f13a 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c @@ -57,6 +57,13 @@ static ID3D10Blob *compile_shader_(unsigned int line, const char *source, const return blob; }
+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) { int x = *(int *)&f; @@ -67,10 +74,7 @@ static BOOL compare_float(float f, float g, unsigned int ulps) if (y < 0) y = INT_MIN - y;
- if (abs(x - y) > ulps) - return FALSE; - - return TRUE; + return compare_uint(x, y, ulps); }
static BOOL compare_vec4(const struct vec4 *vec, float x, float y, float z, float w, unsigned int ulps) diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 1ba283f4d99..42fb3b97fc2 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -326,6 +326,13 @@ static struct vec4 get_color_vec4(IDirect3DDevice9 *device, unsigned int x, unsi return ret; }
+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) { int x = *(int *)&f; @@ -336,10 +343,7 @@ static BOOL compare_float(float f, float g, unsigned int ulps) if (y < 0) y = INT_MIN - y;
- if (abs(x - y) > ulps) - return FALSE; - - return TRUE; + return compare_uint(x, y, ulps); }
static BOOL compare_vec4(const struct vec4 *vec, float x, float y, float z, float w, unsigned int ulps)