From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/d3dx9_private.h | 7 +++++++ dlls/d3dx9_36/tests/d3dx9_test_images.h | 5 ++--- dlls/d3dx9_36/tests/texture.c | 9 +++------ dlls/d3dx9_36/texture.c | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 3065752a36d..ac7c06e73f6 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -34,6 +34,13 @@ #define FOURCC_TX_1 0x54580100
#define D3DX9_FILTER_INVALID_BITS 0xff80fff8 +static inline HRESULT d3dx9_validate_filter(uint32_t filter) +{ + if ((filter & D3DX9_FILTER_INVALID_BITS) || !(filter & 0x7) || ((filter & 0x7) > D3DX_FILTER_BOX)) + return D3DERR_INVALIDCALL; + + return D3D_OK; +}
struct vec4 { diff --git a/dlls/d3dx9_36/tests/d3dx9_test_images.h b/dlls/d3dx9_36/tests/d3dx9_test_images.h index 5ac14eb3eb4..605e4a0b860 100644 --- a/dlls/d3dx9_36/tests/d3dx9_test_images.h +++ b/dlls/d3dx9_36/tests/d3dx9_test_images.h @@ -27,7 +27,6 @@ static const struct { uint32_t filter; HRESULT expected_hr; - BOOL d3dx_filter_texture_todo; } test_filter_values[] = { @@ -36,11 +35,11 @@ test_filter_values[] = { 0x007f0001, D3D_OK }, { D3DX_DEFAULT_NONPOW2, D3DERR_INVALIDCALL }, { D3DX_FROM_FILE, D3DERR_INVALIDCALL }, - { 0, D3DERR_INVALIDCALL, .d3dx_filter_texture_todo = TRUE }, + { 0, D3DERR_INVALIDCALL }, { D3DX_FILTER_BOX + 1, D3DERR_INVALIDCALL }, { 0x0000ffff, D3DERR_INVALIDCALL }, /* Any unused filter bits being set results in failure. */ - { 0xff800001, D3DERR_INVALIDCALL, .d3dx_filter_texture_todo = TRUE }, + { 0xff800001, D3DERR_INVALIDCALL }, };
/* 1x1 bmp (1 bpp) */ diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index b58dd104760..e4baf3f5858 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -1064,8 +1064,7 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device) winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)tex, NULL, 0, test_filter_values[i].filter); - todo_wine_if(test_filter_values[i].d3dx_filter_texture_todo) ok(hr == test_filter_values[i].expected_hr, - "Unexpected hr %#lx.\n", hr); + ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
winetest_pop_context(); } @@ -1143,8 +1142,7 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device) winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)cubetex, NULL, 0, test_filter_values[i].filter); - todo_wine_if(test_filter_values[i].d3dx_filter_texture_todo) ok(hr == test_filter_values[i].expected_hr, - "Unexpected hr %#lx.\n", hr); + ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
winetest_pop_context(); } @@ -1176,8 +1174,7 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device) winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter);
hr = D3DXFilterTexture((IDirect3DBaseTexture9 *)voltex, NULL, 0, test_filter_values[i].filter); - todo_wine_if(test_filter_values[i].d3dx_filter_texture_todo) ok(hr == test_filter_values[i].expected_hr, - "Unexpected hr %#lx.\n", hr); + ok(hr == test_filter_values[i].expected_hr, "Unexpected hr %#lx.\n", hr);
winetest_pop_context(); } diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index 93ab7142ab7..b3fed65244e 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -59,8 +59,8 @@ HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture, if (!texture) return D3DERR_INVALIDCALL;
- if ((filter & 0xFFFF) > D3DX_FILTER_BOX && filter != D3DX_DEFAULT) - return D3DERR_INVALIDCALL; + if (filter != D3DX_DEFAULT && FAILED(hr = d3dx9_validate_filter(filter))) + return hr;
if (srclevel == D3DX_DEFAULT) srclevel = 0;