From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/d3dx9_test_images.h | 79 +++++++++++++++++++++++++ dlls/d3dx9_36/tests/surface.c | 37 ++++++++++++ 2 files changed, 116 insertions(+)
diff --git a/dlls/d3dx9_36/tests/d3dx9_test_images.h b/dlls/d3dx9_36/tests/d3dx9_test_images.h index 605e4a0b860..266c0c201cf 100644 --- a/dlls/d3dx9_36/tests/d3dx9_test_images.h +++ b/dlls/d3dx9_36/tests/d3dx9_test_images.h @@ -226,6 +226,85 @@ static const uint8_t dds_8bit[] = 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 };
+/* 4x4 A8P8 dds file. */ +static const uint8_t dds_a8p8[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x47,0x49,0x4d,0x50,0x2d,0x44,0x44,0x53,0x5a,0x09,0x03,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x00,0x80,0x00,0x02,0x00,0x80,0x80,0x03, + 0x80,0x00,0x00,0x04,0x80,0x00,0x80,0x05,0x80,0x80,0x00,0x06,0xc0,0xc0,0xc0,0x07, + 0xc0,0xdc,0xc0,0x08,0xf0,0xca,0xa6,0x09,0x00,0x20,0x40,0x0a,0x00,0x20,0x60,0x0b, + 0x00,0x20,0x80,0x0c,0x00,0x20,0xa0,0x0d,0x00,0x20,0xc0,0x0e,0x00,0x20,0xe0,0x0f, + 0x00,0x40,0x00,0x10,0x00,0x40,0x20,0x11,0x00,0x40,0x40,0x12,0x00,0x40,0x60,0x13, + 0x00,0x40,0x80,0x14,0x00,0x40,0xa0,0x15,0x00,0x40,0xc0,0x16,0x00,0x40,0xe0,0x17, + 0x00,0x60,0x00,0x18,0x00,0x60,0x20,0x19,0x00,0x60,0x40,0x1a,0x00,0x60,0x60,0x1b, + 0x00,0x60,0x80,0x1c,0x00,0x60,0xa0,0x1d,0x00,0x60,0xc0,0x1e,0x00,0x60,0xe0,0x1f, + 0x00,0x80,0x00,0x20,0x00,0x80,0x20,0x21,0x00,0x80,0x40,0x22,0x00,0x80,0x60,0x23, + 0x00,0x80,0x80,0x24,0x00,0x80,0xa0,0x25,0x00,0x80,0xc0,0x26,0x00,0x80,0xe0,0x27, + 0x00,0xa0,0x00,0x28,0x00,0xa0,0x20,0x29,0x00,0xa0,0x40,0x2a,0x00,0xa0,0x60,0x2b, + 0x00,0xa0,0x80,0x2c,0x00,0xa0,0xa0,0x2d,0x00,0xa0,0xc0,0x2e,0x00,0xa0,0xe0,0x2f, + 0x00,0xc0,0x00,0x30,0x00,0xc0,0x20,0x31,0x00,0xc0,0x40,0x32,0x00,0xc0,0x60,0x33, + 0x00,0xc0,0x80,0x34,0x00,0xc0,0xa0,0x35,0x00,0xc0,0xc0,0x36,0x00,0xc0,0xe0,0x37, + 0x00,0xe0,0x00,0x38,0x00,0xe0,0x20,0x39,0x00,0xe0,0x40,0x3a,0x00,0xe0,0x60,0x3b, + 0x00,0xe0,0x80,0x3c,0x00,0xe0,0xa0,0x3d,0x00,0xe0,0xc0,0x3e,0x00,0xe0,0xe0,0x3f, + 0x40,0x00,0x00,0x40,0x40,0x00,0x20,0x41,0x40,0x00,0x40,0x42,0x40,0x00,0x60,0x43, + 0x40,0x00,0x80,0x44,0x40,0x00,0xa0,0x45,0x40,0x00,0xc0,0x46,0x40,0x00,0xe0,0x47, + 0x40,0x20,0x00,0x48,0x40,0x20,0x20,0x49,0x40,0x20,0x40,0x4a,0x40,0x20,0x60,0x4b, + 0x40,0x20,0x80,0x4c,0x40,0x20,0xa0,0x4d,0x40,0x20,0xc0,0x4e,0x40,0x20,0xe0,0x4f, + 0x40,0x40,0x00,0x50,0x40,0x40,0x20,0x51,0x40,0x40,0x40,0x52,0x40,0x40,0x60,0x53, + 0x40,0x40,0x80,0x54,0x40,0x40,0xa0,0x55,0x40,0x40,0xc0,0x56,0x40,0x40,0xe0,0x57, + 0x40,0x60,0x00,0x58,0x40,0x60,0x20,0x59,0x40,0x60,0x40,0x5a,0x40,0x60,0x60,0x5b, + 0x40,0x60,0x80,0x5c,0x40,0x60,0xa0,0x5d,0x40,0x60,0xc0,0x5e,0x40,0x60,0xe0,0x5f, + 0x40,0x80,0x00,0x60,0x40,0x80,0x20,0x61,0x40,0x80,0x40,0x62,0x40,0x80,0x60,0x63, + 0x40,0x80,0x80,0x64,0x40,0x80,0xa0,0x65,0x40,0x80,0xc0,0x66,0x40,0x80,0xe0,0x67, + 0x40,0xa0,0x00,0x68,0x40,0xa0,0x20,0x69,0x40,0xa0,0x40,0x6a,0x40,0xa0,0x60,0x6b, + 0x40,0xa0,0x80,0x6c,0x40,0xa0,0xa0,0x6d,0x40,0xa0,0xc0,0x6e,0x40,0xa0,0xe0,0x6f, + 0x40,0xc0,0x00,0x70,0x40,0xc0,0x20,0x71,0x40,0xc0,0x40,0x72,0x40,0xc0,0x60,0x73, + 0x40,0xc0,0x80,0x74,0x40,0xc0,0xa0,0x75,0x40,0xc0,0xc0,0x76,0x40,0xc0,0xe0,0x77, + 0x40,0xe0,0x00,0x78,0x40,0xe0,0x20,0x79,0x40,0xe0,0x40,0x7a,0x40,0xe0,0x60,0x7b, + 0x40,0xe0,0x80,0x7c,0x40,0xe0,0xa0,0x7d,0x40,0xe0,0xc0,0x7e,0x40,0xe0,0xe0,0x7f, + 0x80,0x00,0x00,0x80,0x80,0x00,0x20,0x81,0x80,0x00,0x40,0x82,0x80,0x00,0x60,0x83, + 0x80,0x00,0x80,0x84,0x80,0x00,0xa0,0x85,0x80,0x00,0xc0,0x86,0x80,0x00,0xe0,0x87, + 0x80,0x20,0x00,0x88,0x80,0x20,0x20,0x89,0x80,0x20,0x40,0x8a,0x80,0x20,0x60,0x8b, + 0x80,0x20,0x80,0x8c,0x80,0x20,0xa0,0x8d,0x80,0x20,0xc0,0x8e,0x80,0x20,0xe0,0x8f, + 0x80,0x40,0x00,0x90,0x80,0x40,0x20,0x91,0x80,0x40,0x40,0x92,0x80,0x40,0x60,0x93, + 0x80,0x40,0x80,0x94,0x80,0x40,0xa0,0x95,0x80,0x40,0xc0,0x96,0x80,0x40,0xe0,0x97, + 0x80,0x60,0x00,0x98,0x80,0x60,0x20,0x99,0x80,0x60,0x40,0x9a,0x80,0x60,0x60,0x9b, + 0x80,0x60,0x80,0x9c,0x80,0x60,0xa0,0x9d,0x80,0x60,0xc0,0x9e,0x80,0x60,0xe0,0x9f, + 0x80,0x80,0x00,0xa0,0x80,0x80,0x20,0xa1,0x80,0x80,0x40,0xa2,0x80,0x80,0x60,0xa3, + 0x80,0x80,0x80,0xa4,0x80,0x80,0xa0,0xa5,0x80,0x80,0xc0,0xa6,0x80,0x80,0xe0,0xa7, + 0x80,0xa0,0x00,0xa8,0x80,0xa0,0x20,0xa9,0x80,0xa0,0x40,0xaa,0x80,0xa0,0x60,0xab, + 0x80,0xa0,0x80,0xac,0x80,0xa0,0xa0,0xad,0x80,0xa0,0xc0,0xae,0x80,0xa0,0xe0,0xaf, + 0x80,0xc0,0x00,0xb0,0x80,0xc0,0x20,0xb1,0x80,0xc0,0x40,0xb2,0x80,0xc0,0x60,0xb3, + 0x80,0xc0,0x80,0xb4,0x80,0xc0,0xa0,0xb5,0x80,0xc0,0xc0,0xb6,0x80,0xc0,0xe0,0xb7, + 0x80,0xe0,0x00,0xb8,0x80,0xe0,0x20,0xb9,0x80,0xe0,0x40,0xba,0x80,0xe0,0x60,0xbb, + 0x80,0xe0,0x80,0xbc,0x80,0xe0,0xa0,0xbd,0x80,0xe0,0xc0,0xbe,0x80,0xe0,0xe0,0xbf, + 0xc0,0x00,0x00,0xc0,0xc0,0x00,0x20,0xc1,0xc0,0x00,0x40,0xc2,0xc0,0x00,0x60,0xc3, + 0xc0,0x00,0x80,0xc4,0xc0,0x00,0xa0,0xc5,0xc0,0x00,0xc0,0xc6,0xc0,0x00,0xe0,0xc7, + 0xc0,0x20,0x00,0xc8,0xc0,0x20,0x20,0xc9,0xc0,0x20,0x40,0xca,0xc0,0x20,0x60,0xcb, + 0xc0,0x20,0x80,0xcc,0xc0,0x20,0xa0,0xcd,0xc0,0x20,0xc0,0xce,0xc0,0x20,0xe0,0xcf, + 0xc0,0x40,0x00,0xd0,0xc0,0x40,0x20,0xd1,0xc0,0x40,0x40,0xd2,0xc0,0x40,0x60,0xd3, + 0xc0,0x40,0x80,0xd4,0xc0,0x40,0xa0,0xd5,0xc0,0x40,0xc0,0xd6,0xc0,0x40,0xe0,0xd7, + 0xc0,0x60,0x00,0xd8,0xc0,0x60,0x20,0xd9,0xc0,0x60,0x40,0xda,0xc0,0x60,0x60,0xdb, + 0xc0,0x60,0x80,0xdc,0xc0,0x60,0xa0,0xdd,0xc0,0x60,0xc0,0xde,0xc0,0x60,0xe0,0xdf, + 0xc0,0x80,0x00,0xe0,0xc0,0x80,0x20,0xe1,0xc0,0x80,0x40,0xe2,0xc0,0x80,0x60,0xe3, + 0xc0,0x80,0x80,0xe4,0xc0,0x80,0xa0,0xe5,0xc0,0x80,0xc0,0xe6,0xc0,0x80,0xe0,0xe7, + 0xc0,0xa0,0x00,0xe8,0xc0,0xa0,0x20,0xe9,0xc0,0xa0,0x40,0xea,0xc0,0xa0,0x60,0xeb, + 0xc0,0xa0,0x80,0xec,0xc0,0xa0,0xa0,0xed,0xc0,0xa0,0xc0,0xee,0xc0,0xa0,0xe0,0xef, + 0xc0,0xc0,0x00,0xf0,0xc0,0xc0,0x20,0xf1,0xc0,0xc0,0x40,0xf2,0xc0,0xc0,0x60,0xf3, + 0xc0,0xc0,0x80,0xf4,0xc0,0xc0,0xa0,0xf5,0xf0,0xfb,0xff,0xf6,0xa4,0xa0,0xa0,0xf7, + 0x80,0x80,0x80,0xf8,0x00,0x00,0xff,0xf9,0x00,0xff,0x00,0xfa,0x00,0xff,0xff,0xfb, + 0xff,0x00,0x00,0xfc,0xff,0x00,0xff,0xfd,0xff,0xff,0x00,0xfe,0xff,0xff,0xff,0xff, + 0x00,0xf0,0x10,0xe0,0x20,0xd0,0x30,0xc0,0x40,0xb0,0x50,0xa0,0x60,0x90,0x70,0x80, + 0x80,0x70,0x90,0x60,0xa0,0x50,0xb0,0x40,0xc0,0x30,0xd0,0x20,0xe0,0x10,0xf0,0x00, +}; + /* 2x2 24-bit dds, 2 mipmaps */ static const uint8_t dds_24bit[] = { diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index d1f3a153c18..1128a67423c 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -172,6 +172,7 @@ static HRESULT create_file(const char *filename, const unsigned char *data, cons #define DDS_PF_ALPHA 0x00000001 #define DDS_PF_ALPHA_ONLY 0x00000002 #define DDS_PF_FOURCC 0x00000004 +#define DDS_PF_INDEXED 0x00000020 #define DDS_PF_RGB 0x00000040 #define DDS_PF_LUMINANCE 0x00020000 #define DDS_PF_BUMPLUMINANCE 0x00040000 @@ -241,6 +242,7 @@ static void check_dds_pixel_format_(unsigned int line, { DWORD magic; struct dds_header header; + PALETTEENTRY palette[256]; BYTE data[256]; } dds;
@@ -740,6 +742,8 @@ static void test_D3DXGetImageInfo(void) check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0, D3DFMT_V8U8); check_dds_pixel_format(DDS_PF_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0, D3DFMT_V16U16); check_dds_pixel_format(DDS_PF_BUMPLUMINANCE, 0, 32, 0x0000ff, 0x00ff00, 0xff0000, 0, D3DFMT_X8L8V8U8); + check_dds_pixel_format(DDS_PF_INDEXED, 0, 8, 0, 0, 0, 0, D3DFMT_P8); + todo_wine check_dds_pixel_format(DDS_PF_INDEXED | DDS_PF_ALPHA, 0, 16, 0, 0, 0, 0xff00, D3DFMT_A8P8);
test_dds_header_handling();
@@ -755,6 +759,9 @@ static void test_D3DXGetImageInfo(void) hr = D3DXGetImageInfoFromFileInMemory(dds_volume_map, sizeof(dds_volume_map) - 1, &info); ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromFileInMemory returned %#lx, expected %#x\n", hr, D3DXERR_INVALIDDATA);
+ /* Size includes the size of the color palette. */ + hr = D3DXGetImageInfoFromFileInMemory(dds_8bit, (sizeof(dds_8bit) - (sizeof(PALETTEENTRY) * 256)), &info); + todo_wine ok(hr == D3DXERR_INVALIDDATA, "Unexpected hr %#lx.\n", hr);
/* cleanup */ if(testdummy_ok) DeleteFileA("testdummy.bmp"); @@ -1732,6 +1739,36 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) winetest_pop_context(); }
+ /* Test D3DXLoadSurfaceFromFileInMemory with indexed pixel format DDS files. */ + if (!strcmp(winetest_platform, "windows")) + { + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_8bit, sizeof(dds_8bit), &rect, D3DX_FILTER_NONE, 0, NULL); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_4bpp(&lockrect, 0, 0, 0xffec2700); + check_pixel_4bpp(&lockrect, 1, 0, 0xffec2700); + check_pixel_4bpp(&lockrect, 0, 1, 0xffec2700); + check_pixel_4bpp(&lockrect, 1, 1, 0xffec2700); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + } + else + { + skip("Skipping test on wine to avoid access violation.\n"); + } + + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_a8p8, sizeof(dds_a8p8), &rect, D3DX_FILTER_NONE, 0, NULL); + todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + todo_wine check_pixel_4bpp(&lockrect, 0, 0, 0xf0000000); + todo_wine check_pixel_4bpp(&lockrect, 1, 0, 0xe0004000); + todo_wine check_pixel_4bpp(&lockrect, 0, 1, 0xb0400000); + todo_wine check_pixel_4bpp(&lockrect, 1, 1, 0xa0404000); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + check_release((IUnknown*)surf, 0); }