From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/d3dx9_private.h | 2 ++ dlls/d3dx9_36/tests/texture.c | 6 +++--- dlls/d3dx9_36/texture.c | 20 ++++++++++++++------ 3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 248b6a69b00..3065752a36d 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -33,6 +33,8 @@
#define FOURCC_TX_1 0x54580100
+#define D3DX9_FILTER_INVALID_BITS 0xff80fff8 + struct vec4 { float x, y, z, w; diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index ffc03a4d37e..b58dd104760 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -2186,7 +2186,7 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device) texture = NULL; hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_24bit, sizeof(dds_24bit), 32, 32, 6, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, test_filter_values[i].filter, 0, NULL, NULL, &texture); - todo_wine_if(FAILED(hr)) ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); if (texture) IDirect3DTexture9_Release(texture);
@@ -2568,7 +2568,7 @@ static void test_D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, dds_cube_map, sizeof(dds_cube_map), D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, test_filter_values[i].filter, 0, NULL, NULL, &cube_texture); - todo_wine_if(FAILED(hr)) ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); if (cube_texture) IDirect3DCubeTexture9_Release(cube_texture);
@@ -2874,7 +2874,7 @@ static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *dev hr = D3DXCreateVolumeTextureFromFileInMemoryEx(device, dds_24bit_8_8, sizeof(dds_24bit_8_8), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, test_filter_values[i].filter, 0, NULL, NULL, &texture); - todo_wine_if(FAILED(hr)) ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); if (texture) IDirect3DVolumeTexture9_Release(texture);
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index a65a955cebf..93ab7142ab7 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -562,6 +562,17 @@ static D3DFORMAT get_alpha_replacement_format(D3DFORMAT format) return format; }
+static uint32_t d3dx9_get_mip_filter_value(uint32_t mip_filter, uint32_t *skip_levels) +{ + uint32_t filter = (mip_filter == D3DX_DEFAULT) ? D3DX_FILTER_BOX : mip_filter & ~D3DX9_FILTER_INVALID_BITS; + + *skip_levels = mip_filter != D3DX_DEFAULT ? mip_filter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0; + *skip_levels &= D3DX_SKIP_DDS_MIP_LEVELS_MASK; + if (!(filter & 0x7) || (filter & 0x7) > D3DX_FILTER_BOX) + filter = (filter & 0x007f0000) | D3DX_FILTER_BOX; + return filter; +} + HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, @@ -587,8 +598,7 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi return D3DERR_INVALIDCALL;
staging_tex = tex = *texture = NULL; - skip_levels = mipfilter != D3DX_DEFAULT ? mipfilter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0; - skip_levels &= D3DX_SKIP_DDS_MIP_LEVELS_MASK; + mipfilter = d3dx9_get_mip_filter_value(mipfilter, &skip_levels); hr = d3dx_image_init(srcdata, srcdatasize, &image, skip_levels, 0); if (FAILED(hr)) { @@ -1115,8 +1125,7 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic return D3DERR_INVALIDCALL;
staging_tex = tex = *volume_texture = NULL; - skip_levels = mip_filter != D3DX_DEFAULT ? mip_filter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0; - skip_levels &= D3DX_SKIP_DDS_MIP_LEVELS_MASK; + mip_filter = d3dx9_get_mip_filter_value(mip_filter, &skip_levels); hr = d3dx_image_init(data, data_size, &image, skip_levels, 0); if (FAILED(hr)) { @@ -1397,8 +1406,7 @@ HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, return D3DERR_INVALIDCALL;
staging_tex = tex = *cube_texture = NULL; - skip_levels = mip_filter != D3DX_DEFAULT ? mip_filter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0; - skip_levels &= D3DX_SKIP_DDS_MIP_LEVELS_MASK; + mip_filter = d3dx9_get_mip_filter_value(mip_filter, &skip_levels); hr = d3dx_image_init(src_data, src_data_size, &image, skip_levels, 0); if (FAILED(hr)) {