The test code here is pulled in from the d3dx10 tests, with some variable name changes to work around existing d3dx11 test definitions and a removal of a few `broken()`s for Windows Vista since we no longer test on it.
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx11_42/d3dx11_42.spec | 4 ++-- dlls/d3dx11_43/d3dx11_43.spec | 4 ++-- dlls/d3dx11_43/texture.c | 18 ++++++++++++++++++ include/d3dx11tex.h | 4 ++++ 4 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dx11_42/d3dx11_42.spec b/dlls/d3dx11_42/d3dx11_42.spec index 2d125ea119f..72bdea81cf6 100644 --- a/dlls/d3dx11_42/d3dx11_42.spec +++ b/dlls/d3dx11_42/d3dx11_42.spec @@ -30,8 +30,8 @@ @ stdcall -import D3DX11GetImageInfoFromFileA(str ptr ptr ptr) @ stdcall -import D3DX11GetImageInfoFromFileW(wstr ptr ptr ptr) @ stdcall -import D3DX11GetImageInfoFromMemory(ptr long ptr ptr ptr) -@ stub D3DX11GetImageInfoFromResourceA -@ stub D3DX11GetImageInfoFromResourceW +@ stdcall -import D3DX11GetImageInfoFromResourceA(long str ptr ptr ptr) +@ stdcall -import D3DX11GetImageInfoFromResourceW(long wstr ptr ptr ptr) @ stdcall -import D3DX11LoadTextureFromTexture(ptr ptr ptr ptr) @ stub D3DX11PreprocessShaderFromFileA @ stub D3DX11PreprocessShaderFromFileW diff --git a/dlls/d3dx11_43/d3dx11_43.spec b/dlls/d3dx11_43/d3dx11_43.spec index 2d93b8d760a..658e00d0dc3 100644 --- a/dlls/d3dx11_43/d3dx11_43.spec +++ b/dlls/d3dx11_43/d3dx11_43.spec @@ -30,8 +30,8 @@ @ stdcall D3DX11GetImageInfoFromFileA(str ptr ptr ptr) @ stdcall D3DX11GetImageInfoFromFileW(wstr ptr ptr ptr) @ stdcall D3DX11GetImageInfoFromMemory(ptr long ptr ptr ptr) -@ stub D3DX11GetImageInfoFromResourceA -@ stub D3DX11GetImageInfoFromResourceW +@ stdcall D3DX11GetImageInfoFromResourceA(long str ptr ptr ptr) +@ stdcall D3DX11GetImageInfoFromResourceW(long wstr ptr ptr ptr) @ stdcall D3DX11LoadTextureFromTexture(ptr ptr ptr ptr) @ stub D3DX11PreprocessShaderFromFileA @ stub D3DX11PreprocessShaderFromFileW diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c index b7c9761ad18..120891851d7 100644 --- a/dlls/d3dx11_43/texture.c +++ b/dlls/d3dx11_43/texture.c @@ -342,3 +342,21 @@ HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_dat *hresult = hr; return hr; } + +HRESULT WINAPI D3DX11GetImageInfoFromResourceA(HMODULE module, const char *resource, ID3DX11ThreadPump *pump, + D3DX11_IMAGE_INFO *info, HRESULT *result) +{ + FIXME("module %p, resource %s, pump %p, info %p, result %p stub!.\n", module, debugstr_a(resource), pump, info, + result); + + return E_NOTIMPL; +} + +HRESULT WINAPI D3DX11GetImageInfoFromResourceW(HMODULE module, const WCHAR *resource, ID3DX11ThreadPump *pump, + D3DX11_IMAGE_INFO *info, HRESULT *result) +{ + FIXME("module %p, resource %s, pump %p, info %p, result %p stub!.\n", module, debugstr_w(resource), pump, info, + result); + + return E_NOTIMPL; +} diff --git a/include/d3dx11tex.h b/include/d3dx11tex.h index fae5ee9c67a..631a8060f6b 100644 --- a/include/d3dx11tex.h +++ b/include/d3dx11tex.h @@ -153,6 +153,10 @@ HRESULT WINAPI D3DX11GetImageInfoFromFileA(const char *filename, ID3DX11ThreadPu HRESULT *hresult); HRESULT WINAPI D3DX11GetImageInfoFromFileW(const WCHAR *filename, ID3DX11ThreadPump *pump, D3DX11_IMAGE_INFO *img_info, HRESULT *hresult); +HRESULT WINAPI D3DX11GetImageInfoFromResourceA(HMODULE module, const char *resource, ID3DX11ThreadPump *pump, + D3DX11_IMAGE_INFO *info, HRESULT *result); +HRESULT WINAPI D3DX11GetImageInfoFromResourceW(HMODULE module, const WCHAR *resource, ID3DX11ThreadPump *pump, + D3DX11_IMAGE_INFO *info, HRESULT *result); HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX11ThreadPump *pump, D3DX11_IMAGE_INFO *img_info, HRESULT *hresult); HRESULT WINAPI D3DX11LoadTextureFromTexture(ID3D11DeviceContext *context, ID3D11Resource *src_texture,
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx11_42/d3dx11_42.spec | 4 ++-- dlls/d3dx11_43/d3dx11_43.spec | 4 ++-- dlls/d3dx11_43/texture.c | 18 ++++++++++++++++++ include/d3dx11tex.h | 4 ++++ 4 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dx11_42/d3dx11_42.spec b/dlls/d3dx11_42/d3dx11_42.spec index 72bdea81cf6..4e3d2f44192 100644 --- a/dlls/d3dx11_42/d3dx11_42.spec +++ b/dlls/d3dx11_42/d3dx11_42.spec @@ -23,8 +23,8 @@ @ stdcall -import D3DX11CreateTextureFromFileA(ptr str ptr ptr ptr ptr) @ stdcall -import D3DX11CreateTextureFromFileW(ptr wstr ptr ptr ptr ptr) @ stdcall -import D3DX11CreateTextureFromMemory(ptr ptr long ptr ptr ptr ptr) -@ stub D3DX11CreateTextureFromResourceA -@ stub D3DX11CreateTextureFromResourceW +@ stdcall -import D3DX11CreateTextureFromResourceA(ptr long str ptr ptr ptr ptr) +@ stdcall -import D3DX11CreateTextureFromResourceW(ptr long wstr ptr ptr ptr ptr) @ stub D3DX11CreateThreadPump @ stdcall -import D3DX11FilterTexture(ptr ptr long long) @ stdcall -import D3DX11GetImageInfoFromFileA(str ptr ptr ptr) diff --git a/dlls/d3dx11_43/d3dx11_43.spec b/dlls/d3dx11_43/d3dx11_43.spec index 658e00d0dc3..2033d6003fe 100644 --- a/dlls/d3dx11_43/d3dx11_43.spec +++ b/dlls/d3dx11_43/d3dx11_43.spec @@ -23,8 +23,8 @@ @ stdcall D3DX11CreateTextureFromFileA(ptr str ptr ptr ptr ptr) @ stdcall D3DX11CreateTextureFromFileW(ptr wstr ptr ptr ptr ptr) @ stdcall D3DX11CreateTextureFromMemory(ptr ptr long ptr ptr ptr ptr) -@ stub D3DX11CreateTextureFromResourceA -@ stub D3DX11CreateTextureFromResourceW +@ stdcall D3DX11CreateTextureFromResourceA(ptr long str ptr ptr ptr ptr) +@ stdcall D3DX11CreateTextureFromResourceW(ptr long wstr ptr ptr ptr ptr) @ stub D3DX11CreateThreadPump @ stdcall D3DX11FilterTexture(ptr ptr long long) @ stdcall D3DX11GetImageInfoFromFileA(str ptr ptr ptr) diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c index 120891851d7..81380b1aecc 100644 --- a/dlls/d3dx11_43/texture.c +++ b/dlls/d3dx11_43/texture.c @@ -278,6 +278,24 @@ HRESULT WINAPI D3DX11CreateTextureFromFileW(ID3D11Device *device, const WCHAR *f return E_NOTIMPL; }
+HRESULT WINAPI D3DX11CreateTextureFromResourceA(ID3D11Device *device, HMODULE module, const char *resource, + D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult) +{ + FIXME("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p stub!\n", + device, module, debugstr_a(resource), load_info, pump, texture, hresult); + + return E_NOTIMPL; +} + +HRESULT WINAPI D3DX11CreateTextureFromResourceW(ID3D11Device *device, HMODULE module, const WCHAR *resource, + D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult) +{ + FIXME("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p stub!\n", + device, module, debugstr_w(resource), load_info, pump, texture, hresult); + + return E_NOTIMPL; +} + HRESULT WINAPI D3DX11CreateTextureFromMemory(ID3D11Device *device, const void *data, SIZE_T data_size, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult) diff --git a/include/d3dx11tex.h b/include/d3dx11tex.h index 631a8060f6b..386945fd70d 100644 --- a/include/d3dx11tex.h +++ b/include/d3dx11tex.h @@ -146,6 +146,10 @@ HRESULT WINAPI D3DX11CreateTextureFromFileA(ID3D11Device *device, const char *fi HRESULT WINAPI D3DX11CreateTextureFromFileW(ID3D11Device *device, const WCHAR *filename, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult); +HRESULT WINAPI D3DX11CreateTextureFromResourceA(ID3D11Device *device, HMODULE module, const char *resource, + D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult); +HRESULT WINAPI D3DX11CreateTextureFromResourceW(ID3D11Device *device, HMODULE module, const WCHAR *resource, + D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult); HRESULT WINAPI D3DX11CreateTextureFromMemory(ID3D11Device *device, const void *src_data, SIZE_T src_data_size, D3DX11_IMAGE_LOAD_INFO *loadinfo, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult); HRESULT WINAPI D3DX11FilterTexture(ID3D11DeviceContext *context, ID3D11Resource *texture, UINT src_level, UINT filter);
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx11_42/tests/Makefile.in | 2 +- dlls/d3dx11_43/tests/Makefile.in | 2 +- dlls/d3dx11_43/tests/d3dx11.c | 2599 ++++++++++++++++++++++++++++-- 3 files changed, 2450 insertions(+), 153 deletions(-)
diff --git a/dlls/d3dx11_42/tests/Makefile.in b/dlls/d3dx11_42/tests/Makefile.in index f18be76d9d5..7eae4f26e0d 100644 --- a/dlls/d3dx11_42/tests/Makefile.in +++ b/dlls/d3dx11_42/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = d3dx11_42.dll -IMPORTS = d3dx11_42 +IMPORTS = d3dx11_42 ole32 PARENTSRC = ../../d3dx11_43/tests
SOURCES = \ diff --git a/dlls/d3dx11_43/tests/Makefile.in b/dlls/d3dx11_43/tests/Makefile.in index 3283e251bdd..fc9007fc878 100644 --- a/dlls/d3dx11_43/tests/Makefile.in +++ b/dlls/d3dx11_43/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = d3dx11_43.dll -IMPORTS = d3dx11 +IMPORTS = d3dx11 ole32
SOURCES = \ d3dx11.c diff --git a/dlls/d3dx11_43/tests/d3dx11.c b/dlls/d3dx11_43/tests/d3dx11.c index 58285cc493d..1e4f0312ae9 100644 --- a/dlls/d3dx11_43/tests/d3dx11.c +++ b/dlls/d3dx11_43/tests/d3dx11.c @@ -20,9 +20,20 @@ #include "initguid.h" #include "d3d11.h" #include "d3dx11.h" +#include "wine/wined3d.h" #include "wine/test.h" #include <stdint.h>
+static bool wined3d_opengl; + +static const D3DX11_IMAGE_LOAD_INFO d3dx11_default_load_info = +{ + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, NULL +}; + +#define D3DERR_INVALIDCALL 0x8876086c + #ifndef MAKEFOURCC #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ @@ -163,6 +174,95 @@ static unsigned int get_bpp_from_format(DXGI_FORMAT format) } }
+static HRESULT WINAPI D3DX11ThreadPump_QueryInterface(ID3DX11ThreadPump *iface, REFIID riid, void **out) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static ULONG WINAPI D3DX11ThreadPump_AddRef(ID3DX11ThreadPump *iface) +{ + return 2; +} + +static ULONG WINAPI D3DX11ThreadPump_Release(ID3DX11ThreadPump *iface) +{ + return 1; +} + +static int add_work_item_count = 1; + +static HRESULT WINAPI D3DX11ThreadPump_AddWorkItem(ID3DX11ThreadPump *iface, ID3DX11DataLoader *loader, + ID3DX11DataProcessor *processor, HRESULT *result, void **object) +{ + SIZE_T size; + void *data; + HRESULT hr; + + ok(!add_work_item_count++, "unexpected call\n"); + + hr = ID3DX11DataLoader_Load(loader); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + hr = ID3DX11DataLoader_Decompress(loader, &data, &size); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + hr = ID3DX11DataProcessor_Process(processor, data, size); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + hr = ID3DX11DataProcessor_CreateDeviceObject(processor, object); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + hr = ID3DX11DataProcessor_Destroy(processor); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + hr = ID3DX11DataLoader_Destroy(loader); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + if (result) *result = S_OK; + return S_OK; +} + +static UINT WINAPI D3DX11ThreadPump_GetWorkItemCount(ID3DX11ThreadPump *iface) +{ + ok(0, "unexpected call\n"); + return 0; +} + +static HRESULT WINAPI D3DX11ThreadPump_WaitForAllItems(ID3DX11ThreadPump *iface) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DX11ThreadPump_ProcessDeviceWorkItems(ID3DX11ThreadPump *iface, UINT count) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DX11ThreadPump_PurgeAllItems(ID3DX11ThreadPump *iface) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DX11ThreadPump_GetQueueStatus(ID3DX11ThreadPump *iface, UINT *queue, + UINT *processqueue, UINT *devicequeue) +{ + ok(0, "unexpected call\n"); + return E_NOTIMPL; +} + +static ID3DX11ThreadPumpVtbl D3DX11ThreadPumpVtbl = +{ + D3DX11ThreadPump_QueryInterface, + D3DX11ThreadPump_AddRef, + D3DX11ThreadPump_Release, + D3DX11ThreadPump_AddWorkItem, + D3DX11ThreadPump_GetWorkItemCount, + D3DX11ThreadPump_WaitForAllItems, + D3DX11ThreadPump_ProcessDeviceWorkItems, + D3DX11ThreadPump_PurgeAllItems, + D3DX11ThreadPump_GetQueueStatus +}; +static ID3DX11ThreadPump thread_pump = { &D3DX11ThreadPumpVtbl }; + /* 1x1 bmp (1 bpp) */ static const unsigned char bmp_1bpp[] = { @@ -173,6 +273,11 @@ static const unsigned char bmp_1bpp[] = 0x00,0x00 };
+static const unsigned char test_bmp_1bpp_data[] = +{ + 0xf3,0xf2,0xf1,0xff +}; + /* 1x1 bmp (2 bpp) */ static const unsigned char bmp_2bpp[] = { @@ -193,6 +298,11 @@ static const unsigned char bmp_4bpp[] = 0x00,0x00 };
+static const unsigned char test_bmp_4bpp_data[] = +{ + 0xf3,0xf2,0xf1,0xff +}; + /* 1x1 bmp (8 bpp) */ static const unsigned char bmp_8bpp[] = { @@ -203,6 +313,39 @@ static const unsigned char bmp_8bpp[] = 0x00,0x00 };
+static const unsigned char test_bmp_8bpp_data[] = +{ + 0xf3,0xf2,0xf1,0xff +}; + +/* 1x1 16bpp bmp image */ +static const unsigned char test_bmp_16bpp[] = +{ + 0x42,0x4d,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x10,0x00,0x00,0x00, + 0x00,0x00,0x06,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x42,0x00,0x00,0x00,0x00 +}; + +static const unsigned char test_bmp_16bpp_data[] = +{ + 0x84,0x84,0x73,0xff +}; + +/* 1x1 24bpp bmp image */ +static const unsigned char test_bmp_24bpp[] = +{ + 0x42,0x4d,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x18,0x00,0x00,0x00, + 0x00,0x00,0x06,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x84,0x84,0x00,0x00,0x00 +}; + +static const unsigned char test_bmp_24bpp_data[] = +{ + 0x84,0x84,0x73,0xff +}; + /* 2x2 bmp (32 bpp XRGB) */ static const unsigned char bmp_32bpp_xrgb[] = { @@ -213,6 +356,11 @@ static const unsigned char bmp_32bpp_xrgb[] = 0xc2,0x00,0xa3,0xb3,0xc3,0x00 };
+static const unsigned char test_bmp_32bpp_xrgb_data[] = +{ + 0xc2,0xb2,0xa2,0xff,0xc3,0xb3,0xa3,0xff,0xc0,0xb0,0xa0,0xff,0xc1,0xb1,0xa1,0xff +}; + /* 2x2 bmp (32 bpp ARGB) */ static const unsigned char bmp_32bpp_argb[] = { @@ -223,6 +371,11 @@ static const unsigned char bmp_32bpp_argb[] = 0xc2,0x00,0xa3,0xb3,0xc3,0x01 };
+static const unsigned char test_bmp_32bpp_argb_data[] = +{ + 0xc2,0xb2,0xa2,0xff,0xc3,0xb3,0xa3,0xff,0xc0,0xb0,0xa0,0xff,0xc1,0xb1,0xa1,0xff +}; + static const unsigned char png_grayscale[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, @@ -233,201 +386,1627 @@ static const unsigned char png_grayscale[] = 0x60, 0x82 };
-/* 2x2 24-bit dds, 2 mipmaps */ -static const unsigned char dds_24bit[] = +/* 1x1 8bpp gray png image */ +static const unsigned char test_png_8bpp_gray[] = { - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x02,0x00,0x00,0x00, - 0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, + 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, + 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x3a,0x7e,0x9b, + 0x55,0x00,0x00,0x00,0x0a,0x49,0x44,0x41,0x54,0x08,0xd7,0x63,0xf8,0x0f,0x00,0x01, + 0x01,0x01,0x00,0x1b,0xb6,0xee,0x56,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae, + 0x42,0x60,0x82 +}; + +static const unsigned char test_png_8bpp_gray_data[] = +{ + 0xff,0xff,0xff,0xff +}; + +/* 1x1 jpg image */ +static const unsigned char test_jpg[] = +{ + 0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2c, + 0x01,0x2c,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x05,0x03,0x04,0x04,0x04,0x03,0x05, + 0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x07,0x0c,0x08,0x07,0x07,0x07,0x07,0x0f,0x0b, + 0x0b,0x09,0x0c,0x11,0x0f,0x12,0x12,0x11,0x0f,0x11,0x11,0x13,0x16,0x1c,0x17,0x13, + 0x14,0x1a,0x15,0x11,0x11,0x18,0x21,0x18,0x1a,0x1d,0x1d,0x1f,0x1f,0x1f,0x13,0x17, + 0x22,0x24,0x22,0x1e,0x24,0x1c,0x1e,0x1f,0x1e,0xff,0xdb,0x00,0x43,0x01,0x05,0x05, + 0x05,0x07,0x06,0x07,0x0e,0x08,0x08,0x0e,0x1e,0x14,0x11,0x14,0x1e,0x1e,0x1e,0x1e, + 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e, + 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e, + 0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0xff,0xc0, + 0x00,0x11,0x08,0x00,0x01,0x00,0x01,0x03,0x01,0x22,0x00,0x02,0x11,0x01,0x03,0x11, + 0x01,0xff,0xc4,0x00,0x15,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xff,0xc4,0x00,0x14,0x10,0x01,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xc4, + 0x00,0x14,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xff,0xc4,0x00,0x14,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xda,0x00,0x0c,0x03,0x01, + 0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb2,0xc0,0x07,0xff,0xd9 +}; +static const unsigned char test_jpg_data[] = +{ + 0xff,0xff,0xff,0xff +}; + +/* 1x1 gif image */ +static const unsigned char test_gif[] = +{ + 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff, + 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44, + 0x01,0x00,0x3b +}; +static const unsigned char test_gif_data[] = +{ + 0xff,0xff,0xff,0xff +}; + +/* 1x1 tiff image */ +static const unsigned char test_tiff[] = +{ + 0x49,0x49,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0xfe,0x00, + 0x04,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x00,0x01,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00, + 0x00,0x00,0x02,0x01,0x03,0x00,0x03,0x00,0x00,0x00,0xd2,0x00,0x00,0x00,0x03,0x01, + 0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x01,0x03,0x00,0x01,0x00, + 0x00,0x00,0x02,0x00,0x00,0x00,0x0d,0x01,0x02,0x00,0x1b,0x00,0x00,0x00,0xd8,0x00, + 0x00,0x00,0x11,0x01,0x04,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x12,0x01, + 0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x15,0x01,0x03,0x00,0x01,0x00, + 0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x40,0x00, + 0x00,0x00,0x17,0x01,0x04,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x1a,0x01, + 0x05,0x00,0x01,0x00,0x00,0x00,0xf4,0x00,0x00,0x00,0x1b,0x01,0x05,0x00,0x01,0x00, + 0x00,0x00,0xfc,0x00,0x00,0x00,0x1c,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x01,0x00, + 0x00,0x00,0x28,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x2f,0x68,0x6f,0x6d,0x65,0x2f,0x6d,0x65, + 0x68,0x2f,0x44,0x65,0x73,0x6b,0x74,0x6f,0x70,0x2f,0x74,0x65,0x73,0x74,0x2e,0x74, + 0x69,0x66,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x48, + 0x00,0x00,0x00,0x01 +}; +static const unsigned char test_tiff_data[] = +{ + 0x00,0x00,0x00,0xff +}; + +/* 1x1 alpha dds image */ +static const unsigned char test_dds_alpha[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,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,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, - 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, - 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x10,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff + 0xff +}; +static const unsigned char test_dds_alpha_data[] = +{ + 0xff };
-/* 2x2 16-bit dds, no mipmaps */ -static const unsigned char dds_16bit[] = +/* 1x1 luminance dds image */ +static const unsigned char test_dds_luminance[] = { - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00, - 0x02,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,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,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, + 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0xff,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x82 +}; +static const unsigned char test_dds_luminance_data[] = +{ + 0x82,0x82,0x82,0xff +}; + +/* 1x1 16bpp dds image */ +static const unsigned char test_dds_16bpp[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x02,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,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, 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x7c,0x00,0x00, 0xe0,0x03,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f + 0x0e,0x42 +}; +static const unsigned char test_dds_16bpp_data[] = +{ + 0x84,0x84,0x73,0xff };
-/* 16x4 8-bit dds */ -static const unsigned char dds_8bit[] = +/* 1x1 24bpp dds image */ +static const unsigned char test_dds_24bpp[] = { - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x04,0x00,0x00,0x00, - 0x10,0x00,0x00,0x00,0x10,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, + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,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,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, - 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, - 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0x8c,0xcd,0x12,0xff, - 0x78,0x01,0x14,0xff,0x50,0xcd,0x12,0xff,0x00,0x3d,0x8c,0xff,0x02,0x00,0x00,0xff, - 0x47,0x00,0x00,0xff,0xda,0x07,0x02,0xff,0x50,0xce,0x12,0xff,0xea,0x11,0x01,0xff, - 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x08,0x3d,0x8c,0xff,0x08,0x01,0x00,0xff, - 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x60,0xcc,0x12,0xff, - 0xa1,0xb2,0xd4,0xff,0xda,0x07,0x02,0xff,0x47,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x50,0xce,0x12,0xff,0x00,0x00,0x14,0xff,0xa8,0xcc,0x12,0xff,0x3c,0xb2,0xd4,0xff, - 0xda,0x07,0x02,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0xff, - 0x21,0x00,0x00,0xff,0xd8,0xcb,0x12,0xff,0x54,0xcd,0x12,0xff,0x8b,0x4f,0xd5,0xff, - 0x00,0x04,0xda,0xff,0x00,0x00,0x00,0xff,0x3d,0x04,0x91,0xff,0x70,0xce,0x18,0xff, - 0xb4,0xcc,0x12,0xff,0x6b,0x4e,0xd5,0xff,0xb0,0xcc,0x12,0xff,0x00,0x00,0x00,0xff, - 0xc8,0x05,0x91,0xff,0x98,0xc7,0xcc,0xff,0x7c,0xcd,0x12,0xff,0x51,0x05,0x91,0xff, - 0x48,0x07,0x14,0xff,0x6d,0x05,0x91,0xff,0x00,0x07,0xda,0xff,0xa0,0xc7,0xcc,0xff, - 0x00,0x07,0xda,0xff,0x3a,0x77,0xd5,0xff,0xda,0x07,0x02,0xff,0x7c,0x94,0xd4,0xff, - 0xe0,0xce,0xd6,0xff,0x0a,0x80,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x78,0x9a,0xab,0xff,0xde,0x08,0x18,0xff,0xda,0x07,0x02,0xff,0x30,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x50,0xce,0x12,0xff,0x8c,0xcd,0x12,0xff,0xd0,0xb7,0xd8,0xff, - 0x00,0x00,0x00,0xff,0x60,0x32,0xd9,0xff,0x30,0xc1,0x1a,0xff,0xa8,0xcd,0x12,0xff, - 0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff,0x46,0x71,0x0e,0xff,0xc0,0x1d,0x4b,0xff, - 0x09,0x87,0xd4,0xff,0x00,0x00,0x00,0xff,0xf6,0x22,0x00,0xff,0x64,0xcd,0x12,0xff, - 0x00,0x00,0x00,0xff,0xca,0x1d,0x4b,0xff,0x09,0x87,0xd4,0xff,0xaa,0x02,0x05,0xff, - 0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0xc0,0x1d,0x4b,0xff, - 0xcd,0xab,0xba,0xff,0x00,0x00,0x00,0xff,0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff, - 0xd4,0xcd,0x12,0xff,0xa6,0x4c,0xd5,0xff,0x00,0xf0,0xfd,0xff,0xd4,0xcd,0x12,0xff, - 0xf4,0x4c,0xd5,0xff,0x90,0xcd,0x12,0xff,0xc2,0x4c,0xd5,0xff,0x82,0x00,0x00,0xff, - 0xaa,0x02,0x05,0xff,0x88,0xd4,0xba,0xff,0x14,0x00,0x00,0xff,0x01,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x0c,0x08,0x13,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0xd0,0xcd,0x12,0xff,0xc6,0x84,0xf1,0xff,0x7c,0x84,0xf1,0xff,0x20,0x20,0xf5,0xff, - 0x00,0x00,0x0a,0xff,0xf0,0xb0,0x94,0xff,0x64,0x6c,0xf1,0xff,0x85,0x6c,0xf1,0xff, - 0x8b,0x4f,0xd5,0xff,0x00,0x04,0xda,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff, - 0x39,0xde,0xd4,0xff,0x10,0x50,0xd5,0xff,0xaa,0x02,0x05,0xff,0x00,0x00,0x00,0xff, - 0x4f,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff,0x00,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff, - 0xaa,0x02,0x05,0xff,0x4c,0xce,0x12,0xff,0x39,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff, - 0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5b,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x68,0x50,0xcd,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0xe3,0xea,0x90,0xff,0x5c,0xce,0x12,0xff, - 0x18,0x00,0x00,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff, - 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 + 0x70,0x81,0x83 +}; +static const unsigned char test_dds_24bpp_data[] = +{ + 0x83,0x81,0x70,0xff };
-/* 4x4 cube map dds */ -static const unsigned char dds_cube_map[] = +/* 1x1 32bpp dds image */ +static const unsigned char test_dds_32bpp[] = { - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x04,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x04,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,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, - 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, - 0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, - 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50 + 0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x70,0x81,0x83,0xff +}; +static const unsigned char test_dds_32bpp_data[] = +{ + 0x83,0x81,0x70,0xff };
-/* 4x4x2 volume map dds, 2 mipmaps */ -static const unsigned char dds_volume_map[] = +/* 1x1 64bpp dds image */ +static const unsigned char test_dds_64bpp[] = { - 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00, + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x02,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,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,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, - 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, - 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, - 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c, - 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab + 0x04,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x83,0x83,0x81,0x81,0x70,0x70,0xff,0xff +}; +static const unsigned char test_dds_64bpp_data[] = +{ + 0x83,0x83,0x81,0x81,0x70,0x70,0xff,0xff };
-/* invalid image file */ -static const unsigned char noimage[4] = +/* 1x1 96bpp dds image */ +static const unsigned char test_dds_96bpp[] = { - 0x11,0x22,0x33,0x44 + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x02,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x31,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x06,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x84,0x83,0x03,0x3f,0x82,0x81,0x01,0x3f,0xe2,0xe0,0xe0,0x3e +}; +static const unsigned char test_dds_96bpp_data[] = +{ + 0x84,0x83,0x03,0x3f,0x82,0x81,0x01,0x3f,0xe2,0xe0,0xe0,0x3e };
-#define check_image_info_values(info, width, height, depth, array_size, mip_levels, misc_flags, format, resource_dimension, \ - image_file_format, wine_todo) \ - check_image_info_values_(__LINE__, info, width, height, depth, array_size, mip_levels, misc_flags, format, resource_dimension, \ - image_file_format, wine_todo) -static inline void check_image_info_values_(unsigned int line, const D3DX11_IMAGE_INFO *info, uint32_t width, - uint32_t height, uint32_t depth, uint32_t array_size, uint32_t mip_levels, uint32_t misc_flags, - DXGI_FORMAT format, D3D11_RESOURCE_DIMENSION resource_dimension, D3DX11_IMAGE_FILE_FORMAT image_file_format, - BOOL wine_todo) +/* 1x1 128bpp dds image */ +static const unsigned char test_dds_128bpp[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x02,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x84,0x83,0x03,0x3f,0x82,0x81,0x01,0x3f,0xe2,0xe0,0xe0,0x3e,0x00,0x00,0x80,0x3f +}; +static const unsigned char test_dds_128bpp_data[] = +{ + 0x84,0x83,0x03,0x3f,0x82,0x81,0x01,0x3f,0xe2,0xe0,0xe0,0x3e,0x00,0x00,0x80,0x3f + +}; + +/* 4x4 DXT1 dds image */ +static const unsigned char test_dds_dxt1[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x08,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,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, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x2a,0x31,0xf5,0xbc,0xe3,0x6e,0x2a,0x3a +}; +static const unsigned char test_dds_dxt1_data[] = +{ + 0x2a,0x31,0xf5,0xbc,0xe3,0x6e,0x2a,0x3a +}; + +/* 4x8 DXT1 dds image */ +static const unsigned char test_dds_dxt1_4x8[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x08,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x92,0xce,0x09,0x7a,0x5d,0xdd,0xa7,0x26,0x55,0xde,0xaf,0x52,0xbc,0xf8,0x6c,0x44, + 0x53,0xbd,0x8b,0x72,0x55,0x33,0x88,0xaa,0xb2,0x9c,0x6c,0x93,0x55,0x00,0x55,0x00, + 0x0f,0x9c,0x0f,0x9c,0x00,0x00,0x00,0x00, +}; +static const unsigned char test_dds_dxt1_4x8_data[] = +{ + 0x92,0xce,0x09,0x7a,0x5d,0xdd,0xa7,0x26,0x55,0xde,0xaf,0x52,0xbc,0xf8,0x6c,0x44, +}; + +/* 4x4 DXT2 dds image */ +static const unsigned char test_dds_dxt2[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x02,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xde,0xc4,0x10,0x2f,0xbf,0xff,0x7b, + 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x57,0x53,0x00,0x00,0x52,0x52,0x55,0x55, + 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0x59,0x00,0x00,0x54,0x55,0x55,0x55 +}; +static const unsigned char test_dds_dxt2_data[] = +{ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xde,0xc4,0x10,0x2f,0xbf,0xff,0x7b + +}; + +/* 1x3 DXT3 dds image */ +static const unsigned char test_dds_dxt3[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x03,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0c,0x92,0x38,0x84,0x00,0xff,0x55,0xff, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x53,0x8b,0x53,0x8b,0x00,0x00,0x00,0x00 +}; +static const unsigned char test_dds_dxt3_data[] = +{ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4e,0x92,0xd6,0x83,0x00,0xaa,0x55,0x55 + +}; + +/* 4x4 DXT4 dds image */ +static const unsigned char test_dds_dxt4[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x02,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xfd,0xde,0xc4,0x10,0x2f,0xbf,0xff,0x7b, + 0xff,0x00,0x40,0x02,0x24,0x49,0x92,0x24,0x57,0x53,0x00,0x00,0x52,0x52,0x55,0x55, + 0xff,0x00,0x48,0x92,0x24,0x49,0x92,0x24,0xce,0x59,0x00,0x00,0x54,0x55,0x55,0x55 +}; +static const unsigned char test_dds_dxt4_data[] = +{ + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xfd,0xde,0xc4,0x10,0x2f,0xbf,0xff,0x7b + +}; + +/* 4x2 DXT5 dds image */ +static const unsigned char test_dds_dxt5[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50 +}; +static const unsigned char test_dds_dxt5_data[] = +{ + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x05,0x05 + +}; + +/* 8x8 DXT5 dds image */ +static const unsigned char test_dds_dxt5_8x8[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x08,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x04,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x4b,0x8a,0x72,0x39,0x5e,0x5e,0xfa,0xa8, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0xd7,0xd5,0x4a,0x2d,0x2d,0xad,0xfd, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x9a,0x73,0x83,0xa0,0xf0,0x78,0x78, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x5b,0x06,0x19,0x00,0xe8,0x78,0x58, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x39,0xbe,0x8c,0x49,0x35,0xb5,0xff,0x7f, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x96,0x84,0xab,0x59,0x11,0xff,0x11,0xff, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x6a,0xf0,0x6a,0x00,0x00,0x00,0x00, +}; +static const unsigned char test_dds_dxt5_8x8_data[] = +{ + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x4b,0x8a,0x72,0x39,0x5e,0x5e,0xfa,0xa8, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0xd7,0xd5,0x4a,0x2d,0x2d,0xad,0xfd, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x9a,0x73,0x83,0xa0,0xf0,0x78,0x78, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x5b,0x06,0x19,0x00,0xe8,0x78,0x58, +}; + +/* 4x4 BC4 dds image */ +static const unsigned char test_dds_bc4[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x42,0x43,0x34,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xd9,0x15,0xbc,0x41,0x5b,0xa3,0x3d,0x3a,0x8f,0x3d,0x45,0x81,0x20,0x45,0x81,0x20, + 0x6f,0x6f,0x00,0x00,0x00,0x00,0x00,0x00 +}; +static const unsigned char test_dds_bc4_data[] = +{ + 0xd9,0x15,0xbc,0x41,0x5b,0xa3,0x3d,0x3a +}; + +/* 6x3 BC5 dds image */ +static const unsigned char test_dds_bc5[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x03,0x00,0x00,0x00, + 0x06,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x42,0x43,0x35,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x9f,0x28,0x73,0xac,0xd5,0x80,0xaa,0xd5,0x70,0x2c,0x4e,0xd6,0x76,0x1d,0xd6,0x76, + 0xd5,0x0f,0xc3,0x50,0x96,0xcf,0x53,0x96,0xdf,0x16,0xc3,0x50,0x96,0xcf,0x53,0x96, + 0x83,0x55,0x08,0x83,0x30,0x08,0x83,0x30,0x79,0x46,0x31,0x1c,0xc3,0x31,0x1c,0xc3, + 0x6d,0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x5c,0x00,0x00,0x00,0x00,0x00,0x00 +}; +static const unsigned char test_dds_bc5_data[] = +{ + 0x95,0x35,0xe2,0xa3,0xf5,0xd2,0x28,0x68,0x65,0x32,0x7c,0x4e,0xdb,0xe4,0x56,0x0a, + 0xb9,0x33,0xaf,0xf0,0x52,0xbe,0xed,0x27,0xb4,0x2e,0xa6,0x60,0x4e,0xb6,0x5d,0x3f + +}; + +/* 4x4 DXT1 cube map */ +static const unsigned char test_dds_cube[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7,0x32,0x96,0x0b,0x7b,0xcc,0x55,0xcc,0x55, + 0x0e,0x84,0x0e,0x84,0x00,0x00,0x00,0x00,0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7, + 0x32,0x96,0x0b,0x7b,0xcc,0x55,0xcc,0x55,0x0e,0x84,0x0e,0x84,0x00,0x00,0x00,0x00, + 0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7,0x32,0x96,0x0b,0x7b,0xcc,0x55,0xcc,0x55, + 0x0e,0x84,0x0e,0x84,0x00,0x00,0x00,0x00,0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7, + 0x32,0x96,0x0b,0x7b,0xcc,0x55,0xcc,0x55,0x0e,0x84,0x0e,0x84,0x00,0x00,0x00,0x00, + 0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7,0x32,0x96,0x0b,0x7b,0xcc,0x55,0xcc,0x55, + 0x0e,0x84,0x0e,0x84,0x00,0x00,0x00,0x00,0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7, + 0x32,0x96,0x0b,0x7b,0xcc,0x55,0xcc,0x55,0x0e,0x84,0x0e,0x84,0x00,0x00,0x00,0x00 +}; +static const unsigned char test_dds_cube_data[] = +{ + 0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7, + 0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7, + 0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7, + 0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7, + 0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7, + 0xf5,0xa7,0x08,0x69,0x74,0xc0,0xbf,0xd7 +}; + +/* 4x4x2 DXT3 volume dds,2 mipmaps */ +static const unsigned char test_dds_volume[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c, + 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab +}; +static const unsigned char test_dds_volume_data[] = +{ + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, +}; + +/* 1x1 wmp image */ +static const unsigned char test_wmp[] = +{ + 0x49,0x49,0xbc,0x01,0x20,0x00,0x00,0x00,0x24,0xc3,0xdd,0x6f,0x03,0x4e,0xfe,0x4b, + 0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x08,0x00,0x01,0xbc,0x01,0x00,0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x02,0xbc, + 0x04,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xbc,0x04,0x00,0x01,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x81,0xbc,0x04,0x00,0x01,0x00,0x00,0x00,0x01,0x00, + 0x00,0x00,0x82,0xbc,0x0b,0x00,0x01,0x00,0x00,0x00,0x25,0x06,0xc0,0x42,0x83,0xbc, + 0x0b,0x00,0x01,0x00,0x00,0x00,0x25,0x06,0xc0,0x42,0xc0,0xbc,0x04,0x00,0x01,0x00, + 0x00,0x00,0x86,0x00,0x00,0x00,0xc1,0xbc,0x04,0x00,0x01,0x00,0x00,0x00,0x92,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x4d,0x50,0x48,0x4f,0x54,0x4f,0x00,0x11,0x45, + 0xc0,0x71,0x00,0x00,0x00,0x00,0x60,0x00,0xc0,0x00,0x00,0x0c,0x00,0x00,0x00,0xc0, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x25,0xff,0xff,0x00,0x00,0x01, + 0x01,0xc8,0xf0,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x10,0x10,0xa6,0x18,0x8c,0x21, + 0x00,0xc4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x03,0x4e,0x0f,0x3a,0x4c,0x94,0x9d,0xba,0x79,0xe7,0x38, + 0x4c,0xcf,0x14,0xc3,0x43,0x91,0x88,0xfb,0xdc,0xe0,0x7c,0x34,0x70,0x9b,0x28,0xa9, + 0x18,0x74,0x62,0x87,0x8e,0xe4,0x68,0x5f,0xb9,0xcc,0x0e,0xe1,0x8c,0x76,0x3a,0x9b, + 0x82,0x76,0x71,0x13,0xde,0x50,0xd4,0x2d,0xc2,0xda,0x1e,0x3b,0xa6,0xa1,0x62,0x7b, + 0xca,0x1a,0x85,0x4b,0x6e,0x74,0xec,0x60 +}; + +static const unsigned char test_wmp_data[] = +{ + 0xff,0xff,0xff,0xff +}; + +/* 2x2 24-bit dds, 2 mipmaps */ +static const unsigned char dds_24bit[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x02,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +}; + +/* 2x2 16-bit dds, no mipmaps */ +static const unsigned char dds_16bit[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00, + 0x02,0x00,0x00,0x00,0x08,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,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, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x7c,0x00,0x00, + 0xe0,0x03,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f +}; + +/* 16x4 8-bit dds */ +static const unsigned char dds_8bit[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x04,0x00,0x00,0x00, + 0x10,0x00,0x00,0x00,0x10,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, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff, + 0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0x8c,0xcd,0x12,0xff, + 0x78,0x01,0x14,0xff,0x50,0xcd,0x12,0xff,0x00,0x3d,0x8c,0xff,0x02,0x00,0x00,0xff, + 0x47,0x00,0x00,0xff,0xda,0x07,0x02,0xff,0x50,0xce,0x12,0xff,0xea,0x11,0x01,0xff, + 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x08,0x3d,0x8c,0xff,0x08,0x01,0x00,0xff, + 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x60,0xcc,0x12,0xff, + 0xa1,0xb2,0xd4,0xff,0xda,0x07,0x02,0xff,0x47,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x50,0xce,0x12,0xff,0x00,0x00,0x14,0xff,0xa8,0xcc,0x12,0xff,0x3c,0xb2,0xd4,0xff, + 0xda,0x07,0x02,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0xff, + 0x21,0x00,0x00,0xff,0xd8,0xcb,0x12,0xff,0x54,0xcd,0x12,0xff,0x8b,0x4f,0xd5,0xff, + 0x00,0x04,0xda,0xff,0x00,0x00,0x00,0xff,0x3d,0x04,0x91,0xff,0x70,0xce,0x18,0xff, + 0xb4,0xcc,0x12,0xff,0x6b,0x4e,0xd5,0xff,0xb0,0xcc,0x12,0xff,0x00,0x00,0x00,0xff, + 0xc8,0x05,0x91,0xff,0x98,0xc7,0xcc,0xff,0x7c,0xcd,0x12,0xff,0x51,0x05,0x91,0xff, + 0x48,0x07,0x14,0xff,0x6d,0x05,0x91,0xff,0x00,0x07,0xda,0xff,0xa0,0xc7,0xcc,0xff, + 0x00,0x07,0xda,0xff,0x3a,0x77,0xd5,0xff,0xda,0x07,0x02,0xff,0x7c,0x94,0xd4,0xff, + 0xe0,0xce,0xd6,0xff,0x0a,0x80,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x78,0x9a,0xab,0xff,0xde,0x08,0x18,0xff,0xda,0x07,0x02,0xff,0x30,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x50,0xce,0x12,0xff,0x8c,0xcd,0x12,0xff,0xd0,0xb7,0xd8,0xff, + 0x00,0x00,0x00,0xff,0x60,0x32,0xd9,0xff,0x30,0xc1,0x1a,0xff,0xa8,0xcd,0x12,0xff, + 0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff,0x46,0x71,0x0e,0xff,0xc0,0x1d,0x4b,0xff, + 0x09,0x87,0xd4,0xff,0x00,0x00,0x00,0xff,0xf6,0x22,0x00,0xff,0x64,0xcd,0x12,0xff, + 0x00,0x00,0x00,0xff,0xca,0x1d,0x4b,0xff,0x09,0x87,0xd4,0xff,0xaa,0x02,0x05,0xff, + 0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0xc0,0x1d,0x4b,0xff, + 0xcd,0xab,0xba,0xff,0x00,0x00,0x00,0xff,0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff, + 0xd4,0xcd,0x12,0xff,0xa6,0x4c,0xd5,0xff,0x00,0xf0,0xfd,0xff,0xd4,0xcd,0x12,0xff, + 0xf4,0x4c,0xd5,0xff,0x90,0xcd,0x12,0xff,0xc2,0x4c,0xd5,0xff,0x82,0x00,0x00,0xff, + 0xaa,0x02,0x05,0xff,0x88,0xd4,0xba,0xff,0x14,0x00,0x00,0xff,0x01,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x0c,0x08,0x13,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0xd0,0xcd,0x12,0xff,0xc6,0x84,0xf1,0xff,0x7c,0x84,0xf1,0xff,0x20,0x20,0xf5,0xff, + 0x00,0x00,0x0a,0xff,0xf0,0xb0,0x94,0xff,0x64,0x6c,0xf1,0xff,0x85,0x6c,0xf1,0xff, + 0x8b,0x4f,0xd5,0xff,0x00,0x04,0xda,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff, + 0x39,0xde,0xd4,0xff,0x10,0x50,0xd5,0xff,0xaa,0x02,0x05,0xff,0x00,0x00,0x00,0xff, + 0x4f,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff,0x00,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff, + 0xaa,0x02,0x05,0xff,0x4c,0xce,0x12,0xff,0x39,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff, + 0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5b,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x68,0x50,0xcd,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0xe3,0xea,0x90,0xff,0x5c,0xce,0x12,0xff, + 0x18,0x00,0x00,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff, + 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 +}; + +/* 4x4 cube map dds */ +static const unsigned char dds_cube_map[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x04,0x00,0x00,0x00, + 0x04,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,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, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00, + 0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50 +}; + +/* 4x4x2 volume map dds, 2 mipmaps */ +static const unsigned char dds_volume_map[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50, + 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c, + 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab +}; + +/* + * 8x8 24-bit dds, 4 mipmaps. Level 0 is red, level 1 is green, level 2 is + * blue, and level 3 is black. + */ +static const unsigned char dds_24bit_8_8[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x08,0x00,0x00,0x00, + 0x08,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff, + 0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00, + 0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00 +}; + +/* 4x4 cube map DDS file with 2 mips. */ +static const unsigned char dds_cube_map_4_4[] = +{ + 0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x02,0x00,0x04,0x00,0x00,0x00, + 0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,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,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, + 0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0xff,0x00,0x00,0x00, + 0x00,0xff,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0xff,0x08,0x10,0x40,0x00, + 0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00, + 0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00, + 0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00, + 0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00, + 0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00, + 0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00, + 0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00, + 0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00, + 0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00, + 0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00, + 0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00, + 0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00, + 0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00, + 0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00, + 0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00, + 0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00, + 0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00, + 0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00, + 0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, + 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, + 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, + 0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00, + 0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00, + 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, + 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, + 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, + 0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00, + 0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x00, +}; + +/* invalid image file */ +static const unsigned char noimage[4] = +{ + 0x11,0x22,0x33,0x44 +}; + +static const struct test_image +{ + const unsigned char *data; + unsigned int size; + const unsigned char *expected_data; + D3DX11_IMAGE_INFO expected_info; +} test_image[] = +{ + { + bmp_1bpp, sizeof(bmp_1bpp), test_bmp_1bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_BMP} + }, + { + bmp_4bpp, sizeof(bmp_4bpp), test_bmp_4bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_BMP} + }, + { + bmp_8bpp, sizeof(bmp_8bpp), test_bmp_8bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_BMP} + }, + { + test_bmp_16bpp, sizeof(test_bmp_16bpp), test_bmp_16bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_BMP} + }, + { + test_bmp_24bpp, sizeof(test_bmp_24bpp), test_bmp_24bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_BMP} + }, + /* 5. */ + { + bmp_32bpp_xrgb, sizeof(bmp_32bpp_xrgb), test_bmp_32bpp_xrgb_data, + {2, 2, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_BMP} + }, + { + bmp_32bpp_argb, sizeof(bmp_32bpp_argb), test_bmp_32bpp_argb_data, + {2, 2, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_BMP} + }, + { + test_png_8bpp_gray, sizeof(test_png_8bpp_gray), test_png_8bpp_gray_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_PNG} + }, + { + test_jpg, sizeof(test_jpg), test_jpg_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_JPG} + }, + { + test_gif, sizeof(test_gif), test_gif_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_GIF} + }, + /* 10. */ + { + test_tiff, sizeof(test_tiff), test_tiff_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_TIFF} + }, + { + test_dds_alpha, sizeof(test_dds_alpha), test_dds_alpha_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_luminance, sizeof(test_dds_luminance), test_dds_luminance_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_16bpp, sizeof(test_dds_16bpp), test_dds_16bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_24bpp, sizeof(test_dds_24bpp), test_dds_24bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + /* 15. */ + { + test_dds_32bpp, sizeof(test_dds_32bpp), test_dds_32bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_64bpp, sizeof(test_dds_64bpp), test_dds_64bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R16G16B16A16_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_96bpp, sizeof(test_dds_96bpp), test_dds_96bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R32G32B32_FLOAT, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_128bpp, sizeof(test_dds_128bpp), test_dds_128bpp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R32G32B32A32_FLOAT, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_dxt1, sizeof(test_dds_dxt1), test_dds_dxt1_data, + {4, 4, 1, 1, 1, 0, DXGI_FORMAT_BC1_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + /* 20. */ + { + test_dds_dxt1_4x8, sizeof(test_dds_dxt1_4x8), test_dds_dxt1_4x8_data, + {4, 8, 1, 1, 4, 0, DXGI_FORMAT_BC1_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_dxt2, sizeof(test_dds_dxt2), test_dds_dxt2_data, + {4, 4, 1, 1, 3, 0, DXGI_FORMAT_BC2_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_dxt3, sizeof(test_dds_dxt3), test_dds_dxt3_data, + {1, 3, 1, 1, 2, 0, DXGI_FORMAT_BC2_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_dxt4, sizeof(test_dds_dxt4), test_dds_dxt4_data, + {4, 4, 1, 1, 3, 0, DXGI_FORMAT_BC3_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_dxt5, sizeof(test_dds_dxt5), test_dds_dxt5_data, + {4, 2, 1, 1, 1, 0, DXGI_FORMAT_BC3_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + /* 25. */ + { + test_dds_dxt5_8x8, sizeof(test_dds_dxt5_8x8), test_dds_dxt5_8x8_data, + {8, 8, 1, 1, 4, 0, DXGI_FORMAT_BC3_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_bc4, sizeof(test_dds_bc4), test_dds_bc4_data, + {4, 4, 1, 1, 3, 0, DXGI_FORMAT_BC4_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_bc5, sizeof(test_dds_bc5), test_dds_bc5_data, + {6, 3, 1, 1, 3, 0, DXGI_FORMAT_BC5_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_cube, sizeof(test_dds_cube), test_dds_cube_data, + {4, 4, 1, 6, 3, 0x4, DXGI_FORMAT_BC1_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS} + }, + { + test_dds_volume, sizeof(test_dds_volume), test_dds_volume_data, + {4, 4, 2, 1, 3, 0, DXGI_FORMAT_BC2_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE3D, D3DX11_IFF_DDS} + }, + /* 30. */ + { + test_wmp, sizeof(test_wmp), test_wmp_data, + {1, 1, 1, 1, 1, 0, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_WMP} + }, +}; + +static const struct test_image_load_info +{ + const uint8_t *data; + uint32_t size; + D3DX11_IMAGE_LOAD_INFO load_info; + HRESULT expected_hr; + + D3D11_RESOURCE_DIMENSION expected_type; + union + { + D3D11_TEXTURE2D_DESC desc_2d; + D3D11_TEXTURE3D_DESC desc_3d; + } expected_resource_desc; + BOOL todo_resource_desc; +} test_image_load_info[] = +{ + /* + * Autogen mips misc flag specified. In the case of a cube texture image, + * the autogen mips flag is OR'd against D3D11_RESOURCE_MISC_TEXTURECUBE, + * even if it isn't specified in the load info structure. + */ + { + dds_cube_map_4_4, sizeof(dds_cube_map_4_4), + { + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, (D3D11_USAGE)D3DX11_DEFAULT, + (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET), D3DX11_DEFAULT, D3D11_RESOURCE_MISC_GENERATE_MIPS, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT + }, + S_OK, D3D11_RESOURCE_DIMENSION_TEXTURE2D, + { + .desc_2d = + { + 4, 4, 3, 6, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, D3D11_USAGE_DEFAULT, + (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET), 0, + (D3D11_RESOURCE_MISC_GENERATE_MIPS | D3D11_RESOURCE_MISC_TEXTURECUBE) + } + } + }, + /* + * Pass in different dimensions and texture format than the source image. + */ + { + test_dds_dxt1, sizeof(test_dds_dxt1), + { + 8, 8, D3DX11_DEFAULT, D3DX11_DEFAULT, 1, (D3D11_USAGE)D3DX11_DEFAULT, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, DXGI_FORMAT_R8G8B8A8_UNORM, D3DX11_DEFAULT, + D3DX11_DEFAULT + }, + S_OK, D3D11_RESOURCE_DIMENSION_TEXTURE2D, + { + .desc_2d = + { + 8, 8, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0 + } + } + }, +}; + +static const struct test_invalid_image_load_info +{ + const uint8_t *data; + uint32_t size; + D3DX11_IMAGE_LOAD_INFO load_info; + HRESULT expected_hr; + HRESULT expected_process_hr; + HRESULT expected_create_device_object_hr; + BOOL todo_hr; + BOOL todo_process_hr; + BOOL todo_create_device_object_hr; +} test_invalid_image_load_info[] = +{ + /* + * A depth value that isn't D3DX11_FROM_FILE/D3DX11_DEFAULT/0 on a 2D + * texture results in failure. + */ + { + test_dds_32bpp, sizeof(test_dds_32bpp), + { + D3DX11_DEFAULT, D3DX11_DEFAULT, 2, D3DX11_DEFAULT, D3DX11_DEFAULT, (D3D11_USAGE)D3DX11_DEFAULT, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT + }, + E_FAIL, E_FAIL + }, + /* Invalid filter value. */ + { + test_dds_32bpp, sizeof(test_dds_32bpp), + { + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, (D3D11_USAGE)D3DX11_DEFAULT, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, 7, D3DX11_DEFAULT + }, + D3DERR_INVALIDCALL, D3DERR_INVALIDCALL + }, + /* Invalid mipfilter value, only validated if mips are generated. */ + { + test_dds_32bpp, sizeof(test_dds_32bpp), + { + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, (D3D11_USAGE)D3DX11_DEFAULT, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, 7 + }, + S_OK, S_OK, S_OK + }, + /* Invalid mipfilter value. */ + { + test_dds_32bpp, sizeof(test_dds_32bpp), + { + 2, 2, D3DX11_DEFAULT, D3DX11_DEFAULT, 2, (D3D11_USAGE)D3DX11_DEFAULT, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, 7 + }, + D3DERR_INVALIDCALL, D3DERR_INVALIDCALL + }, + /* + * Usage/BindFlags/CpuAccessFlags are validated in the call to + * CreateDeviceObject(). + */ + { + test_dds_32bpp, sizeof(test_dds_32bpp), + { + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3D11_CPU_ACCESS_READ, D3D11_USAGE_DYNAMIC, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT + }, + E_INVALIDARG, S_OK, E_INVALIDARG + }, + /* 5. */ + { + test_dds_32bpp, sizeof(test_dds_32bpp), + { + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3D11_USAGE_DEFAULT, + D3D11_BIND_DEPTH_STENCIL, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT + }, + E_INVALIDARG, S_OK, E_INVALIDARG + }, + /* + * D3D11_RESOURCE_MISC_GENERATE_MIPS requires binding as a shader resource + * and a render target. + */ + { + test_dds_32bpp, sizeof(test_dds_32bpp), + { + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3D11_USAGE_DEFAULT, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3D11_RESOURCE_MISC_GENERATE_MIPS, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT + }, + E_INVALIDARG, S_OK, E_INVALIDARG + }, + /* Can't set the cube texture flag if the image isn't a cube texture. */ + { + test_dds_32bpp, sizeof(test_dds_32bpp), + { + D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT, D3D11_USAGE_DEFAULT, + D3DX11_DEFAULT, D3DX11_DEFAULT, D3D11_RESOURCE_MISC_TEXTURECUBE, D3DX11_DEFAULT, D3DX11_DEFAULT, D3DX11_DEFAULT + }, + E_INVALIDARG, S_OK, E_INVALIDARG + }, +}; + +static DXGI_FORMAT block_compressed_formats[] = +{ + DXGI_FORMAT_BC1_TYPELESS, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM_SRGB, + DXGI_FORMAT_BC2_TYPELESS, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM_SRGB, + DXGI_FORMAT_BC3_TYPELESS, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM_SRGB, + DXGI_FORMAT_BC4_TYPELESS, DXGI_FORMAT_BC4_UNORM, DXGI_FORMAT_BC4_SNORM, + DXGI_FORMAT_BC5_TYPELESS, DXGI_FORMAT_BC5_UNORM, DXGI_FORMAT_BC5_SNORM, + DXGI_FORMAT_BC6H_TYPELESS, DXGI_FORMAT_BC6H_UF16, DXGI_FORMAT_BC6H_SF16, + DXGI_FORMAT_BC7_TYPELESS, DXGI_FORMAT_BC7_UNORM, DXGI_FORMAT_BC7_UNORM_SRGB +}; + +static BOOL is_block_compressed(DXGI_FORMAT format) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(block_compressed_formats); ++i) + if (format == block_compressed_formats[i]) + return TRUE; + + return FALSE; +} + +#define check_image_info_values(info, width, height, depth, array_size, mip_levels, misc_flags, format, resource_dimension, \ + image_file_format, wine_todo) \ + check_image_info_values_(__LINE__, info, width, height, depth, array_size, mip_levels, misc_flags, format, resource_dimension, \ + image_file_format, wine_todo) +static inline void check_image_info_values_(unsigned int line, const D3DX11_IMAGE_INFO *info, uint32_t width, + uint32_t height, uint32_t depth, uint32_t array_size, uint32_t mip_levels, uint32_t misc_flags, + DXGI_FORMAT format, D3D11_RESOURCE_DIMENSION resource_dimension, D3DX11_IMAGE_FILE_FORMAT image_file_format, + BOOL wine_todo) +{ + const D3DX11_IMAGE_INFO expected_info = { width, height, depth, array_size, mip_levels, misc_flags, format, + resource_dimension, image_file_format }; + BOOL matched; + + matched = !memcmp(&expected_info, info, sizeof(*info)); + todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected image info values.\n"); + if (matched) + return; + + todo_wine_if(wine_todo && info->Width != width) + ok_(__FILE__, line)(info->Width == width, "Expected width %u, got %u.\n", width, info->Width); + todo_wine_if(wine_todo && info->Height != height) + ok_(__FILE__, line)(info->Height == height, "Expected height %u, got %u.\n", height, info->Height); + todo_wine_if(wine_todo && info->Depth != depth) + ok_(__FILE__, line)(info->Depth == depth, "Expected depth %u, got %u.\n", depth, info->Depth); + todo_wine_if(wine_todo && info->ArraySize != array_size) + ok_(__FILE__, line)(info->ArraySize == array_size, "Expected array_size %u, got %u.\n", array_size, + info->ArraySize); + todo_wine_if(wine_todo && info->MipLevels != mip_levels) + ok_(__FILE__, line)(info->MipLevels == mip_levels, "Expected mip_levels %u, got %u.\n", mip_levels, + info->MipLevels); + todo_wine_if(wine_todo && info->MiscFlags != misc_flags) + ok_(__FILE__, line)(info->MiscFlags == misc_flags, "Expected misc_flags %u, got %u.\n", misc_flags, + info->MiscFlags); + ok_(__FILE__, line)(info->Format == format, "Expected texture format %d, got %d.\n", format, info->Format); + todo_wine_if(wine_todo && info->ResourceDimension != resource_dimension) + ok_(__FILE__, line)(info->ResourceDimension == resource_dimension, "Expected resource_dimension %d, got %d.\n", + resource_dimension, info->ResourceDimension); + ok_(__FILE__, line)(info->ImageFileFormat == image_file_format, "Expected image_file_format %d, got %d.\n", + image_file_format, info->ImageFileFormat); +} + +#define check_texture2d_desc(desc, expected, wine_todo) check_texture2d_desc_(__LINE__, desc, expected, wine_todo) +static inline void check_texture2d_desc_(uint32_t line, const D3D11_TEXTURE2D_DESC *desc, const D3D11_TEXTURE2D_DESC *expected, + BOOL wine_todo) +{ + BOOL matched; + + matched = !memcmp(expected, desc, sizeof(*desc)); + todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected 2D texture desc values.\n"); + if (matched) + return; + + todo_wine_if(wine_todo && desc->Width != expected->Width) + ok_(__FILE__, line)(desc->Width == expected->Width, "Expected width %u, got %u.\n", expected->Width, + desc->Width); + todo_wine_if(wine_todo && desc->Height != expected->Height) + ok_(__FILE__, line)(desc->Height == expected->Height, "Expected height %u, got %u.\n", expected->Height, + desc->Height); + todo_wine_if(wine_todo && desc->ArraySize != expected->ArraySize) + ok_(__FILE__, line)(desc->ArraySize == expected->ArraySize, "Expected array size %u, got %u.\n", + expected->ArraySize, desc->ArraySize); + todo_wine_if(wine_todo && desc->MipLevels != expected->MipLevels) + ok_(__FILE__, line)(desc->MipLevels == expected->MipLevels, "Expected mip levels %u, got %u.\n", + expected->MipLevels, desc->MipLevels); + todo_wine_if(wine_todo && desc->Format != expected->Format) + ok_(__FILE__, line)(desc->Format == expected->Format, "Expected texture format %#x, got %#x.\n", + expected->Format, desc->Format); + todo_wine_if(wine_todo && desc->SampleDesc.Count != expected->SampleDesc.Count) + ok_(__FILE__, line)(desc->SampleDesc.Count == expected->SampleDesc.Count, "Expected sample count %u, got %u.\n", + expected->SampleDesc.Count, desc->SampleDesc.Count); + todo_wine_if(wine_todo && desc->SampleDesc.Quality != expected->SampleDesc.Quality) + ok_(__FILE__, line)(desc->SampleDesc.Quality == expected->SampleDesc.Quality, + "Expected sample quality %u, got %u.\n", expected->SampleDesc.Quality, desc->SampleDesc.Quality); + todo_wine_if(wine_todo && desc->Usage != expected->Usage) + ok_(__FILE__, line)(desc->Usage == expected->Usage, "Expected usage %u, got %u.\n", expected->Usage, + desc->Usage); + todo_wine_if(wine_todo && desc->BindFlags != expected->BindFlags) + ok_(__FILE__, line)(desc->BindFlags == expected->BindFlags, "Expected bind flags %#x, got %#x.\n", + expected->BindFlags, desc->BindFlags); + todo_wine_if(wine_todo && desc->CPUAccessFlags != expected->CPUAccessFlags) + ok_(__FILE__, line)(desc->CPUAccessFlags == expected->CPUAccessFlags, + "Expected CPU access flags %#x, got %#x.\n", expected->CPUAccessFlags, desc->CPUAccessFlags); + todo_wine_if(wine_todo && desc->MiscFlags != expected->MiscFlags) + ok_(__FILE__, line)(desc->MiscFlags == expected->MiscFlags, "Expected misc flags %#x, got %#x.\n", + expected->MiscFlags, desc->MiscFlags); +} + +#define check_texture2d_desc_values(desc, width, height, mip_levels, array_size, format, sample_count, sample_quality, \ + usage, bind_flags, cpu_access_flags, misc_flags, wine_todo) \ + check_texture2d_desc_values_(__LINE__, desc, width, height, mip_levels, array_size, format, sample_count, sample_quality, \ + usage, bind_flags, cpu_access_flags, misc_flags, wine_todo) +static inline void check_texture2d_desc_values_(uint32_t line, const D3D11_TEXTURE2D_DESC *desc, uint32_t width, + uint32_t height, uint32_t mip_levels, uint32_t array_size, DXGI_FORMAT format, uint32_t sample_count, + uint32_t sample_quality, D3D11_USAGE usage, uint32_t bind_flags, uint32_t cpu_access_flags, uint32_t misc_flags, + BOOL wine_todo) +{ + const D3D11_TEXTURE2D_DESC expected_desc = { width, height, mip_levels, array_size, format, { sample_count, sample_quality }, + usage, bind_flags, cpu_access_flags, misc_flags }; + + check_texture2d_desc_(line, desc, &expected_desc, wine_todo); +} + +#define check_texture3d_desc(desc, expected, wine_todo) check_texture3d_desc_(__LINE__, desc, expected, wine_todo) +static inline void check_texture3d_desc_(uint32_t line, const D3D11_TEXTURE3D_DESC *desc, + const D3D11_TEXTURE3D_DESC *expected, BOOL wine_todo) +{ + BOOL matched; + + matched = !memcmp(expected, desc, sizeof(*desc)); + todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected 3D texture desc values.\n"); + if (matched) + return; + + todo_wine_if(wine_todo && desc->Width != expected->Width) + ok_(__FILE__, line)(desc->Width == expected->Width, "Expected width %u, got %u.\n", expected->Width, + desc->Width); + todo_wine_if(wine_todo && desc->Height != expected->Height) + ok_(__FILE__, line)(desc->Height == expected->Height, "Expected height %u, got %u.\n", expected->Height, + desc->Height); + todo_wine_if(wine_todo && desc->Depth != expected->Depth) + ok_(__FILE__, line)(desc->Depth == expected->Depth, "Expected depth %u, got %u.\n", expected->Depth, + desc->Depth); + todo_wine_if(wine_todo && desc->MipLevels != expected->MipLevels) + ok_(__FILE__, line)(desc->MipLevels == expected->MipLevels, "Expected mip levels %u, got %u.\n", + expected->MipLevels, desc->MipLevels); + todo_wine_if(wine_todo && desc->Format != expected->Format) + ok_(__FILE__, line)(desc->Format == expected->Format, "Expected texture format %#x, got %#x.\n", + expected->Format, desc->Format); + todo_wine_if(wine_todo && desc->Usage != expected->Usage) + ok_(__FILE__, line)(desc->Usage == expected->Usage, "Expected usage %u, got %u.\n", expected->Usage, + desc->Usage); + todo_wine_if(wine_todo && desc->BindFlags != expected->BindFlags) + ok_(__FILE__, line)(desc->BindFlags == expected->BindFlags, "Expected bind flags %#x, got %#x.\n", + expected->BindFlags, desc->BindFlags); + todo_wine_if(wine_todo && desc->CPUAccessFlags != expected->CPUAccessFlags) + ok_(__FILE__, line)(desc->CPUAccessFlags == expected->CPUAccessFlags, + "Expected CPU access flags %#x, got %#x.\n", expected->CPUAccessFlags, desc->CPUAccessFlags); + todo_wine_if(wine_todo && desc->MiscFlags != expected->MiscFlags) + ok_(__FILE__, line)(desc->MiscFlags == expected->MiscFlags, "Expected misc flags %#x, got %#x.\n", + expected->MiscFlags, desc->MiscFlags); +} + +/* + * Taken from the d3d11 tests. If there's a missing resource type or + * texture format checking function, check to see if it exists there first. + */ +struct resource_readback +{ + ID3D11Resource *resource; + D3D11_MAPPED_SUBRESOURCE map_desc; + ID3D11DeviceContext *immediate_context; + unsigned int width, height, depth, sub_resource_idx; +}; + +static void init_resource_readback(ID3D11Resource *resource, ID3D11Resource *readback_resource, + unsigned int width, unsigned int height, unsigned int depth, unsigned int sub_resource_idx, + ID3D11Device *device, struct resource_readback *rb) +{ + HRESULT hr; + + rb->resource = readback_resource; + rb->width = width; + rb->height = height; + rb->depth = depth; + rb->sub_resource_idx = sub_resource_idx; + + ID3D11Device_GetImmediateContext(device, &rb->immediate_context); + + ID3D11DeviceContext_CopyResource(rb->immediate_context, rb->resource, resource); + if (FAILED(hr = ID3D11DeviceContext_Map(rb->immediate_context, + rb->resource, sub_resource_idx, D3D11_MAP_READ, 0, &rb->map_desc))) + { + trace("Failed to map resource, hr %#lx.\n", hr); + ID3D11Resource_Release(rb->resource); + rb->resource = NULL; + ID3D11DeviceContext_Release(rb->immediate_context); + rb->immediate_context = NULL; + } +} + +static void get_texture_readback(ID3D11Texture2D *texture, unsigned int sub_resource_idx, + struct resource_readback *rb) +{ + D3D11_TEXTURE2D_DESC texture_desc; + ID3D11Resource *rb_texture; + unsigned int miplevel; + ID3D11Device *device; + HRESULT hr; + + memset(rb, 0, sizeof(*rb)); + + ID3D11Texture2D_GetDevice(texture, &device); + + ID3D11Texture2D_GetDesc(texture, &texture_desc); + texture_desc.Usage = D3D11_USAGE_STAGING; + texture_desc.BindFlags = 0; + texture_desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + texture_desc.MiscFlags = 0; + if (FAILED(hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, (ID3D11Texture2D **)&rb_texture))) + { + trace("Failed to create texture, hr %#lx.\n", hr); + ID3D11Device_Release(device); + return; + } + + miplevel = sub_resource_idx % texture_desc.MipLevels; + init_resource_readback((ID3D11Resource *)texture, rb_texture, + max(1, texture_desc.Width >> miplevel), + max(1, texture_desc.Height >> miplevel), + 1, sub_resource_idx, device, rb); + + ID3D11Device_Release(device); +} + +static void get_texture3d_readback(ID3D11Texture3D *texture, unsigned int sub_resource_idx, + struct resource_readback *rb) +{ + D3D11_TEXTURE3D_DESC texture_desc; + ID3D11Resource *rb_texture; + unsigned int miplevel; + ID3D11Device *device; + HRESULT hr; + + memset(rb, 0, sizeof(*rb)); + + ID3D11Texture3D_GetDevice(texture, &device); + + ID3D11Texture3D_GetDesc(texture, &texture_desc); + texture_desc.Usage = D3D11_USAGE_STAGING; + texture_desc.BindFlags = 0; + texture_desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + texture_desc.MiscFlags = 0; + if (FAILED(hr = ID3D11Device_CreateTexture3D(device, &texture_desc, NULL, (ID3D11Texture3D **)&rb_texture))) + { + trace("Failed to create texture, hr %#lx.\n", hr); + ID3D11Device_Release(device); + return; + } + + miplevel = sub_resource_idx % texture_desc.MipLevels; + init_resource_readback((ID3D11Resource *)texture, rb_texture, + max(1, texture_desc.Width >> miplevel), + max(1, texture_desc.Height >> miplevel), + max(1, texture_desc.Depth >> miplevel), + sub_resource_idx, device, rb); + + ID3D11Device_Release(device); +} + +static void *get_readback_data(struct resource_readback *rb, uint32_t x, uint32_t y, uint32_t z, unsigned byte_width) +{ + return (BYTE *)rb->map_desc.pData + z * rb->map_desc.DepthPitch + y * rb->map_desc.RowPitch + x * byte_width; +} + +static uint32_t get_readback_u32(struct resource_readback *rb, uint32_t x, uint32_t y, uint32_t z) +{ + return *(DWORD *)get_readback_data(rb, x, y, z, sizeof(DWORD)); +} + +static void release_resource_readback(struct resource_readback *rb) +{ + ID3D11DeviceContext_Unmap(rb->immediate_context, rb->resource, rb->sub_resource_idx); + ID3D11Resource_Release(rb->resource); + ID3D11DeviceContext_Release(rb->immediate_context); +} + +#define check_readback_data_u32(a, b, c) check_readback_data_u32_(__LINE__, a, b, c) +static void check_readback_data_u32_(unsigned int line, struct resource_readback *rb, + const RECT *rect, uint32_t expected) +{ + unsigned int x = 0, y = 0; + BOOL all_match = FALSE; + RECT default_rect; + uint32_t got = 0; + + if (!rect) + { + SetRect(&default_rect, 0, 0, rb->width, rb->height); + rect = &default_rect; + } + + for (y = rect->top; y < rect->bottom; ++y) + { + for (x = rect->left; x < rect->right; ++x) + { + if ((got = get_readback_u32(rb, x, y, 0)) != expected) + goto done; + } + } + all_match = TRUE; + +done: + ok_(__FILE__, line)(all_match, + "Got 0x%08x, expected 0x%08x at (%u, %u), sub-resource %u.\n", + got, expected, x, y, rb->sub_resource_idx); +} + +#define check_texture_sub_resource_u32(a, b, c, d) check_texture_sub_resource_u32_(__LINE__, a, b, c, d) +static void check_texture_sub_resource_u32_(uint32_t line, ID3D11Texture2D *texture, + uint32_t sub_resource_idx, const RECT *rect, uint32_t expected) +{ + struct resource_readback rb; + + get_texture_readback(texture, sub_resource_idx, &rb); + check_readback_data_u32_(line, &rb, rect, expected); + release_resource_readback(&rb); +} + +#define check_test_image_load_info_resource(resource, image_load_info) \ + check_test_image_load_info_resource_(__LINE__, resource, image_load_info) +static void check_test_image_load_info_resource_(uint32_t line, ID3D11Resource *resource, + const struct test_image_load_info *image_load_info) +{ + D3D11_RESOURCE_DIMENSION resource_dimension; + HRESULT hr; + + ID3D11Resource_GetType(resource, &resource_dimension); + ok(resource_dimension == image_load_info->expected_type, "Got unexpected ResourceDimension %u, expected %u.\n", + resource_dimension, image_load_info->expected_type); + switch (resource_dimension) + { + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + { + const D3D11_TEXTURE2D_DESC *expected_desc_2d = &image_load_info->expected_resource_desc.desc_2d; + D3D11_TEXTURE2D_DESC desc_2d; + ID3D11Texture2D *tex_2d; + + hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&tex_2d); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ID3D11Texture2D_GetDesc(tex_2d, &desc_2d); + check_texture2d_desc_(line, &desc_2d, expected_desc_2d, image_load_info->todo_resource_desc); + ID3D11Texture2D_Release(tex_2d); + break; + } + + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + { + const D3D11_TEXTURE3D_DESC *expected_desc_3d = &image_load_info->expected_resource_desc.desc_3d; + D3D11_TEXTURE3D_DESC desc_3d; + ID3D11Texture3D *tex_3d; + + hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture3D, (void **)&tex_3d); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ID3D11Texture3D_GetDesc(tex_3d, &desc_3d); + check_texture3d_desc_(line, &desc_3d, expected_desc_3d, image_load_info->todo_resource_desc); + ID3D11Texture3D_Release(tex_3d); + break; + } + + default: + break; + } +} + +static void check_resource_info(ID3D11Resource *resource, const struct test_image *image, unsigned int line) +{ + unsigned int expected_mip_levels, expected_width, expected_height, max_dimension; + D3D11_RESOURCE_DIMENSION resource_dimension; + D3D11_TEXTURE2D_DESC desc_2d; + D3D11_TEXTURE3D_DESC desc_3d; + ID3D11Texture2D *texture_2d; + ID3D11Texture3D *texture_3d; + HRESULT hr; + + expected_width = image->expected_info.Width; + expected_height = image->expected_info.Height; + if (is_block_compressed(image->expected_info.Format)) + { + expected_width = (expected_width + 3) & ~3; + expected_height = (expected_height + 3) & ~3; + } + expected_mip_levels = 0; + max_dimension = max(expected_width, expected_height); + while (max_dimension) + { + ++expected_mip_levels; + max_dimension >>= 1; + } + + ID3D11Resource_GetType(resource, &resource_dimension); + ok(resource_dimension == image->expected_info.ResourceDimension, + "Got unexpected ResourceDimension %u, expected %u.\n", + resource_dimension, image->expected_info.ResourceDimension); + + switch (resource_dimension) + { + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture_2d); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ID3D11Texture2D_GetDesc(texture_2d, &desc_2d); + ok_(__FILE__, line)(desc_2d.Width == expected_width, + "Got unexpected Width %u, expected %u.\n", + desc_2d.Width, expected_width); + ok_(__FILE__, line)(desc_2d.Height == expected_height, + "Got unexpected Height %u, expected %u.\n", + desc_2d.Height, expected_height); + ok_(__FILE__, line)(desc_2d.MipLevels == expected_mip_levels, + "Got unexpected MipLevels %u, expected %u.\n", + desc_2d.MipLevels, expected_mip_levels); + ok_(__FILE__, line)(desc_2d.ArraySize == image->expected_info.ArraySize, + "Got unexpected ArraySize %u, expected %u.\n", + desc_2d.ArraySize, image->expected_info.ArraySize); + ok_(__FILE__, line)(desc_2d.Format == image->expected_info.Format, + "Got unexpected Format %u, expected %u.\n", + desc_2d.Format, image->expected_info.Format); + ok_(__FILE__, line)(desc_2d.SampleDesc.Count == 1, + "Got unexpected SampleDesc.Count %u, expected %u\n", + desc_2d.SampleDesc.Count, 1); + ok_(__FILE__, line)(desc_2d.SampleDesc.Quality == 0, + "Got unexpected SampleDesc.Quality %u, expected %u\n", + desc_2d.SampleDesc.Quality, 0); + ok_(__FILE__, line)(desc_2d.Usage == D3D11_USAGE_DEFAULT, + "Got unexpected Usage %u, expected %u\n", + desc_2d.Usage, D3D11_USAGE_DEFAULT); + ok_(__FILE__, line)(desc_2d.BindFlags == D3D11_BIND_SHADER_RESOURCE, + "Got unexpected BindFlags %#x, expected %#x\n", + desc_2d.BindFlags, D3D11_BIND_SHADER_RESOURCE); + ok_(__FILE__, line)(desc_2d.CPUAccessFlags == 0, + "Got unexpected CPUAccessFlags %#x, expected %#x\n", + desc_2d.CPUAccessFlags, 0); + ok_(__FILE__, line)(desc_2d.MiscFlags == image->expected_info.MiscFlags, + "Got unexpected MiscFlags %#x, expected %#x.\n", + desc_2d.MiscFlags, image->expected_info.MiscFlags); + + ID3D11Texture2D_Release(texture_2d); + break; + + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture3D, (void **)&texture_3d); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ID3D11Texture3D_GetDesc(texture_3d, &desc_3d); + ok_(__FILE__, line)(desc_3d.Width == expected_width, + "Got unexpected Width %u, expected %u.\n", + desc_3d.Width, expected_width); + ok_(__FILE__, line)(desc_3d.Height == expected_height, + "Got unexpected Height %u, expected %u.\n", + desc_3d.Height, expected_height); + ok_(__FILE__, line)(desc_3d.Depth == image->expected_info.Depth, + "Got unexpected Depth %u, expected %u.\n", + desc_3d.Depth, image->expected_info.Depth); + ok_(__FILE__, line)(desc_3d.MipLevels == expected_mip_levels, + "Got unexpected MipLevels %u, expected %u.\n", + desc_3d.MipLevels, expected_mip_levels); + ok_(__FILE__, line)(desc_3d.Format == image->expected_info.Format, + "Got unexpected Format %u, expected %u.\n", + desc_3d.Format, image->expected_info.Format); + ok_(__FILE__, line)(desc_3d.Usage == D3D11_USAGE_DEFAULT, + "Got unexpected Usage %u, expected %u\n", + desc_3d.Usage, D3D11_USAGE_DEFAULT); + ok_(__FILE__, line)(desc_3d.BindFlags == D3D11_BIND_SHADER_RESOURCE, + "Got unexpected BindFlags %#x, expected %#x\n", + desc_3d.BindFlags, D3D11_BIND_SHADER_RESOURCE); + ok_(__FILE__, line)(desc_3d.CPUAccessFlags == 0, + "Got unexpected CPUAccessFlags %#x, expected %#x\n", + desc_3d.CPUAccessFlags, 0); + ok_(__FILE__, line)(desc_3d.MiscFlags == image->expected_info.MiscFlags, + "Got unexpected MiscFlags %#x, expected %#x.\n", + desc_3d.MiscFlags, image->expected_info.MiscFlags); + ID3D11Texture3D_Release(texture_3d); + break; + + default: + break; + } +} + +static void check_texture2d_data(ID3D11Texture2D *texture, const struct test_image *image, unsigned int line) +{ + unsigned int width, height, stride, i, array_slice, bpp; + struct resource_readback rb; + D3D11_TEXTURE2D_DESC desc; + const BYTE *expected_data; + BOOL line_match; + + ID3D11Texture2D_GetDesc(texture, &desc); + width = desc.Width; + height = desc.Height; + bpp = get_bpp_from_format(desc.Format); + stride = (width * bpp + 7) / 8; + if (is_block_compressed(desc.Format)) + { + stride *= 4; + height /= 4; + } + + expected_data = image->expected_data; + for (array_slice = 0; array_slice < desc.ArraySize; ++array_slice) + { + get_texture_readback(texture, array_slice * desc.MipLevels, &rb); + ok_(__FILE__, line)(!!rb.resource, "Failed to create texture readback.\n"); + if (!rb.resource) + return; + + for (i = 0; i < height; ++i) + { + line_match = !memcmp(expected_data + stride * i, get_readback_data(&rb, 0, i, 0, bpp), stride); + todo_wine_if(is_block_compressed(image->expected_info.Format) && image->data != test_dds_dxt5 + && (image->expected_info.Width % 4 != 0 || image->expected_info.Height % 4 != 0)) + ok_(__FILE__, line)(line_match, "Data mismatch for line %u, array slice %u.\n", i, array_slice); + if (!line_match) + break; + } + expected_data += stride * height; + + release_resource_readback(&rb); + } +} + +static void check_texture3d_data(ID3D11Texture3D *texture, const struct test_image *image, unsigned int line) { - const D3DX11_IMAGE_INFO expected_info = { width, height, depth, array_size, mip_levels, misc_flags, format, - resource_dimension, image_file_format }; - BOOL matched; + unsigned int width, height, depth, stride, i, bpp; + struct resource_readback rb; + D3D11_TEXTURE3D_DESC desc; + const BYTE *expected_data; + BOOL line_match; + + ID3D11Texture3D_GetDesc(texture, &desc); + width = desc.Width; + height = desc.Height; + depth = desc.Depth; + bpp = get_bpp_from_format(desc.Format); + stride = (width * bpp + 7) / 8; + if (is_block_compressed(desc.Format)) + { + stride *= 4; + height /= 4; + }
- matched = !memcmp(&expected_info, info, sizeof(*info)); - todo_wine_if(wine_todo) ok_(__FILE__, line)(matched, "Got unexpected image info values.\n"); - if (matched) + expected_data = image->expected_data; + get_texture3d_readback(texture, 0, &rb); + ok_(__FILE__, line)(!!rb.resource, "Failed to create texture readback.\n"); + if (!rb.resource) return;
- todo_wine_if(wine_todo && info->Width != width) - ok_(__FILE__, line)(info->Width == width, "Expected width %u, got %u.\n", width, info->Width); - todo_wine_if(wine_todo && info->Height != height) - ok_(__FILE__, line)(info->Height == height, "Expected height %u, got %u.\n", height, info->Height); - todo_wine_if(wine_todo && info->Depth != depth) - ok_(__FILE__, line)(info->Depth == depth, "Expected depth %u, got %u.\n", depth, info->Depth); - todo_wine_if(wine_todo && info->ArraySize != array_size) - ok_(__FILE__, line)(info->ArraySize == array_size, "Expected array_size %u, got %u.\n", array_size, - info->ArraySize); - todo_wine_if(wine_todo && info->MipLevels != mip_levels) - ok_(__FILE__, line)(info->MipLevels == mip_levels, "Expected mip_levels %u, got %u.\n", mip_levels, - info->MipLevels); - todo_wine_if(wine_todo && info->MiscFlags != misc_flags) - ok_(__FILE__, line)(info->MiscFlags == misc_flags, "Expected misc_flags %u, got %u.\n", misc_flags, - info->MiscFlags); - ok_(__FILE__, line)(info->Format == format, "Expected texture format %d, got %d.\n", format, info->Format); - todo_wine_if(wine_todo && info->ResourceDimension != resource_dimension) - ok_(__FILE__, line)(info->ResourceDimension == resource_dimension, "Expected resource_dimension %d, got %d.\n", - resource_dimension, info->ResourceDimension); - ok_(__FILE__, line)(info->ImageFileFormat == image_file_format, "Expected image_file_format %d, got %d.\n", - image_file_format, info->ImageFileFormat); + for (i = 0; i < height * depth; ++i) + { + line_match = !memcmp(expected_data + stride * i, get_readback_data(&rb, 0, i, 0, bpp), stride); + ok_(__FILE__, line)(line_match, "Data mismatch for line %u.\n", i); + if (!line_match) + { + for (unsigned int j = 0; j < stride; ++j) + trace("%02x\n", *((BYTE *)get_readback_data(&rb, j, i, 0, 1))); + break; + } + } + + release_resource_readback(&rb); +} + +static void check_resource_data(ID3D11Resource *resource, const struct test_image *image, unsigned int line) +{ + ID3D11Texture3D *texture3d; + ID3D11Texture2D *texture2d; + + if (SUCCEEDED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture3D, (void **)&texture3d))) + { + if (wined3d_opengl && is_block_compressed(image->expected_info.Format)) + skip("Skipping compressed format 3D texture readback test.\n"); + else + check_texture3d_data(texture3d, image, line); + ID3D11Texture3D_Release(texture3d); + } + else if (SUCCEEDED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture2d))) + { + check_texture2d_data(texture2d, image, line); + ID3D11Texture2D_Release(texture2d); + } + else + { + ok(0, "Failed to get 2D or 3D texture interface.\n"); + } }
static WCHAR temp_dir[MAX_PATH];
-static BOOL create_file(const WCHAR *filename, const char *data, unsigned int size, WCHAR *out_path) +static char *get_str_a(const WCHAR *wstr) +{ + static char buffer[MAX_PATH]; + + WideCharToMultiByte(CP_ACP, 0, wstr, -1, buffer, sizeof(buffer), NULL, NULL); + return buffer; +} + +static BOOL create_file(const WCHAR *filename, const void *data, unsigned int size, WCHAR *out_path) { WCHAR path[MAX_PATH]; DWORD written; @@ -482,6 +2061,102 @@ static void delete_directory(const WCHAR *dir) RemoveDirectoryW(path); }
+static HMODULE create_resource_module(const WCHAR *filename, const void *data, unsigned int size) +{ + WCHAR resource_module_path[MAX_PATH], current_module_path[MAX_PATH]; + HANDLE resource; + HMODULE module; + BOOL ret; + + if (!temp_dir[0]) + GetTempPathW(ARRAY_SIZE(temp_dir), temp_dir); + lstrcpyW(resource_module_path, temp_dir); + lstrcatW(resource_module_path, filename); + + GetModuleFileNameW(NULL, current_module_path, ARRAY_SIZE(current_module_path)); + ret = CopyFileW(current_module_path, resource_module_path, FALSE); + ok(ret, "CopyFileW failed, error %lu.\n", GetLastError()); + SetFileAttributesW(resource_module_path, FILE_ATTRIBUTE_NORMAL); + + resource = BeginUpdateResourceW(resource_module_path, TRUE); + UpdateResourceW(resource, (LPCWSTR)RT_RCDATA, filename, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), (void *)data, size); + EndUpdateResourceW(resource, FALSE); + + module = LoadLibraryExW(resource_module_path, NULL, LOAD_LIBRARY_AS_DATAFILE); + + return module; +} + +static void delete_resource_module(const WCHAR *filename, HMODULE module) +{ + WCHAR path[MAX_PATH]; + + FreeLibrary(module); + + lstrcpyW(path, temp_dir); + lstrcatW(path, filename); + DeleteFileW(path); +} + +static ID3D11Device *create_device(void) +{ + HRESULT (WINAPI *pD3D11CreateDevice)(IDXGIAdapter *, D3D_DRIVER_TYPE, HMODULE, UINT, const D3D_FEATURE_LEVEL *, + UINT, UINT, ID3D11Device **, D3D_FEATURE_LEVEL *, ID3D11DeviceContext **); + HMODULE d3d11_mod = LoadLibraryA("d3d11.dll"); + ID3D11Device *device; + + + if (!d3d11_mod) + { + win_skip("d3d11.dll not present\n"); + return NULL; + } + + pD3D11CreateDevice = (void *)GetProcAddress(d3d11_mod, "D3D11CreateDevice"); + if (SUCCEEDED(pD3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, + NULL, 0, D3D11_SDK_VERSION, &device, NULL, NULL))) + return device; + if (SUCCEEDED(pD3D11CreateDevice(NULL, D3D_DRIVER_TYPE_WARP, NULL, 0, + NULL, 0, D3D11_SDK_VERSION, &device, NULL, NULL))) + return device; + if (SUCCEEDED(pD3D11CreateDevice(NULL, D3D_DRIVER_TYPE_REFERENCE, NULL, 0, + NULL, 0, D3D11_SDK_VERSION, &device, NULL, NULL))) + return device; + + return NULL; +} + +static void check_image_info(D3DX11_IMAGE_INFO *image_info, const struct test_image *image, unsigned int line) +{ + ok_(__FILE__, line)(image_info->Width == image->expected_info.Width, + "Got unexpected Width %u, expected %u.\n", + image_info->Width, image->expected_info.Width); + ok_(__FILE__, line)(image_info->Height == image->expected_info.Height, + "Got unexpected Height %u, expected %u.\n", + image_info->Height, image->expected_info.Height); + ok_(__FILE__, line)(image_info->Depth == image->expected_info.Depth, + "Got unexpected Depth %u, expected %u.\n", + image_info->Depth, image->expected_info.Depth); + ok_(__FILE__, line)(image_info->ArraySize == image->expected_info.ArraySize, + "Got unexpected ArraySize %u, expected %u.\n", + image_info->ArraySize, image->expected_info.ArraySize); + ok_(__FILE__, line)(image_info->MipLevels == image->expected_info.MipLevels, + "Got unexpected MipLevels %u, expected %u.\n", + image_info->MipLevels, image->expected_info.MipLevels); + ok_(__FILE__, line)(image_info->MiscFlags == image->expected_info.MiscFlags, + "Got unexpected MiscFlags %#x, expected %#x.\n", + image_info->MiscFlags, image->expected_info.MiscFlags); + ok_(__FILE__, line)(image_info->Format == image->expected_info.Format, + "Got unexpected Format %#x, expected %#x.\n", + image_info->Format, image->expected_info.Format); + ok_(__FILE__, line)(image_info->ResourceDimension == image->expected_info.ResourceDimension, + "Got unexpected ResourceDimension %u, expected %u.\n", + image_info->ResourceDimension, image->expected_info.ResourceDimension); + ok_(__FILE__, line)(image_info->ImageFileFormat == image->expected_info.ImageFileFormat, + "Got unexpected ImageFileFormat %u, expected %u.\n", + image_info->ImageFileFormat, image->expected_info.ImageFileFormat); +} + static void test_D3DX11CreateAsyncMemoryLoader(void) { ID3DX11DataLoader *loader; @@ -1334,9 +3009,15 @@ static void test_dxt10_dds_header_image_info(void)
static void test_D3DX11GetImageInfoFromMemory(void) { + static const WCHAR test_resource_name[] = L"resource.data"; + static const WCHAR test_filename[] = L"image.data"; + HMODULE resource_module; D3DX11_IMAGE_INFO info; - HRESULT hr; + WCHAR path[MAX_PATH]; + unsigned int i; + HRESULT hr, hr2;
+ CoInitialize(NULL); hr = D3DX11GetImageInfoFromMemory(bmp_1bpp, sizeof(bmp_1bpp), NULL, &info, NULL); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
@@ -1544,10 +3225,625 @@ static void test_D3DX11GetImageInfoFromMemory(void) todo_wine check_dds_dxt10_format(DXGI_FORMAT_BC6H_UF16, DXGI_FORMAT_BC6H_UF16, FALSE); todo_wine check_dds_dxt10_format(DXGI_FORMAT_BC6H_SF16, DXGI_FORMAT_BC6H_SF16, FALSE); todo_wine check_dds_dxt10_format(DXGI_FORMAT_BC7_UNORM, DXGI_FORMAT_BC7_UNORM, FALSE); + + for (i = 0; i < ARRAY_SIZE(test_image); ++i) + { + winetest_push_context("Test %u", i); + + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromMemory(test_image[i].data, test_image[i].size, NULL, &info, &hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + if (hr == S_OK) + check_image_info(&info, test_image + i, __LINE__); + + winetest_pop_context(); + } + + if (!strcmp(winetest_platform, "wine")) + { + skip("Skipping D3DX11GetImageInfoFrom{File,Resource} tests.\n"); + CoUninitialize(); + return; + } + + /* D3DX11GetImageInfoFromFile{A,W} tests. */ + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromFileW(NULL, NULL, &info, &hr2); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromFileW(L"deadbeaf", NULL, &info, &hr2); + ok(hr == D3D11_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromFileA(NULL, NULL, &info, &hr2); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromFileA("deadbeaf", NULL, &info, &hr2); + ok(hr == D3D11_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + + for (i = 0; i < ARRAY_SIZE(test_image); ++i) + { + winetest_push_context("Test %u", i); + create_file(test_filename, test_image[i].data, test_image[i].size, path); + + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromFileW(path, NULL, &info, &hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + if (hr == S_OK) + check_image_info(&info, test_image + i, __LINE__); + + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromFileA(get_str_a(path), NULL, &info, &hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + if (hr == S_OK) + check_image_info(&info, test_image + i, __LINE__); + + delete_file(test_filename); + winetest_pop_context(); + } + + /* D3DX11GetImageInfoFromResource{A,W} tests. */ + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromResourceW(NULL, NULL, NULL, &info, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromResourceW(NULL, L"deadbeaf", NULL, &info, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromResourceA(NULL, NULL, NULL, &info, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromResourceA(NULL, "deadbeaf", NULL, &info, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + + for (i = 0; i < ARRAY_SIZE(test_image); ++i) + { + winetest_push_context("Test %u", i); + resource_module = create_resource_module(test_resource_name, test_image[i].data, test_image[i].size); + + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromResourceW(resource_module, L"deadbeef", NULL, &info, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromResourceW(resource_module, test_resource_name, NULL, &info, &hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + if (hr == S_OK) + check_image_info(&info, test_image + i, __LINE__); + + hr2 = 0xdeadbeef; + hr = D3DX11GetImageInfoFromResourceA(resource_module, get_str_a(test_resource_name), NULL, &info, &hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + if (hr == S_OK) + check_image_info(&info, test_image + i, __LINE__); + + delete_resource_module(test_resource_name, resource_module); + winetest_pop_context(); + } + + CoUninitialize(); +} + +static void test_create_texture(void) +{ + static const uint32_t dds_24bit_8_8_mip_level_expected[] = { 0xff0000ff, 0xff00ff00, 0xffff0000, 0xff000000 }; + static const WCHAR test_resource_name[] = L"resource.data"; + static const WCHAR test_filename[] = L"image.data"; + D3D11_TEXTURE2D_DESC tex_2d_desc; + D3DX11_IMAGE_LOAD_INFO load_info; + D3DX11_IMAGE_INFO img_info; + unsigned int i, mip_level; + ID3D11Resource *resource; + ID3D11Texture2D *tex_2d; + HMODULE resource_module; + ID3D11Device *device; + WCHAR path[MAX_PATH]; + HRESULT hr, hr2; + + if (!strcmp(winetest_platform, "wine")) + { + skip("Skipping texture creation tests.\n"); + return; + } + + device = create_device(); + if (!device) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + CoInitialize(NULL); + + /* D3DX11CreateTextureFromMemory tests */ + + resource = (ID3D11Resource *)0xdeadbeef; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(NULL, bmp_1bpp, sizeof(bmp_1bpp), NULL, NULL, &resource, &hr2); + ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + ok(resource == (ID3D11Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource); + + resource = (ID3D11Resource *)0xdeadbeef; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, NULL, 0, NULL, NULL, &resource, &hr2); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + ok(resource == (ID3D11Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource); + + resource = (ID3D11Resource *)0xdeadbeef; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, NULL, sizeof(bmp_1bpp), NULL, NULL, &resource, &hr2); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + ok(resource == (ID3D11Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource); + + resource = (ID3D11Resource *)0xdeadbeef; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, bmp_1bpp, 0, NULL, NULL, &resource, &hr2); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(resource == (ID3D11Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource); + + resource = (ID3D11Resource *)0xdeadbeef; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, bmp_1bpp, sizeof(bmp_1bpp) - 1, NULL, NULL, &resource, &hr2); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(resource == (ID3D11Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource); + + for (i = 0; i < ARRAY_SIZE(test_image); ++i) + { + winetest_push_context("Test %u", i); + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, test_image[i].data, test_image[i].size, NULL, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + if (hr == S_OK) + { + check_resource_info(resource, test_image + i, __LINE__); + check_resource_data(resource, test_image + i, __LINE__); + ID3D11Resource_Release(resource); + } + + /* Test behavior with load_info structure values set to defaults. */ + load_info = d3dx11_default_load_info; + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, test_image[i].data, test_image[i].size, &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + if (hr == S_OK) + { + check_resource_info(resource, test_image + i, __LINE__); + check_resource_data(resource, test_image + i, __LINE__); + ID3D11Resource_Release(resource); + } + + /* Check that passed in D3DX11_IMAGE_INFO structure is filled. */ + memset(&img_info, 0, sizeof(img_info)); + load_info = d3dx11_default_load_info; + load_info.pSrcInfo = &img_info; + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, test_image[i].data, test_image[i].size, &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + if (hr == S_OK) + { + check_resource_info(resource, test_image + i, __LINE__); + check_resource_data(resource, test_image + i, __LINE__); + ok(!memcmp(&test_image[i].expected_info, &img_info, sizeof(img_info)), "Unexpected image info.\n"); + ID3D11Resource_Release(resource); + } + + winetest_pop_context(); + } + + for (i = 0; i < ARRAY_SIZE(test_invalid_image_load_info); ++i) + { + const struct test_invalid_image_load_info *test = &test_invalid_image_load_info[i]; + + winetest_push_context("Test %u", i); + + hr2 = 0xdeadbeef; + load_info = test->load_info; + hr = D3DX11CreateTextureFromMemory(device, test->data, test->size, &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + todo_wine_if(test->todo_hr) ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + ID3D11Resource_Release(resource); + + winetest_pop_context(); + } + + for (i = 0; i < ARRAY_SIZE(test_image_load_info); ++i) + { + const struct test_image_load_info *test = &test_image_load_info[i]; + + winetest_push_context("Test %u", i); + + load_info = test->load_info; + resource = NULL; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, test->data, test->size, &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_test_image_load_info_resource(resource, test); + ID3D11Resource_Release(resource); + } + + winetest_pop_context(); + } + + /* + * Test behavior of the FirstMipLevel argument, including checks of the + * values loaded into each level of the created texture. + */ + for (i = 0; i < 2; ++i) + { + winetest_push_context("FirstMipLevel %u", i); + memset(&img_info, 0, sizeof(img_info)); + load_info = d3dx11_default_load_info; + load_info.FirstMipLevel = i; + load_info.MipLevels = D3DX11_FROM_FILE; + load_info.pSrcInfo = &img_info; + + resource = NULL; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, dds_24bit_8_8, sizeof(dds_24bit_8_8), &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&tex_2d); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + /* + * The FirstMipLevel behavior does not exactly match D3DX_SKIP_DDS_MIP_LEVEL + * from d3dx9, image info values always represent mip level 0 regardless of + * what FirstMipLevel is set to. Further, texture dimensions are + * always based on mip level 0, and the number of mip levels is always the same + * as the number in the image info structure. + */ + ID3D11Texture2D_GetDesc(tex_2d, &tex_2d_desc); + check_texture2d_desc_values(&tex_2d_desc, 8, 8, 4, 1, DXGI_FORMAT_R8G8B8A8_UNORM, 1, 0, D3D11_USAGE_DEFAULT, + D3D11_BIND_SHADER_RESOURCE, 0, 0, FALSE); + check_image_info_values(&img_info, 8, 8, 1, 1, 4, 0, DXGI_FORMAT_R8G8B8A8_UNORM, + D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS, FALSE); + + /* + * Image data is loaded starting from the mip level provided by + * FirstMipLevel. This behavior does match d3dx9's D3DX_SKIP_DDS_MIP_LEVEL. + */ + for (mip_level = 0; mip_level < 4; ++mip_level) + { + winetest_push_context("MipLevel %u", mip_level); + check_texture_sub_resource_u32(tex_2d, mip_level, NULL, + dds_24bit_8_8_mip_level_expected[min(3, mip_level + i)]); + winetest_pop_context(); + } + + ID3D11Texture2D_Release(tex_2d); + ID3D11Resource_Release(resource); + winetest_pop_context(); + } + + /* + * If FirstMipLevel is set to a value that is larger than the total number + * of mip levels in the image, it falls back to 0. + */ + memset(&img_info, 0, sizeof(img_info)); + load_info = d3dx11_default_load_info; + load_info.FirstMipLevel = 5; + load_info.MipLevels = D3DX11_FROM_FILE; + load_info.pSrcInfo = &img_info; + + resource = NULL; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromMemory(device, dds_24bit_8_8, sizeof(dds_24bit_8_8), &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + check_image_info_values(&img_info, 8, 8, 1, 1, 4, 0, DXGI_FORMAT_R8G8B8A8_UNORM, + D3D11_RESOURCE_DIMENSION_TEXTURE2D, D3DX11_IFF_DDS, FALSE); + + hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&tex_2d); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ID3D11Texture2D_GetDesc(tex_2d, &tex_2d_desc); + check_texture2d_desc_values(&tex_2d_desc, 8, 8, 4, 1, DXGI_FORMAT_R8G8B8A8_UNORM, 1, 0, D3D11_USAGE_DEFAULT, + D3D11_BIND_SHADER_RESOURCE, 0, 0, FALSE); + for (mip_level = 0; mip_level < 4; ++mip_level) + { + winetest_push_context("MipLevel %u", mip_level); + check_texture_sub_resource_u32(tex_2d, mip_level, NULL, dds_24bit_8_8_mip_level_expected[mip_level]); + winetest_pop_context(); + } + + ID3D11Texture2D_Release(tex_2d); + ID3D11Resource_Release(resource); + + hr2 = 0xdeadbeef; + add_work_item_count = 0; + hr = D3DX11CreateTextureFromMemory(device, test_image[0].data, test_image[0].size, + NULL, &thread_pump, &resource, &hr2); + ok(add_work_item_count == 1, "Got unexpected add_work_item_count %u.\n", add_work_item_count); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + check_resource_info(resource, test_image, __LINE__); + check_resource_data(resource, test_image, __LINE__); + ID3D11Resource_Release(resource); + + /* D3DX11CreateTextureFromFile tests */ + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromFileW(device, NULL, NULL, NULL, &resource, &hr2); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromFileW(device, L"deadbeef", NULL, NULL, &resource, &hr2); + ok(hr == D3D11_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromFileA(device, NULL, NULL, NULL, &resource, &hr2); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromFileA(device, "deadbeef", NULL, NULL, &resource, &hr2); + ok(hr == D3D11_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + + for (i = 0; i < ARRAY_SIZE(test_image); ++i) + { + winetest_push_context("Test %u", i); + create_file(test_filename, test_image[i].data, test_image[i].size, path); + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromFileW(device, path, NULL, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + if (hr == S_OK) + { + check_resource_info(resource, test_image + i, __LINE__); + check_resource_data(resource, test_image + i, __LINE__); + ID3D11Resource_Release(resource); + } + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromFileA(device, get_str_a(path), NULL, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + if (hr == S_OK) + { + check_resource_info(resource, test_image + i, __LINE__); + check_resource_data(resource, test_image + i, __LINE__); + ID3D11Resource_Release(resource); + } + + delete_file(test_filename); + winetest_pop_context(); + } + + for (i = 0; i < ARRAY_SIZE(test_invalid_image_load_info); ++i) + { + const struct test_invalid_image_load_info *test = &test_invalid_image_load_info[i]; + + winetest_push_context("Test %u", i); + create_file(test_filename, test->data, test->size, path); + load_info = test->load_info; + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromFileW(device, path, &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + todo_wine_if(test->todo_hr) ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + ID3D11Resource_Release(resource); + + hr = D3DX11CreateTextureFromFileA(device, get_str_a(path), &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + todo_wine_if(test->todo_hr) ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + ID3D11Resource_Release(resource); + + delete_file(test_filename); + winetest_pop_context(); + } + + for (i = 0; i < ARRAY_SIZE(test_image_load_info); ++i) + { + const struct test_image_load_info *test = &test_image_load_info[i]; + + winetest_push_context("Test %u", i); + create_file(test_filename, test->data, test->size, path); + load_info = test->load_info; + + resource = NULL; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromFileW(device, path, &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_test_image_load_info_resource(resource, test); + ID3D11Resource_Release(resource); + } + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromFileA(device, get_str_a(path), &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_test_image_load_info_resource(resource, test); + ID3D11Resource_Release(resource); + } + + delete_file(test_filename); + winetest_pop_context(); + } + + /* D3DX11CreateTextureFromResource tests */ + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceW(device, NULL, NULL, NULL, NULL, &resource, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceW(device, NULL, L"deadbeef", NULL, NULL, &resource, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceA(device, NULL, NULL, NULL, NULL, &resource, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceA(device, NULL, "deadbeef", NULL, NULL, &resource, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + + for (i = 0; i < ARRAY_SIZE(test_image); ++i) + { + winetest_push_context("Test %u", i); + resource_module = create_resource_module(test_resource_name, test_image[i].data, test_image[i].size); + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceW(device, resource_module, L"deadbeef", NULL, NULL, &resource, &hr2); + ok(hr == D3DX11_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(hr2 == 0xdeadbeef, "Got unexpected hr2 %#lx.\n", hr2); + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceW(device, resource_module, + test_resource_name, NULL, NULL, &resource, &hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + if (hr == S_OK) + { + check_resource_info(resource, test_image + i, __LINE__); + check_resource_data(resource, test_image + i, __LINE__); + ID3D11Resource_Release(resource); + } + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceA(device, resource_module, + get_str_a(test_resource_name), NULL, NULL, &resource, &hr2); + ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX11_IFF_WMP), + "Got unexpected hr %#lx.\n", hr); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + if (hr == S_OK) + { + check_resource_info(resource, test_image + i, __LINE__); + check_resource_data(resource, test_image + i, __LINE__); + ID3D11Resource_Release(resource); + } + + delete_resource_module(test_resource_name, resource_module); + winetest_pop_context(); + } + + for (i = 0; i < ARRAY_SIZE(test_invalid_image_load_info); ++i) + { + const struct test_invalid_image_load_info *test = &test_invalid_image_load_info[i]; + + winetest_push_context("Test %u", i); + resource_module = create_resource_module(test_resource_name, test->data, test->size); + load_info = test->load_info; + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceW(device, resource_module, + test_resource_name, &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + todo_wine_if(test->todo_hr) ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + ID3D11Resource_Release(resource); + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceA(device, resource_module, + get_str_a(test_resource_name), &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + todo_wine_if(test->todo_hr) ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + ID3D11Resource_Release(resource); + + delete_resource_module(test_resource_name, resource_module); + winetest_pop_context(); + } + + for (i = 0; i < ARRAY_SIZE(test_image_load_info); ++i) + { + const struct test_image_load_info *test = &test_image_load_info[i]; + + winetest_push_context("Test %u", i); + resource_module = create_resource_module(test_resource_name, test->data, test->size); + load_info = test->load_info; + + resource = NULL; + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceW(device, resource_module, + test_resource_name, &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_test_image_load_info_resource(resource, test); + ID3D11Resource_Release(resource); + } + + hr2 = 0xdeadbeef; + hr = D3DX11CreateTextureFromResourceA(device, resource_module, + get_str_a(test_resource_name), &load_info, NULL, &resource, &hr2); + ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); + ok(hr == test->expected_hr, "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_test_image_load_info_resource(resource, test); + ID3D11Resource_Release(resource); + } + + delete_resource_module(test_resource_name, resource_module); + winetest_pop_context(); + } + + CoUninitialize(); + + ok(!ID3D11Device_Release(device), "Unexpected refcount.\n"); }
START_TEST(d3dx11) { + HMODULE wined3d; + + if ((wined3d = GetModuleHandleA("wined3d.dll"))) + { + enum wined3d_renderer (CDECL *p_wined3d_get_renderer)(void); + + if ((p_wined3d_get_renderer = (void *)GetProcAddress(wined3d, "wined3d_get_renderer")) + && p_wined3d_get_renderer() == WINED3D_RENDERER_OPENGL) + wined3d_opengl = true; + } + test_D3DX11CreateAsyncMemoryLoader(); test_D3DX11CreateAsyncFileLoader(); test_D3DX11CreateAsyncResourceLoader(); @@ -1555,4 +3851,5 @@ START_TEST(d3dx11) test_D3DX11GetImageInfoFromMemory(); test_legacy_dds_header_image_info(); test_dxt10_dds_header_image_info(); + test_create_texture(); }
From: Connor McAdams cmcadams@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45533 Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx11_43/tests/d3dx11.c | 16 +- dlls/d3dx11_43/texture.c | 293 +++++++++++++++++++++++++++++++++- 2 files changed, 300 insertions(+), 9 deletions(-)
diff --git a/dlls/d3dx11_43/tests/d3dx11.c b/dlls/d3dx11_43/tests/d3dx11.c index 1e4f0312ae9..1f71f6cfce1 100644 --- a/dlls/d3dx11_43/tests/d3dx11.c +++ b/dlls/d3dx11_43/tests/d3dx11.c @@ -3358,12 +3358,6 @@ static void test_create_texture(void) WCHAR path[MAX_PATH]; HRESULT hr, hr2;
- if (!strcmp(winetest_platform, "wine")) - { - skip("Skipping texture creation tests.\n"); - return; - } - device = create_device(); if (!device) { @@ -3589,13 +3583,21 @@ static void test_create_texture(void) add_work_item_count = 0; hr = D3DX11CreateTextureFromMemory(device, test_image[0].data, test_image[0].size, NULL, &thread_pump, &resource, &hr2); - ok(add_work_item_count == 1, "Got unexpected add_work_item_count %u.\n", add_work_item_count); + todo_wine ok(add_work_item_count == 1, "Got unexpected add_work_item_count %u.\n", add_work_item_count); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == hr2, "Got unexpected hr2 %#lx.\n", hr2); check_resource_info(resource, test_image, __LINE__); check_resource_data(resource, test_image, __LINE__); ID3D11Resource_Release(resource);
+ if (!strcmp(winetest_platform, "wine")) + { + skip("Skipping D3DX11CreateTextureFrom{File,Resource} tests.\n"); + CoUninitialize(); + ok(!ID3D11Device_Release(device), "Unexpected refcount.\n"); + return; + } + /* D3DX11CreateTextureFromFile tests */ hr2 = 0xdeadbeef; hr = D3DX11CreateTextureFromFileW(device, NULL, NULL, NULL, &resource, &hr2); diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c index 81380b1aecc..2ba850ba12a 100644 --- a/dlls/d3dx11_43/texture.c +++ b/dlls/d3dx11_43/texture.c @@ -16,9 +16,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define COBJMACROS + #include "d3dx11.h" #include "d3dcompiler.h" #include "dxhelpers.h" +#include "assert.h"
#include "wine/debug.h"
@@ -248,6 +251,279 @@ HRESULT get_image_info(const void *data, SIZE_T size, D3DX11_IMAGE_INFO *img_inf return S_OK; }
+static void init_load_info(const D3DX11_IMAGE_LOAD_INFO *load_info, D3DX11_IMAGE_LOAD_INFO *out) +{ + if (load_info) + { + *out = *load_info; + return; + } + + out->Width = D3DX11_DEFAULT; + out->Height = D3DX11_DEFAULT; + out->Depth = D3DX11_DEFAULT; + out->FirstMipLevel = D3DX11_DEFAULT; + out->MipLevels = D3DX11_DEFAULT; + out->Usage = D3DX11_DEFAULT; + out->BindFlags = D3DX11_DEFAULT; + out->CpuAccessFlags = D3DX11_DEFAULT; + out->MiscFlags = D3DX11_DEFAULT; + out->Format = D3DX11_DEFAULT; + out->Filter = D3DX11_DEFAULT; + out->MipFilter = D3DX11_DEFAULT; + out->pSrcInfo = NULL; +} + +HRESULT load_texture_data(const void *data, SIZE_T size, D3DX11_IMAGE_LOAD_INFO *load_info, + D3D11_SUBRESOURCE_DATA **resource_data) +{ + uint32_t loaded_mip_level_count, max_mip_level_count; + const struct pixel_format_desc *fmt_desc, *src_desc; + struct d3dx_subresource_data *sub_rsrcs = NULL; + D3DX11_IMAGE_INFO img_info; + struct d3dx_image image; + unsigned int i, j; + HRESULT hr = S_OK; + + if (!data || !size) + return E_FAIL; + + *resource_data = NULL; + if (!load_info->Filter || load_info->Filter == D3DX11_DEFAULT) + load_info->Filter = D3DX11_FILTER_LINEAR; + if (FAILED(hr = d3dx_validate_filter(load_info->Filter))) + { + ERR("Invalid filter argument %#x.\n", load_info->Filter); + return hr; + } + + hr = d3dx_image_init(data, size, &image, 0, D3DX_IMAGE_SUPPORT_DXT10); + if (FAILED(hr)) + return E_FAIL; + + hr = d3dx11_image_info_from_d3dx_image(&img_info, &image); + if (FAILED(hr)) + { + WARN("Invalid or unsupported image file, hr %#lx.\n", hr); + hr = E_FAIL; + goto end; + } + + if ((!(img_info.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE) || img_info.ArraySize != 6) + && img_info.ArraySize != 1) + { + FIXME("img_info.ArraySize = %u not supported.\n", img_info.ArraySize); + hr = E_NOTIMPL; + goto end; + } + + if (load_info->FirstMipLevel == D3DX11_DEFAULT || load_info->FirstMipLevel >= img_info.MipLevels) + load_info->FirstMipLevel = 0; + + if (load_info->Format == D3DX11_DEFAULT || load_info->Format == DXGI_FORMAT_FROM_FILE) + load_info->Format = img_info.Format; + fmt_desc = get_d3dx_pixel_format_info(d3dx_pixel_format_id_from_dxgi_format(load_info->Format)); + if (fmt_desc->format == D3DX_PIXEL_FORMAT_COUNT) + { + FIXME("Unknown DXGI format supplied, %#x.\n", load_info->Format); + hr = E_NOTIMPL; + goto end; + } + + /* Potentially round up width/height to align with block size. */ + if (!load_info->Width || load_info->Width == D3DX11_FROM_FILE || load_info->Width == D3DX11_DEFAULT) + load_info->Width = (img_info.Width + fmt_desc->block_width - 1) & ~(fmt_desc->block_width - 1); + if (!load_info->Height || load_info->Height == D3DX11_FROM_FILE || load_info->Height == D3DX11_DEFAULT) + load_info->Height = (img_info.Height + fmt_desc->block_height - 1) & ~(fmt_desc->block_height - 1); + if (!load_info->Depth || load_info->Depth == D3DX11_FROM_FILE || load_info->Depth == D3DX11_DEFAULT) + load_info->Depth = img_info.Depth; + + if ((load_info->Depth > 1) && (img_info.ResourceDimension != D3D11_RESOURCE_DIMENSION_TEXTURE3D)) + { + WARN("Invalid depth value %u for image with dimension %d.\n", load_info->Depth, img_info.ResourceDimension); + hr = E_FAIL; + goto end; + } + + max_mip_level_count = d3dx_get_max_mip_levels_for_size(load_info->Width, load_info->Height, load_info->Depth); + if (!load_info->MipLevels || load_info->MipLevels == D3DX11_DEFAULT || load_info->MipLevels == D3DX11_FROM_FILE) + load_info->MipLevels = (load_info->MipLevels == D3DX11_FROM_FILE) ? img_info.MipLevels : max_mip_level_count; + load_info->MipLevels = min(max_mip_level_count, load_info->MipLevels); + + hr = d3dx_create_subresource_data_for_texture(load_info->Width, load_info->Height, load_info->Depth, + load_info->MipLevels, img_info.ArraySize, fmt_desc, &sub_rsrcs); + if (FAILED(hr)) + goto end; + + src_desc = get_d3dx_pixel_format_info(image.format); + loaded_mip_level_count = min(img_info.MipLevels - load_info->FirstMipLevel, load_info->MipLevels); + for (i = 0; i < img_info.ArraySize; ++i) + { + struct volume dst_size = { load_info->Width, load_info->Height, load_info->Depth }; + + for (j = 0; j < loaded_mip_level_count; ++j) + { + struct d3dx_subresource_data *sub_rsrc = &sub_rsrcs[i * load_info->MipLevels + j]; + const RECT unaligned_rect = { 0, 0, dst_size.width, dst_size.height }; + struct d3dx_pixels src_pixels, dst_pixels; + + hr = d3dx_image_get_pixels(&image, i, j + load_info->FirstMipLevel, &src_pixels); + if (FAILED(hr)) + goto end; + + set_d3dx_pixels(&dst_pixels, sub_rsrc->data, sub_rsrc->row_pitch, sub_rsrc->slice_pitch, NULL, dst_size.width, + dst_size.height, dst_size.depth, &unaligned_rect); + + hr = d3dx_load_pixels_from_pixels(&dst_pixels, fmt_desc, &src_pixels, src_desc, load_info->Filter, 0); + if (FAILED(hr)) + goto end; + + d3dx_get_next_mip_level_size(&dst_size); + } + } + + if (loaded_mip_level_count < load_info->MipLevels) + { + struct volume base_level_size = { load_info->Width, load_info->Height, load_info->Depth }; + const uint32_t base_level = loaded_mip_level_count - 1; + + if (!load_info->MipFilter || load_info->MipFilter == D3DX11_DEFAULT) + load_info->MipFilter = D3DX11_FILTER_LINEAR; + if (FAILED(hr = d3dx_validate_filter(load_info->MipFilter))) + { + ERR("Invalid mip filter argument %#x.\n", load_info->MipFilter); + goto end; + } + + d3dx_get_mip_level_size(&base_level_size, base_level); + for (i = 0; i < img_info.ArraySize; ++i) + { + struct volume src_size, dst_size; + + src_size = dst_size = base_level_size; + for (j = base_level; j < (load_info->MipLevels - 1); ++j) + { + struct d3dx_subresource_data *dst_data = &sub_rsrcs[i * load_info->MipLevels + j + 1]; + struct d3dx_subresource_data *src_data = &sub_rsrcs[i * load_info->MipLevels + j]; + const RECT src_unaligned_rect = { 0, 0, src_size.width, src_size.height }; + struct d3dx_pixels src_pixels, dst_pixels; + RECT dst_unaligned_rect; + + d3dx_get_next_mip_level_size(&dst_size); + SetRect(&dst_unaligned_rect, 0, 0, dst_size.width, dst_size.height); + set_d3dx_pixels(&dst_pixels, dst_data->data, dst_data->row_pitch, dst_data->slice_pitch, NULL, + dst_size.width, dst_size.height, dst_size.depth, &dst_unaligned_rect); + set_d3dx_pixels(&src_pixels, src_data->data, src_data->row_pitch, src_data->slice_pitch, NULL, + src_size.width, src_size.height, src_size.depth, &src_unaligned_rect); + + hr = d3dx_load_pixels_from_pixels(&dst_pixels, fmt_desc, &src_pixels, fmt_desc, load_info->MipFilter, 0); + if (FAILED(hr)) + goto end; + + src_size = dst_size; + } + } + } + + *resource_data = (D3D11_SUBRESOURCE_DATA *)sub_rsrcs; + sub_rsrcs = NULL; + + load_info->Usage = (load_info->Usage == D3DX11_DEFAULT) ? D3D11_USAGE_DEFAULT : load_info->Usage; + load_info->BindFlags = (load_info->BindFlags == D3DX11_DEFAULT) ? D3D11_BIND_SHADER_RESOURCE : load_info->BindFlags; + load_info->CpuAccessFlags = (load_info->CpuAccessFlags == D3DX11_DEFAULT) ? 0 : load_info->CpuAccessFlags; + load_info->MiscFlags = (load_info->MiscFlags == D3DX11_DEFAULT) ? 0 : load_info->MiscFlags; + load_info->MiscFlags |= img_info.MiscFlags; + /* + * Must be present in order to get resource dimension for texture + * creation. + */ + assert(load_info->pSrcInfo); + *load_info->pSrcInfo = img_info; + +end: + d3dx_image_cleanup(&image); + free(sub_rsrcs); + return hr; +} + +HRESULT create_d3d_texture(ID3D11Device *device, D3DX11_IMAGE_LOAD_INFO *load_info, + D3D11_SUBRESOURCE_DATA *resource_data, ID3D11Resource **texture) +{ + HRESULT hr; + + *texture = NULL; + switch (load_info->pSrcInfo->ResourceDimension) + { + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + { + D3D11_TEXTURE2D_DESC texture_2d_desc = { 0 }; + ID3D11Texture2D *texture_2d; + + texture_2d_desc.Width = load_info->Width; + texture_2d_desc.Height = load_info->Height; + texture_2d_desc.MipLevels = load_info->MipLevels; + texture_2d_desc.ArraySize = load_info->pSrcInfo->ArraySize; + texture_2d_desc.Format = load_info->Format; + texture_2d_desc.SampleDesc.Count = 1; + texture_2d_desc.Usage = load_info->Usage; + texture_2d_desc.BindFlags = load_info->BindFlags; + texture_2d_desc.CPUAccessFlags = load_info->CpuAccessFlags; + texture_2d_desc.MiscFlags = load_info->MiscFlags; + + if (FAILED(hr = ID3D11Device_CreateTexture2D(device, &texture_2d_desc, resource_data, &texture_2d))) + return hr; + *texture = (ID3D11Resource *)texture_2d; + break; + } + + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + { + D3D11_TEXTURE3D_DESC texture_3d_desc = { 0 }; + ID3D11Texture3D *texture_3d; + + texture_3d_desc.Width = load_info->Width; + texture_3d_desc.Height = load_info->Height; + texture_3d_desc.Depth = load_info->Depth; + texture_3d_desc.MipLevels = load_info->MipLevels; + texture_3d_desc.Format = load_info->Format; + texture_3d_desc.Usage = load_info->Usage; + texture_3d_desc.BindFlags = load_info->BindFlags; + texture_3d_desc.CPUAccessFlags = load_info->CpuAccessFlags; + texture_3d_desc.MiscFlags = load_info->MiscFlags; + + if (FAILED(hr = ID3D11Device_CreateTexture3D(device, &texture_3d_desc, resource_data, &texture_3d))) + return hr; + *texture = (ID3D11Resource *)texture_3d; + break; + } + + default: + FIXME("Unhandled resource dimension %d.\n", load_info->pSrcInfo->ResourceDimension); + return E_NOTIMPL; + } + + return S_OK; +} + +static HRESULT create_texture(ID3D11Device *device, const void *data, SIZE_T size, + D3DX11_IMAGE_LOAD_INFO *load_info, ID3D11Resource **texture) +{ + D3D11_SUBRESOURCE_DATA *resource_data; + D3DX11_IMAGE_LOAD_INFO load_info_copy; + D3DX11_IMAGE_INFO img_info; + HRESULT hr; + + init_load_info(load_info, &load_info_copy); + if (!load_info_copy.pSrcInfo) + load_info_copy.pSrcInfo = &img_info; + + if (FAILED((hr = load_texture_data(data, size, &load_info_copy, &resource_data)))) + return hr; + hr = create_d3d_texture(device, &load_info_copy, resource_data, texture); + free(resource_data); + return hr; +} + HRESULT WINAPI D3DX11CreateShaderResourceViewFromMemory(ID3D11Device *device, const void *data, SIZE_T data_size, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11ShaderResourceView **view, HRESULT *hresult) @@ -300,10 +576,23 @@ HRESULT WINAPI D3DX11CreateTextureFromMemory(ID3D11Device *device, const void *d SIZE_T data_size, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult) { - FIXME("device %p, data %p, data_size %Iu, load_info %p, pump %p, texture %p, hresult %p stub.\n", + HRESULT hr; + + TRACE("device %p, data %p, data_size %Iu, load_info %p, pump %p, texture %p, hresult %p.\n", device, data, data_size, load_info, pump, texture, hresult);
- return E_NOTIMPL; + if (!device) + return E_INVALIDARG; + if (!data) + return E_FAIL; + + if (pump) + FIXME("D3DX11 thread pump is currently unimplemented.\n"); + + hr = create_texture(device, data, data_size, load_info, texture); + if (hresult) + *hresult = hr; + return hr; }
HRESULT WINAPI D3DX11SaveTextureToFileW(ID3D11DeviceContext *context, ID3D11Resource *texture,
Matteo Bruni (@Mystral) commented about dlls/d3dx11_43/tests/d3dx11.c:
- 0x01,0xc8,0xf0,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x10,0x10,0xa6,0x18,0x8c,0x21,
- 0x00,0xc4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x03,0x4e,0x0f,0x3a,0x4c,0x94,0x9d,0xba,0x79,0xe7,0x38,
- 0x4c,0xcf,0x14,0xc3,0x43,0x91,0x88,0xfb,0xdc,0xe0,0x7c,0x34,0x70,0x9b,0x28,0xa9,
- 0x18,0x74,0x62,0x87,0x8e,0xe4,0x68,0x5f,0xb9,0xcc,0x0e,0xe1,0x8c,0x76,0x3a,0x9b,
- 0x82,0x76,0x71,0x13,0xde,0x50,0xd4,0x2d,0xc2,0xda,0x1e,0x3b,0xa6,0xa1,0x62,0x7b,
- 0xca,0x1a,0x85,0x4b,0x6e,0x74,0xec,0x60
+};
+static const unsigned char test_wmp_data[] = +{
- 0xff,0xff,0xff,0xff
+};
+/* 2x2 24-bit dds, 2 mipmaps */ +static const unsigned char dds_24bit[] =
For posterity: these are from d3dx9_test_images.h (not yet in the d3dx10 tests I think?)
Matteo Bruni (@Mystral) commented about dlls/d3dx11_43/tests/d3dx11.c:
return;- }
- miplevel = sub_resource_idx % texture_desc.MipLevels;
- init_resource_readback((ID3D11Resource *)texture, rb_texture,
max(1, texture_desc.Width >> miplevel),max(1, texture_desc.Height >> miplevel),max(1, texture_desc.Depth >> miplevel),sub_resource_idx, device, rb);- ID3D11Device_Release(device);
+}
+static void *get_readback_data(struct resource_readback *rb, uint32_t x, uint32_t y, uint32_t z, unsigned byte_width) +{
- return (BYTE *)rb->map_desc.pData + z * rb->map_desc.DepthPitch + y * rb->map_desc.RowPitch + x * byte_width;
The d3dx10 version has the cast to `uint8_t` here. This is obviously no different in practice, but I'd try to keep the d3dx10 and d3dx11 test sources as close as possible.
Matteo Bruni (@Mystral) commented about dlls/d3dx11_43/tests/d3dx11.c:
0x00,0x00};
+static const unsigned char test_bmp_1bpp_data[] =
Similar idea here. d3dx11.c was already using `unsigned char` for these image data arrays, d3dx10.c has `BYTE`. I'd just pick one of the two (or even e.g. `uint8_t` :upside_down:) and change over the other one, probably as a separate patch before this one.
Matteo Bruni (@Mystral) commented about dlls/d3dx11_43/tests/d3dx11.c:
- 0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
- 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
- 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c,
- 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab
+}; +static const unsigned char test_dds_volume_data[] = +{
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
+};
+/* 1x1 wmp image */ +static const unsigned char test_wmp[] =
This one is out of order vs d3dx10.c
Matteo Bruni (@Mystral) commented about dlls/d3dx11_43/tests/d3dx11.c:
- 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
- 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c,
- 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab
+}; +static const unsigned char test_dds_volume_data[] = +{
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
+};
+/* 1x1 wmp image */ +static const unsigned char test_wmp[] = +{
- 0x49,0x49,0xbc,0x01,0x20,0x00,0x00,0x00,0x24,0xc3,0xdd,0x6f,0x03,0x4e,0xfe,0x4b,
Also different spacing. In this particular case I'd reformat the one in d3dx10.c since that's the exception rather than the rule.
Matteo Bruni (@Mystral) commented about dlls/d3dx11_43/texture.c:
- const struct pixel_format_desc *fmt_desc, *src_desc;
- struct d3dx_subresource_data *sub_rsrcs = NULL;
- D3DX11_IMAGE_INFO img_info;
- struct d3dx_image image;
- unsigned int i, j;
- HRESULT hr = S_OK;
- if (!data || !size)
return E_FAIL;- *resource_data = NULL;
- if (!load_info->Filter || load_info->Filter == D3DX11_DEFAULT)
load_info->Filter = D3DX11_FILTER_LINEAR;- if (FAILED(hr = d3dx_validate_filter(load_info->Filter)))
- {
ERR("Invalid filter argument %#x.\n", load_info->Filter);
This should be a `WARN()` since it's an application-controlled argument. I see that I missed it in the d3dx10 implementation...
Matteo Bruni (@Mystral) commented about dlls/d3dx11_43/texture.c:
goto end;d3dx_get_next_mip_level_size(&dst_size);}- }
- if (loaded_mip_level_count < load_info->MipLevels)
- {
struct volume base_level_size = { load_info->Width, load_info->Height, load_info->Depth };const uint32_t base_level = loaded_mip_level_count - 1;if (!load_info->MipFilter || load_info->MipFilter == D3DX11_DEFAULT)load_info->MipFilter = D3DX11_FILTER_LINEAR;if (FAILED(hr = d3dx_validate_filter(load_info->MipFilter))){ERR("Invalid mip filter argument %#x.\n", load_info->MipFilter);
```suggestion:-0+0 WARN("Invalid mip filter argument %#x.\n", load_info->MipFilter); ```
Sorry I didn't get to this sooner. I left some comments with the general idea of keeping the d3dx10/11 tests as close as possible, now and going forward. Ideally it would be possible to do `diff -u dlls/d3dx10_43/tests/d3dx10.c dlls/d3dx11_43/tests/d3dx11.c` and quickly discern trivial differences (mainly all the s/10/11/) from "intended" ones.
some variable name changes to work around existing d3dx11 test definitions and a removal of a few `broken()`s for Windows Vista since we no longer test on it.
In the same vein, I'd get rid of those `broken()`s from the d3dx10 tests as well, by removing them from d3dx10 before, or after, porting the test over (in the latter case you could even argue for bringing the `broken()` in the initial introduction of the d3dx11 version — I don't think it would be necessary).
WRT the variable names, I'd rather change (or even get rid of, if largely made obsolete) the existing d3dx11 tests to keep the two versions better in sync.