From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/d3dx9_test_images.h | 29 ++++- dlls/d3dx9_36/tests/surface.c | 30 ++++++ dlls/d3dx9_36/tests/texture.c | 136 +++++++++++++++++++++++- dlls/d3dx9_36/tests/volume.c | 26 ++++- 4 files changed, 216 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx9_36/tests/d3dx9_test_images.h b/dlls/d3dx9_36/tests/d3dx9_test_images.h index 655d9a87fde..8dabd8c2f84 100644 --- a/dlls/d3dx9_36/tests/d3dx9_test_images.h +++ b/dlls/d3dx9_36/tests/d3dx9_test_images.h @@ -1,6 +1,6 @@ /* - * Test images and functions used across the surface, texture and volume - * test files. + * Test images, functions and values used across the surface, texture and + * volume test files. * * Copyright 2024 Connor McAdams for CodeWeavers * @@ -23,6 +23,31 @@ #define COBJMACROS #include "d3dx9tex.h"
+static const struct +{ + uint32_t filter; + HRESULT expected_hr; + BOOL d3dx_filter_texture_todo; +} +test_filter_values[] = +{ + { D3DX_DEFAULT, D3D_OK }, + /* Any combo of MIRROR/DITHER/SRGB bits are valid. */ + { 0x007f0001, D3D_OK }, + { D3DX_DEFAULT_NONPOW2, D3DERR_INVALIDCALL }, + { D3DX_FROM_FILE, D3DERR_INVALIDCALL }, + { 0, D3DERR_INVALIDCALL, .d3dx_filter_texture_todo = TRUE }, + { D3DX_FILTER_BOX + 1, D3DERR_INVALIDCALL }, + { 0x0000ffff, D3DERR_INVALIDCALL }, + { 0x7c000001, D3DERR_INVALIDCALL, .d3dx_filter_texture_todo = TRUE }, + { 0x80000001, D3DERR_INVALIDCALL, .d3dx_filter_texture_todo = TRUE }, + /* + * Mip skip bits are 30-26, 25-23 are unused, but setting them results in + * failure. + */ + { 0x03800001, D3DERR_INVALIDCALL, .d3dx_filter_texture_todo = TRUE }, +}; + /* 1x1 bmp (1 bpp) */ static const uint8_t bmp_1bpp[] = { diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index cd31a024f73..c29f61a8e7d 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -779,6 +779,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) static const DWORD pixdata_a2r10g10b10[] = { 0x57395aff, 0x5b7668fd, 0xb0d856b5, 0xff2c61d6 }; static const uint32_t pixdata_a8r8g8b8[] = { 0x00102030, 0x40506070, 0x8090a0b0, 0xc0d0e0ff }; BYTE buffer[4 * 8 * 4]; + uint32_t i;
hr = create_file("testdummy.bmp", noimage, sizeof(noimage)); /* invalid image */ testdummy_ok = SUCCEEDED(hr); @@ -1053,6 +1054,17 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) hr = D3DXLoadSurfaceFromSurface(surf, NULL, NULL, newsurf, NULL, &destrect, D3DX_FILTER_NONE, 0); ok(hr == D3D_OK, "D3DXLoadSurfaceFromSurface returned %#lx, expected %#lx.\n", hr, D3D_OK);
+ for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter); + + hr = D3DXLoadSurfaceFromSurface(surf, NULL, NULL, newsurf, NULL, NULL, test_filter_values[i].filter, 0); + todo_wine_if(FAILED(test_filter_values[i].expected_hr)) ok(hr == test_filter_values[i].expected_hr, + "Unexpected hr %#lx.\n", hr); + + winetest_pop_context(); + } + IDirect3DSurface9_Release(newsurf);
check_release((IUnknown*)surf, 0); @@ -1213,6 +1225,24 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) hr = IDirect3DSurface9_UnlockRect(surf); ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx\n", hr);
+ SetRect(&rect, 0, 0, 2, 2); + for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter); + + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_24bit, sizeof(dds_24bit), NULL, + test_filter_values[i].filter, 0, NULL); + todo_wine_if(FAILED(test_filter_values[i].expected_hr)) ok(hr == test_filter_values[i].expected_hr, + "Unexpected hr %#lx.\n", hr); + + hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8b8g8r8, D3DFMT_A8B8G8R8, 8, NULL, &rect, + test_filter_values[i].filter, 0); + todo_wine_if(FAILED(test_filter_values[i].expected_hr)) ok(hr == test_filter_values[i].expected_hr, + "Unexpected hr %#lx.\n", hr); + + winetest_pop_context(); + } + check_release((IUnknown*)surf, 0); }
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c index bbfae36b4e9..495e9055f1e 100644 --- a/dlls/d3dx9_36/tests/texture.c +++ b/dlls/d3dx9_36/tests/texture.c @@ -1047,6 +1047,7 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device) IDirect3DCubeTexture9 *cubetex; IDirect3DVolumeTexture9 *voltex; HRESULT hr; + uint32_t i;
hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 5, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex, NULL);
@@ -1058,6 +1059,17 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device) hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_NONE); ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
+ for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + 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); + + winetest_pop_context(); + } + hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, NULL, 0, D3DX_FILTER_BOX + 1); /* Invalid filter */ ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
@@ -1126,6 +1138,17 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device) hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 0, D3DX_FILTER_BOX + 1); /* Invalid filter */ ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
+ for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + 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); + + winetest_pop_context(); + } + hr = D3DXFilterTexture((IDirect3DBaseTexture9*) cubetex, NULL, 5, D3DX_FILTER_NONE); /* Invalid miplevel */ ok(hr == D3DERR_INVALIDCALL, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL); IDirect3DCubeTexture9_Release(cubetex); @@ -1148,6 +1171,17 @@ static void test_D3DXFilterTexture(IDirect3DDevice9 *device) hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, 0, D3DX_FILTER_BOX); ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
+ for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + 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); + + winetest_pop_context(); + } + hr = D3DXFilterTexture((IDirect3DBaseTexture9*) voltex, NULL, level_count - 1, D3DX_DEFAULT); ok(hr == D3D_OK, "D3DXFilterTexture returned %#lx, expected %#lx\n", hr, D3D_OK);
@@ -2118,7 +2152,7 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device) }; HRESULT hr; struct surface_readback surface_rb; - uint32_t miplevels, mip_level; + uint32_t miplevels, mip_level, i; IDirect3DTexture9 *texture; IDirect3DSurface9 *surface; D3DXIMAGE_INFO img_info; @@ -2129,6 +2163,36 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device) ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx\n", hr, D3D_OK); IDirect3DTexture9_Release(texture);
+ for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter); + + texture = NULL; + hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_16bit, sizeof(dds_16bit), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, + 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, test_filter_values[i].filter, D3DX_DEFAULT, 0, NULL, NULL, &texture); + todo_wine_if(FAILED(test_filter_values[i].expected_hr)) ok(hr == test_filter_values[i].expected_hr, + "Unexpected hr %#lx.\n", hr); + if (texture) + IDirect3DTexture9_Release(texture); + + winetest_pop_context(); + } + + /* Mip filter argument values never cause failure. */ + for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Mip filter %d (%#x)", i, test_filter_values[i].filter); + + 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); + if (texture) + IDirect3DTexture9_Release(texture); + + winetest_pop_context(); + } + hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_16bit, sizeof(dds_16bit), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &texture); ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#lx, expected %#lx\n", hr, D3D_OK); @@ -2467,6 +2531,42 @@ static void test_D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); IDirect3DCubeTexture9_Release(cube_texture);
+ hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, dds_cube_map, sizeof(dds_cube_map), D3DX_DEFAULT, + D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &cube_texture); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + IDirect3DCubeTexture9_Release(cube_texture); + for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter); + + cube_texture = NULL; + hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, dds_cube_map, sizeof(dds_cube_map), D3DX_DEFAULT, + D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, test_filter_values[i].filter, D3DX_DEFAULT, + 0, NULL, NULL, &cube_texture); + todo_wine_if(FAILED(test_filter_values[i].expected_hr)) ok(hr == test_filter_values[i].expected_hr, + "Unexpected hr %#lx.\n", hr); + if (cube_texture) + IDirect3DCubeTexture9_Release(cube_texture); + + winetest_pop_context(); + } + + /* Mip filter argument values never cause failure. */ + for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Mip filter %d (%#x)", i, test_filter_values[i].filter); + + cube_texture = NULL; + 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); + if (cube_texture) + IDirect3DCubeTexture9_Release(cube_texture); + + winetest_pop_context(); + } + if (!is_autogenmipmap_supported(device, D3DRTYPE_CUBETEXTURE)) { skip("No D3DUSAGE_AUTOGENMIPMAP support for cube textures\n"); @@ -2708,7 +2808,7 @@ static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *dev }; IDirect3DVolumeTexture9 *volume_texture, *texture; struct volume_readback volume_rb; - uint32_t mip_level, x, y, z; + uint32_t mip_level, x, y, z, i; D3DXIMAGE_INFO img_info; D3DVOLUME_DESC desc; HRESULT hr; @@ -2732,6 +2832,38 @@ static void test_D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *dev check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE); IDirect3DVolumeTexture9_Release(texture);
+ for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter); + + texture = NULL; + 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, + test_filter_values[i].filter, D3DX_DEFAULT, 0, NULL, NULL, &texture); + todo_wine_if(FAILED(test_filter_values[i].expected_hr)) ok(hr == test_filter_values[i].expected_hr, + "Unexpected hr %#lx.\n", hr); + if (texture) + IDirect3DVolumeTexture9_Release(texture); + + winetest_pop_context(); + } + + /* Mip filter argument values never cause failure. */ + for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Mip filter %d (%#x)", i, test_filter_values[i].filter); + + texture = NULL; + 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); + if (texture) + IDirect3DVolumeTexture9_Release(texture); + + winetest_pop_context(); + } + 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, D3DX_SKIP_DDS_MIP_LEVELS(1, D3DX_FILTER_POINT), 0, &img_info, NULL, &texture); diff --git a/dlls/d3dx9_36/tests/volume.c b/dlls/d3dx9_36/tests/volume.c index c0bad638597..c961120eb0d 100644 --- a/dlls/d3dx9_36/tests/volume.c +++ b/dlls/d3dx9_36/tests/volume.c @@ -191,6 +191,18 @@ static void test_D3DXLoadVolumeFromMemory(IDirect3DDevice9 *device) hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 32, NULL, &src_box, D3DX_DEFAULT, 0); ok(hr == D3D_OK, "D3DXLoadVolumeFromMemory returned %#lx, expected %#lx\n", hr, D3D_OK);
+ for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter); + + hr = D3DXLoadVolumeFromMemory(volume, NULL, &dst_box, pixels, D3DFMT_A8R8G8B8, 16, 32, NULL, &src_box, + test_filter_values[i].filter, 0); + todo_wine_if(FAILED(test_filter_values[i].expected_hr)) ok(hr == test_filter_values[i].expected_hr, + "Unexpected hr %#lx.\n", hr); + + winetest_pop_context(); + } + IDirect3DVolume9_Release(volume); IDirect3DVolumeTexture9_Release(volume_texture); } @@ -199,7 +211,7 @@ static void test_D3DXLoadVolumeFromFileInMemory(IDirect3DDevice9 *device) { HRESULT hr; D3DBOX src_box; - uint32_t x, y, z; + uint32_t x, y, z, i; D3DVOLUME_DESC desc; D3DXIMAGE_INFO img_info; IDirect3DVolume9 *volume; @@ -260,6 +272,18 @@ static void test_D3DXLoadVolumeFromFileInMemory(IDirect3DDevice9 *device) ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, 0, &volume); + for (i = 0; i < ARRAY_SIZE(test_filter_values); ++i) + { + winetest_push_context("Filter %d (%#x)", i, test_filter_values[i].filter); + + hr = D3DXLoadVolumeFromFileInMemory(volume, NULL, NULL, dds_24bit_8_8, sizeof(dds_24bit_8_8), NULL, + test_filter_values[i].filter, 0, NULL); + todo_wine_if(FAILED(test_filter_values[i].expected_hr)) ok(hr == test_filter_values[i].expected_hr, + "Unexpected hr %#lx.\n", hr); + + winetest_pop_context(); + } + hr = D3DXLoadVolumeFromFileInMemory(volume, NULL, NULL, dds_24bit_8_8, sizeof(dds_24bit_8_8), NULL, D3DX_FILTER_POINT, 0, &img_info); ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);