Commit b7656110 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dx9/tests: Add a test with a larger DXT5 texture.

parent 426d6776
......@@ -101,6 +101,22 @@ static const BYTE dds_dxt5[] =
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
};
static const BYTE dds_dxt5_8_8[] =
{
0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x08,0x00,0x00,0x00,
0x08,0x00,0x00,0x00,0x20,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,
0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0xe0,0x07,0x05,0x05,0x50,0x50,
0x3f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x07,0x05,0x05,0x50,0x50,
0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xf8,0xe0,0xff,0x05,0x05,0x50,0x50,
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x05,0x05,0x50,0x50,
};
static const unsigned char png_grayscale[] =
{
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,
......@@ -1556,6 +1572,17 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
0xff7b207b, 0xff7b207b, 0xff84df7b, 0xff84df7b,
};
static const DWORD dds_dxt5_8_8_expected[] =
{
0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x3f00ffff, 0x3f00ffff, 0x3fff0000, 0x3fff0000,
0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x3f00ffff, 0x3f00ffff, 0x3fff0000, 0x3fff0000,
0x000000ff, 0x000000ff, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3f00ffff, 0x3f00ffff,
0x000000ff, 0x000000ff, 0x0000ff00, 0x0000ff00, 0x3fff0000, 0x3fff0000, 0x3f00ffff, 0x3f00ffff,
0x7fffff00, 0x7fffff00, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xffffffff, 0xffffffff,
0x7fffff00, 0x7fffff00, 0x7fff00ff, 0x7fff00ff, 0xff000000, 0xff000000, 0xffffffff, 0xffffffff,
0x7fff00ff, 0x7fff00ff, 0x7fffff00, 0x7fffff00, 0xffffffff, 0xffffffff, 0xff000000, 0xff000000,
0x7fff00ff, 0x7fff00ff, 0x7fffff00, 0x7fffff00, 0xffffffff, 0xffffffff, 0xff000000, 0xff000000,
};
IDirect3DSurface9 *surface, *uncompressed_surface;
IDirect3DTexture9 *texture;
D3DLOCKED_RECT lock_rect;
......@@ -1644,6 +1671,45 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
if (SUCCEEDED(hr))
IDirect3DTexture9_Release(texture);
/* Test with a larger DXT5 texture. */
hr = D3DXCreateTextureFromFileInMemory(device, dds_dxt5_8_8, sizeof(dds_dxt5_8_8), &texture);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
type = IDirect3DTexture9_GetType(texture);
ok(type == D3DRTYPE_TEXTURE, "Got unexpected type %u.\n", type);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(desc.Width == 8, "Got unexpected width %u.\n", desc.Width);
ok(desc.Height == 8, "Got unexpected height %u.\n", desc.Height);
IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 8, 8, D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT, &uncompressed_surface, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = D3DXLoadSurfaceFromSurface(uncompressed_surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = IDirect3DSurface9_LockRect(uncompressed_surface, &lock_rect, NULL, D3DLOCK_READONLY);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (y = 0; y < 8; ++y)
{
for (x = 0; x < 8; ++x)
{
ok(compare_color(((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
dds_dxt5_8_8_expected[y * 8 + x], 0),
"Color at position %u, %u is 0x%08x, expected 0x%08x.\n",
x, y, ((DWORD *)lock_rect.pBits)[lock_rect.Pitch / 4 * y + x],
dds_dxt5_8_8_expected[y * 8 + x]);
}
}
hr = IDirect3DSurface9_UnlockRect(uncompressed_surface);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
}
IDirect3DSurface9_Release(uncompressed_surface);
IDirect3DSurface9_Release(surface);
IDirect3DTexture9_Release(texture);
/* Volume textures work too. */
hr = D3DXCreateTextureFromFileInMemory(device, dds_volume_map, sizeof(dds_volume_map), &texture);
todo_wine_if (!has_2d_dxt3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment