[WINESYNC] d3dx9: Handle compressed surfaces in D3DXLoadSurfaceFromMemory.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=24983
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 376182062ff1ab8e7835fd67bc650da83c2cc75d by Matteo Bruni <mbruni@codeweavers.com>
This commit is contained in:
winesync 2020-09-21 22:57:00 +02:00 committed by Jérôme Gardou
parent e639a7847f
commit 882cc57c66
12 changed files with 1394 additions and 130 deletions

View file

@ -950,7 +950,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
else {
PALETTEENTRY palette;
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8r3g3b2, D3DFMT_A8R3G3B2, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8r3g3b2,
D3DFMT_A8R3G3B2, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
check_pixel_4bpp(&lockrect, 0, 0, 0x57dbffff);
@ -959,7 +960,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_pixel_4bpp(&lockrect, 1, 1, 0xc8929255);
IDirect3DSurface9_UnlockRect(surf);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a1r5g5b5, D3DFMT_A1R5G5B5, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a1r5g5b5,
D3DFMT_A1R5G5B5, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
check_pixel_4bpp(&lockrect, 0, 0, 0x008cadad);
@ -968,7 +970,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_pixel_4bpp(&lockrect, 1, 1, 0xff29088c);
IDirect3DSurface9_UnlockRect(surf);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_r5g6b5, D3DFMT_R5G6B5, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_r5g6b5,
D3DFMT_R5G6B5, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
check_pixel_4bpp(&lockrect, 0, 0, 0xff9cdfb5);
@ -977,7 +980,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_pixel_4bpp(&lockrect, 1, 1, 0xff425d73);
IDirect3DSurface9_UnlockRect(surf);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_g16r16, D3DFMT_G16R16, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_g16r16,
D3DFMT_G16R16, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
todo_wine {
@ -988,8 +992,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_pixel_4bpp(&lockrect, 1, 1, 0xfffe9aff);
IDirect3DSurface9_UnlockRect(surf);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8b8g8r8, D3DFMT_A8B8G8R8,
8, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8b8g8r8,
D3DFMT_A8B8G8R8, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@ -1001,8 +1005,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
SetRect(&rect, 0, 0, 1, 1);
SetRect(&destrect, 1, 1, 2, 2);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, &destrect, pixdata_a8b8g8r8, D3DFMT_A8B8G8R8,
8, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, &destrect, pixdata_a8b8g8r8,
D3DFMT_A8B8G8R8, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
check_pixel_4bpp(&lockrect, 0, 0, 0xc3f04c39);
@ -1013,8 +1017,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
SetRect(&rect, 0, 0, 2, 2);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a2r10g10b10, D3DFMT_A2R10G10B10,
8, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a2r10g10b10,
D3DFMT_A2R10G10B10, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
check_pixel_4bpp(&lockrect, 0, 0, 0x555c95bf);
@ -1050,7 +1054,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
ok(hr == D3D_OK, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x\n", hr);
ok(*(DWORD*)lockrect.pBits == 0x80f3f2f1, "Pixel color mismatch: got %#x, expected 0x80f3f2f1\n", *(DWORD*)lockrect.pBits);
ok(*(DWORD*)lockrect.pBits == 0x80f3f2f1,
"Pixel color mismatch: got %#x, expected 0x80f3f2f1\n", *(DWORD*)lockrect.pBits);
hr = IDirect3DSurface9_UnlockRect(surf);
ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x\n", hr);
}
@ -1071,7 +1076,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_A1R5G5B5, D3DPOOL_DEFAULT, &surf, NULL);
if(FAILED(hr)) skip("Failed to create a surface (%#x)\n", hr);
else {
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8r3g3b2, D3DFMT_A8R3G3B2, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8r3g3b2,
D3DFMT_A8R3G3B2, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
check_pixel_2bpp(&lockrect, 0, 0, 0x6fff);
@ -1080,7 +1086,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_pixel_2bpp(&lockrect, 1, 1, 0xca4a);
IDirect3DSurface9_UnlockRect(surf);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a1r5g5b5, D3DFMT_A1R5G5B5, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a1r5g5b5,
D3DFMT_A1R5G5B5, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
check_pixel_2bpp(&lockrect, 0, 0, 0x46b5);
@ -1089,7 +1096,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_pixel_2bpp(&lockrect, 1, 1, 0x9431);
IDirect3DSurface9_UnlockRect(surf);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_r5g6b5, D3DFMT_R5G6B5, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_r5g6b5,
D3DFMT_R5G6B5, 4, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
check_pixel_2bpp(&lockrect, 0, 0, 0xcf76);
@ -1098,7 +1106,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_pixel_2bpp(&lockrect, 1, 1, 0xa16e);
IDirect3DSurface9_UnlockRect(surf);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_g16r16, D3DFMT_G16R16, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_g16r16,
D3DFMT_G16R16, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
todo_wine {
@ -1109,7 +1118,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_pixel_2bpp(&lockrect, 1, 1, 0xfe7f);
IDirect3DSurface9_UnlockRect(surf);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8b8g8r8, D3DFMT_A8B8G8R8, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a8b8g8r8,
D3DFMT_A8B8G8R8, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
todo_wine {
@ -1120,7 +1130,8 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
check_pixel_2bpp(&lockrect, 1, 1, 0xf8b8);
IDirect3DSurface9_UnlockRect(surf);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a2r10g10b10, D3DFMT_A2R10G10B10, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata_a2r10g10b10,
D3DFMT_A2R10G10B10, 8, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
check_pixel_2bpp(&lockrect, 0, 0, 0x2e57);
@ -1246,7 +1257,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
/* DXT1, DXT2, DXT3, DXT4, DXT5 */
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 4, 4, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surf, NULL);
if (FAILED(hr))
skip("Failed to create R8G8B8 surface, hr %#x.\n", hr);
skip("Failed to create A8R8G8B8 surface, hr %#x.\n", hr);
else
{
hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_24bit, sizeof(dds_24bit), NULL, D3DX_FILTER_NONE, 0, NULL);
@ -1260,7 +1271,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
hr = IDirect3DTexture9_GetSurfaceLevel(tex, 0, &newsurf);
ok(SUCCEEDED(hr), "Failed to get the surface, hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT2 format.\n");
ok(SUCCEEDED(hr), "Failed to convert pixels to DXT2 format.\n");
check_release((IUnknown*)newsurf, 1);
check_release((IUnknown*)tex, 0);
}
@ -1273,7 +1284,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
hr = IDirect3DTexture9_GetSurfaceLevel(tex, 0, &newsurf);
ok(SUCCEEDED(hr), "Failed to get the surface, hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT3 format.\n");
ok(SUCCEEDED(hr), "Failed to convert pixels to DXT3 format.\n");
check_release((IUnknown*)newsurf, 1);
check_release((IUnknown*)tex, 0);
}
@ -1286,7 +1297,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
hr = IDirect3DTexture9_GetSurfaceLevel(tex, 0, &newsurf);
ok(SUCCEEDED(hr), "Failed to get the surface, hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT4 format.\n");
ok(SUCCEEDED(hr), "Failed to convert pixels to DXT4 format.\n");
check_release((IUnknown*)newsurf, 1);
check_release((IUnknown*)tex, 0);
}
@ -1299,11 +1310,11 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
hr = IDirect3DTexture9_GetSurfaceLevel(tex, 0, &newsurf);
ok(SUCCEEDED(hr), "Failed to get the surface, hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT5 format.\n");
ok(SUCCEEDED(hr), "Failed to convert pixels to DXT5 format.\n");
SetRect(&rect, 0, 0, 4, 2);
hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, &rect, surf, NULL, &rect, D3DX_FILTER_NONE, 0);
todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromMemory(newsurf, NULL, &rect, &dds_dxt5[128],
D3DFMT_DXT5, 16, NULL, &rect, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@ -1332,7 +1343,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
SetRect(&rect, 2, 2, 6, 6);
hr = D3DXLoadSurfaceFromMemory(newsurf, NULL, NULL, &dds_dxt5_8_8[128],
D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0);
todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromMemory(newsurf, NULL, &rect, &dds_dxt5_8_8[128],
D3DFMT_DXT5, 16 * 2, NULL, NULL, D3DX_FILTER_POINT, 0);
@ -1354,10 +1365,10 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
hr = IDirect3DTexture9_GetSurfaceLevel(tex, 0, &newsurf);
ok(SUCCEEDED(hr), "Failed to get the surface, hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT1 format.\n");
ok(SUCCEEDED(hr), "Failed to convert pixels to DXT1 format.\n");
hr = D3DXLoadSurfaceFromSurface(surf, NULL, NULL, newsurf, NULL, NULL, D3DX_FILTER_NONE, 0);
todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels from DXT1 format.\n");
ok(SUCCEEDED(hr), "Failed to convert pixels from DXT1 format.\n");
check_release((IUnknown*)newsurf, 1);
check_release((IUnknown*)tex, 0);

View file

@ -636,7 +636,7 @@ static void test_D3DXCheckVolumeTextureRequirements(IDirect3DDevice9 *device)
if (has_3d_dxt3)
ok(format == D3DFMT_DXT3, "Returned format %u, expected %u\n", format, D3DFMT_DXT3);
else
todo_wine ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
ok(format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", format, D3DFMT_A8R8G8B8);
/* mipmaps */
if (!(caps.TextureCaps & D3DPTEXTURECAPS_MIPVOLUMEMAP))
@ -1628,16 +1628,16 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
/* Check that D3DXCreateTextureFromFileInMemory accepts cube texture dds file (only first face texture is loaded) */
hr = D3DXCreateTextureFromFileInMemory(device, dds_cube_map, sizeof(dds_cube_map), &texture);
todo_wine_if (!has_2d_dxt5)
ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
if (SUCCEEDED(hr))
ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
type = IDirect3DTexture9_GetType(texture);
ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u.\n", type, D3DRTYPE_TEXTURE);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
ok(desc.Width == 4, "Width is %u, expected 4.\n", desc.Width);
ok(desc.Height == 4, "Height is %u, expected 4.\n", desc.Height);
if (has_cube_dxt5)
{
type = IDirect3DTexture9_GetType(texture);
ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u\n", type, D3DRTYPE_TEXTURE);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
ok(desc.Width == 4, "Width is %u, expected 4\n", desc.Width);
ok(desc.Height == 4, "Height is %u, expected 4\n", desc.Height);
ok(desc.Format == D3DFMT_DXT5, "Unexpected texture format %#x.\n", desc.Format);
hr = IDirect3DTexture9_LockRect(texture, 0, &lock_rect, NULL, D3DLOCK_READONLY);
ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %#x, expected %#x\n", hr, D3D_OK);
if (SUCCEEDED(hr))
@ -1648,12 +1648,17 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
i, ((BYTE *)lock_rect.pBits)[i], dds_cube_map[128 + i]);
IDirect3DTexture9_UnlockRect(texture, 0);
}
IDirect3DTexture9_Release(texture);
}
else
{
ok(desc.Format == D3DFMT_A8R8G8B8, "Unexpected texture format %#x.\n", desc.Format);
skip("D3DFMT_DXT5 textures are not supported, skipping a test.\n");
}
IDirect3DTexture9_Release(texture);
/* Test with a DXT5 texture smaller than the block size. */
hr = D3DXCreateTextureFromFileInMemory(device, dds_dxt5, sizeof(dds_dxt5), &texture);
todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr) && has_2d_dxt5)
{
type = IDirect3DTexture9_GetType(texture);
@ -1709,7 +1714,7 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
D3DPOOL_DEFAULT, &uncompressed_surface, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
@ -1739,28 +1744,25 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
SetRect(&rect, 2, 2, 6, 6);
hr = D3DXLoadSurfaceFromMemory(surface, NULL, NULL, &dds_dxt5_8_8[128],
D3DFMT_DXT5, 16 * 2, NULL, &rect, D3DX_FILTER_POINT, 0);
todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (y = 0; y < 8; ++y)
hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (y = 0; y < 8; ++y)
{
for (x = 0; x < 8; ++x)
{
for (x = 0; x < 8; ++x)
{
ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
dds_dxt5_8_8_expected_misaligned_1[y * 8 + x], 0),
"Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
dds_dxt5_8_8_expected_misaligned_1[y * 8 + x]);
}
ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
dds_dxt5_8_8_expected_misaligned_1[y * 8 + x], 0),
"Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
dds_dxt5_8_8_expected_misaligned_1[y * 8 + x]);
}
hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
}
hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, D3DLOCK_READONLY);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@ -1804,19 +1806,19 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
/* Volume textures work too. */
hr = D3DXCreateTextureFromFileInMemory(device, dds_volume_map, sizeof(dds_volume_map), &texture);
todo_wine_if (!has_2d_dxt3)
ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
if (SUCCEEDED(hr))
{
type = IDirect3DTexture9_GetType(texture);
ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u.\n", type, D3DRTYPE_TEXTURE);
level_count = IDirect3DBaseTexture9_GetLevelCount((IDirect3DBaseTexture9 *)texture);
todo_wine ok(level_count == 3, "Texture has %u mip levels, 3 expected.\n", level_count);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
ok(desc.Width == 4, "Width is %u, expected 4.\n", desc.Width);
ok(desc.Height == 4, "Height is %u, expected 4.\n", desc.Height);
ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
type = IDirect3DTexture9_GetType(texture);
ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u.\n", type, D3DRTYPE_TEXTURE);
level_count = IDirect3DBaseTexture9_GetLevelCount((IDirect3DBaseTexture9 *)texture);
todo_wine ok(level_count == 3, "Texture has %u mip levels, 3 expected.\n", level_count);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
ok(desc.Width == 4, "Width is %u, expected 4.\n", desc.Width);
ok(desc.Height == 4, "Height is %u, expected 4.\n", desc.Height);
if (has_2d_dxt3)
{
ok(desc.Format == D3DFMT_DXT3, "Unexpected texture format %#x.\n", desc.Format);
hr = IDirect3DTexture9_LockRect(texture, 0, &lock_rect, NULL, D3DLOCK_READONLY);
ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %#x, expected %#x.\n", hr, D3D_OK);
if (SUCCEEDED(hr))
@ -1827,10 +1829,15 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
i, ((BYTE *)lock_rect.pBits)[i], dds_volume_map[128 + i]);
IDirect3DTexture9_UnlockRect(texture, 0);
}
/* The lower texture levels are apparently generated by filtering the level 0 surface
* I.e. following levels from the file are ignored. */
IDirect3DTexture9_Release(texture);
}
else
{
ok(desc.Format == D3DFMT_A8R8G8B8, "Unexpected texture format %#x.\n", desc.Format);
skip("D3DFMT_DXT3 volume textures are not supported, skipping a test.\n");
}
/* The lower texture levels are apparently generated by filtering the level 0 surface
* I.e. following levels from the file are ignored. */
IDirect3DTexture9_Release(texture);
}
static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
@ -1985,7 +1992,7 @@ static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
if (SUCCEEDED(hr))
{
levelcount = IDirect3DCubeTexture9_GetLevelCount(cube_texture);
todo_wine ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
hr = IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &surface_desc);
ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
@ -2010,8 +2017,7 @@ static void test_D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *devic
hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, dds_cube_map, sizeof(dds_cube_map), D3DX_DEFAULT, D3DX_DEFAULT,
D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &cube_texture);
todo_wine_if (!has_cube_dxt5)
ok(hr == D3D_OK, "D3DXCreateCubeTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
ok(hr == D3D_OK, "D3DXCreateCubeTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
if (SUCCEEDED(hr)) IDirect3DCubeTexture9_Release(cube_texture);
}
@ -2036,29 +2042,25 @@ static void test_D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *devic
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateVolumeTextureFromFileInMemory(device, dds_volume_map, sizeof(dds_volume_map), &volume_texture);
todo_wine_if (!has_3d_dxt3)
ok(hr == D3D_OK, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
if (SUCCEEDED(hr))
{
levelcount = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
ok(hr == D3D_OK, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x.\n", hr, D3D_OK);
levelcount = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
ok(levelcount == 3, "GetLevelCount returned %u, expected 3.\n", levelcount);
hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &volume_desc);
ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
ok(volume_desc.Width == 4, "Got width %u, expected 4\n", volume_desc.Width);
ok(volume_desc.Height == 4, "Got height %u, expected 4\n", volume_desc.Height);
ok(volume_desc.Depth == 2, "Got depth %u, expected 2\n", volume_desc.Depth);
ok(volume_desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected D3DPOOL_MANAGED\n", volume_desc.Pool);
hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &volume_desc);
ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
ok(volume_desc.Width == 4, "Got width %u, expected 4.\n", volume_desc.Width);
ok(volume_desc.Height == 4, "Got height %u, expected 4.\n", volume_desc.Height);
ok(volume_desc.Depth == 2, "Got depth %u, expected 2.\n", volume_desc.Depth);
ok(volume_desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected D3DPOOL_MANAGED.\n", volume_desc.Pool);
hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 1, &volume_desc);
ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
ok(volume_desc.Width == 2, "Got width %u, expected 2\n", volume_desc.Width);
ok(volume_desc.Height == 2, "Got height %u, expected 2\n", volume_desc.Height);
ok(volume_desc.Depth == 1, "Got depth %u, expected 1\n", volume_desc.Depth);
hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 1, &volume_desc);
ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x.\n", hr, D3D_OK);
ok(volume_desc.Width == 2, "Got width %u, expected 2.\n", volume_desc.Width);
ok(volume_desc.Height == 2, "Got height %u, expected 2.\n", volume_desc.Height);
ok(volume_desc.Depth == 1, "Got depth %u, expected 1.\n", volume_desc.Depth);
ref = IDirect3DVolumeTexture9_Release(volume_texture);
ok(ref == 0, "Invalid reference count. Got %u, expected 0\n", ref);
}
ref = IDirect3DVolumeTexture9_Release(volume_texture);
ok(ref == 0, "Invalid reference count. Got %u, expected 0.\n", ref);
}
/* fills positive x face with red color */
@ -2511,14 +2513,14 @@ START_TEST(texture)
/* Check whether DXTn textures are supported. */
has_2d_dxt3 = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT3));
hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT5);
has_2d_dxt5 = SUCCEEDED(hr);
hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_CUBETEXTURE, D3DFMT_DXT5);
has_cube_dxt5 = SUCCEEDED(hr);
has_2d_dxt5 = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT5));
has_cube_dxt5 = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_CUBETEXTURE, D3DFMT_DXT5));
has_3d_dxt3 = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_VOLUMETEXTURE, D3DFMT_DXT3));
trace("DXTn texture support: 2D DXT3 %#x, 2D DXT5 %#x, cube DXT5 %#x, 3D dxt3 %#x.\n",
has_2d_dxt3, has_2d_dxt5, has_cube_dxt5, has_3d_dxt3);
test_D3DXCheckTextureRequirements(device);
test_D3DXCheckCubeTextureRequirements(device);