mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-30 05:31:39 +00:00
d3dx9/tests: Add more tests for loading files with multiple mip levels into textures.
Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
This commit is contained in:
parent
52e71f3e07
commit
acf797f669
|
@ -128,6 +128,91 @@ static const unsigned char png_grayscale[] =
|
|||
0x60, 0x82
|
||||
};
|
||||
|
||||
/*
|
||||
* 4x4x4 24-bit volume dds, 3 mipmaps. Level 0 is red, level 1 is green, level 2 is
|
||||
* blue.
|
||||
*/
|
||||
static const BYTE dds_volume_24bit_4_4_4[] =
|
||||
{
|
||||
0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x82,0x00,0x04,0x00,0x00,0x00,
|
||||
0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x04,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,
|
||||
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,0x20,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,0xff,0x00,0x00
|
||||
};
|
||||
|
||||
/*
|
||||
* 4x4x4 DXT3 volume dds. 3 mipmaps. Level 0 is red, level 1 is green, level 2 is
|
||||
* blue.
|
||||
*/
|
||||
static const BYTE dds_volume_dxt3_4_4_4[] =
|
||||
{
|
||||
0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00,
|
||||
0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x04,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,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x07,0xe0,0x07,0xaa,0xaa,0xaa,0xaa,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x07,0xe0,0x07,0xaa,0xaa,0xaa,0xaa,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x1f,0x00,0xaa,0xaa,0xaa,0xaa,
|
||||
};
|
||||
|
||||
/*
|
||||
* 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 BYTE 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
|
||||
};
|
||||
|
||||
#define ADMITTED_ERROR 0.0001f
|
||||
|
||||
static inline float relative_error(float expected, float got)
|
||||
|
@ -248,6 +333,88 @@ static BOOL compare_color(DWORD c1, DWORD c2, BYTE max_diff)
|
|||
&& compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff);
|
||||
}
|
||||
|
||||
struct surface_readback
|
||||
{
|
||||
IDirect3DSurface9 *surface;
|
||||
D3DLOCKED_RECT locked_rect;
|
||||
};
|
||||
|
||||
static uint32_t get_readback_color(struct surface_readback *rb, uint32_t x, uint32_t y)
|
||||
{
|
||||
return rb->locked_rect.pBits
|
||||
? ((uint32_t *)rb->locked_rect.pBits)[y * rb->locked_rect.Pitch / sizeof(uint32_t) + x] : 0xdeadbeef;
|
||||
}
|
||||
|
||||
static void release_surface_readback(struct surface_readback *rb)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if (!rb->surface)
|
||||
return;
|
||||
if (rb->locked_rect.pBits && FAILED(hr = IDirect3DSurface9_UnlockRect(rb->surface)))
|
||||
trace("Can't unlock the readback surface, hr %#lx.\n", hr);
|
||||
IDirect3DSurface9_Release(rb->surface);
|
||||
}
|
||||
|
||||
static void get_texture_surface_readback(IDirect3DDevice9 *device, IDirect3DTexture9 *texture, uint32_t mip_level,
|
||||
struct surface_readback *rb)
|
||||
{
|
||||
IDirect3DSurface9 *surface;
|
||||
D3DSURFACE_DESC desc;
|
||||
HRESULT hr;
|
||||
|
||||
memset(rb, 0, sizeof(*rb));
|
||||
hr = IDirect3DTexture9_GetSurfaceLevel(texture, mip_level, &surface);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
trace("Failed to get surface for mip level %d, hr %#lx.\n", mip_level, hr);
|
||||
return;
|
||||
}
|
||||
|
||||
hr = IDirect3DSurface9_GetDesc(surface, &desc);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
trace("Failed to get surface description, hr %#lx.\n", hr);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM,
|
||||
&rb->surface, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
trace("Can't create the readback surface, hr %#lx.\n", hr);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
hr = D3DXLoadSurfaceFromSurface(rb->surface, NULL, NULL, surface, NULL, NULL, D3DX_FILTER_NONE, 0);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
trace("Can't load the readback surface, hr %#lx.\n", hr);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
hr = IDirect3DSurface9_LockRect(rb->surface, &rb->locked_rect, NULL, D3DLOCK_READONLY);
|
||||
if (FAILED(hr))
|
||||
trace("Can't lock the readback surface, hr %#lx.\n", hr);
|
||||
|
||||
exit:
|
||||
IDirect3DSurface9_Release(surface);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
if (rb->surface)
|
||||
IDirect3DSurface9_Release(rb->surface);
|
||||
rb->surface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#define check_readback_pixel_4bpp(rb, x, y, color, todo) _check_readback_pixel_4bpp(__LINE__, rb, x, y, color, todo)
|
||||
static inline void _check_readback_pixel_4bpp(uint32_t line, struct surface_readback *rb, uint32_t x,
|
||||
uint32_t y, uint32_t expected_color, BOOL todo)
|
||||
{
|
||||
uint32_t color = get_readback_color(rb, x, y);
|
||||
todo_wine_if(todo) ok_(__FILE__, line)(color == expected_color, "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
|
||||
}
|
||||
|
||||
static BOOL is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -1763,6 +1930,10 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
|
|||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
};
|
||||
static const uint32_t dds_volume_dxt3_4_4_4_expected_uncompressed[] =
|
||||
{
|
||||
0xffff0000, 0xff00ff00, 0xff0000ff,
|
||||
};
|
||||
IDirect3DSurface9 *surface, *uncompressed_surface;
|
||||
IDirect3DTexture9 *texture;
|
||||
D3DLOCKED_RECT lock_rect;
|
||||
|
@ -2012,16 +2183,69 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
|
|||
ok(desc.Format == D3DFMT_A8R8G8B8, "Unexpected texture format %#x.\n", desc.Format);
|
||||
skip("D3DFMT_DXT3 volume textures are not supported, skipping a test.\n");
|
||||
}
|
||||
/* The lower texture levels are apparently generated by filtering the level 0 surface
|
||||
* I.e. following levels from the file are ignored. */
|
||||
|
||||
IDirect3DTexture9_Release(texture);
|
||||
|
||||
/*
|
||||
* All mip levels are pulled from the texture file, even in the case of a
|
||||
* volume texture file.
|
||||
*/
|
||||
hr = D3DXCreateTextureFromFileInMemory(device, dds_volume_dxt3_4_4_4, sizeof(dds_volume_dxt3_4_4_4), &texture);
|
||||
ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
|
||||
check_texture_mip_levels(texture, 3, TRUE);
|
||||
if (has_2d_dxt3)
|
||||
{
|
||||
struct surface_readback surface_rb;
|
||||
uint32_t mip_level;
|
||||
|
||||
check_texture_level_desc(texture, 0, D3DFMT_DXT3, 0, D3DPOOL_MANAGED, 0, 0, 4, 4, FALSE);
|
||||
check_texture_level_desc(texture, 1, D3DFMT_DXT3, 0, D3DPOOL_MANAGED, 0, 0, 2, 2, TRUE);
|
||||
check_texture_level_desc(texture, 2, D3DFMT_DXT3, 0, D3DPOOL_MANAGED, 0, 0, 1, 1, TRUE);
|
||||
for (mip_level = 0; mip_level < ARRAY_SIZE(dds_volume_dxt3_4_4_4_expected_uncompressed); ++mip_level)
|
||||
{
|
||||
const uint32_t expected_color = dds_volume_dxt3_4_4_4_expected_uncompressed[mip_level];
|
||||
BOOL todo = !!mip_level;
|
||||
uint32_t x, y;
|
||||
|
||||
IDirect3DTexture9_GetLevelDesc(texture, mip_level, &desc);
|
||||
get_texture_surface_readback(device, texture, mip_level, &surface_rb);
|
||||
for (y = 0; y < desc.Height; ++y)
|
||||
{
|
||||
for (x = 0; x < desc.Width; ++x)
|
||||
{
|
||||
check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, todo);
|
||||
}
|
||||
}
|
||||
release_surface_readback(&surface_rb);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
check_texture_level_desc(texture, 0, D3DFMT_A8R8G8B8, 0, D3DPOOL_MANAGED, 0, 0, 4, 4, FALSE);
|
||||
skip("D3DFMT_DXT3 textures are not supported, skipping a test.\n");
|
||||
}
|
||||
|
||||
IDirect3DTexture9_Release(texture);
|
||||
}
|
||||
|
||||
static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
|
||||
{
|
||||
static const uint32_t dds_24bit_8_8_expected[] =
|
||||
{
|
||||
0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000,
|
||||
};
|
||||
static const uint32_t dds_volume_24bit_4_4_4_expected[] =
|
||||
{
|
||||
0xffff0000, 0xff00ff00, 0xff0000ff,
|
||||
};
|
||||
static const uint32_t dds_volume_dxt3_4_4_4_expected_uncompressed[] =
|
||||
{
|
||||
0xffff0000, 0xff00ff00, 0xff0000ff,
|
||||
};
|
||||
HRESULT hr;
|
||||
struct surface_readback surface_rb;
|
||||
uint32_t miplevels, mip_level;
|
||||
IDirect3DTexture9 *texture;
|
||||
unsigned int miplevels;
|
||||
IDirect3DSurface9 *surface;
|
||||
D3DXIMAGE_INFO img_info;
|
||||
D3DSURFACE_DESC desc;
|
||||
|
@ -2188,6 +2412,112 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
|
|||
check_texture_level_desc(texture, 0, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 1, 1, TRUE);
|
||||
|
||||
IDirect3DTexture9_Release(texture);
|
||||
|
||||
/*
|
||||
* Load multiple mip levels from a file and check the resulting pixel
|
||||
* values.
|
||||
*/
|
||||
hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_24bit_8_8, sizeof(dds_24bit_8_8),
|
||||
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
|
||||
D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
|
||||
ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
|
||||
|
||||
check_texture_mip_levels(texture, 4, FALSE);
|
||||
check_image_info(&img_info, 8, 8, 1, 4, D3DFMT_R8G8B8, D3DRTYPE_TEXTURE, D3DXIFF_DDS, FALSE);
|
||||
check_texture_level_desc(texture, 0, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 8, 8, FALSE);
|
||||
check_texture_level_desc(texture, 1, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 4, 4, FALSE);
|
||||
check_texture_level_desc(texture, 2, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 2, 2, FALSE);
|
||||
check_texture_level_desc(texture, 3, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 1, 1, FALSE);
|
||||
|
||||
for (mip_level = 0; mip_level < ARRAY_SIZE(dds_24bit_8_8_expected); ++mip_level)
|
||||
{
|
||||
const uint32_t expected_color = dds_24bit_8_8_expected[mip_level];
|
||||
uint32_t x, y;
|
||||
|
||||
IDirect3DTexture9_GetLevelDesc(texture, mip_level, &desc);
|
||||
get_texture_surface_readback(device, texture, mip_level, &surface_rb);
|
||||
for (y = 0; y < desc.Height; ++y)
|
||||
{
|
||||
for (x = 0; x < desc.Width; ++x)
|
||||
{
|
||||
check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, FALSE);
|
||||
}
|
||||
}
|
||||
release_surface_readback(&surface_rb);
|
||||
}
|
||||
|
||||
IDirect3DTexture9_Release(texture);
|
||||
|
||||
/* Volume DDS with mips into regular texture tests. */
|
||||
hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_volume_24bit_4_4_4, sizeof(dds_volume_24bit_4_4_4),
|
||||
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
|
||||
D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
|
||||
ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
|
||||
|
||||
check_texture_mip_levels(texture, 3, FALSE);
|
||||
check_image_info(&img_info, 4, 4, 4, 3, D3DFMT_R8G8B8, D3DRTYPE_VOLUMETEXTURE, D3DXIFF_DDS, FALSE);
|
||||
check_texture_level_desc(texture, 0, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 4, 4, FALSE);
|
||||
check_texture_level_desc(texture, 1, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 2, 2, FALSE);
|
||||
check_texture_level_desc(texture, 2, D3DFMT_X8R8G8B8, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 1, 1, FALSE);
|
||||
|
||||
for (mip_level = 0; mip_level < ARRAY_SIZE(dds_volume_24bit_4_4_4_expected); ++mip_level)
|
||||
{
|
||||
const uint32_t expected_color = dds_volume_24bit_4_4_4_expected[mip_level];
|
||||
BOOL todo = !!mip_level;
|
||||
uint32_t x, y;
|
||||
|
||||
IDirect3DTexture9_GetLevelDesc(texture, mip_level, &desc);
|
||||
get_texture_surface_readback(device, texture, mip_level, &surface_rb);
|
||||
for (y = 0; y < desc.Height; ++y)
|
||||
{
|
||||
for (x = 0; x < desc.Width; ++x)
|
||||
{
|
||||
check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, todo);
|
||||
}
|
||||
}
|
||||
release_surface_readback(&surface_rb);
|
||||
}
|
||||
|
||||
IDirect3DTexture9_Release(texture);
|
||||
|
||||
/* DXT3 volume DDS with mips into a regular texture. */
|
||||
if (has_2d_dxt3)
|
||||
{
|
||||
hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_volume_dxt3_4_4_4, sizeof(dds_volume_dxt3_4_4_4),
|
||||
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
|
||||
D3DX_DEFAULT, D3DX_DEFAULT, 0, &img_info, NULL, &texture);
|
||||
ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
|
||||
|
||||
check_texture_mip_levels(texture, 3, TRUE);
|
||||
check_image_info(&img_info, 4, 4, 4, 3, D3DFMT_DXT3, D3DRTYPE_VOLUMETEXTURE, D3DXIFF_DDS, FALSE);
|
||||
check_texture_level_desc(texture, 0, D3DFMT_DXT3, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 4, 4, FALSE);
|
||||
check_texture_level_desc(texture, 1, D3DFMT_DXT3, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 2, 2, TRUE);
|
||||
check_texture_level_desc(texture, 2, D3DFMT_DXT3, D3DUSAGE_DYNAMIC, D3DPOOL_DEFAULT, 0, 0, 1, 1, TRUE);
|
||||
|
||||
for (mip_level = 0; mip_level < ARRAY_SIZE(dds_volume_dxt3_4_4_4_expected_uncompressed); ++mip_level)
|
||||
{
|
||||
const uint32_t expected_color = dds_volume_dxt3_4_4_4_expected_uncompressed[mip_level];
|
||||
BOOL todo = !!mip_level;
|
||||
uint32_t x, y;
|
||||
|
||||
IDirect3DTexture9_GetLevelDesc(texture, mip_level, &desc);
|
||||
get_texture_surface_readback(device, texture, mip_level, &surface_rb);
|
||||
for (y = 0; y < desc.Height; ++y)
|
||||
{
|
||||
for (x = 0; x < desc.Width; ++x)
|
||||
{
|
||||
check_readback_pixel_4bpp(&surface_rb, x, y, expected_color, todo);
|
||||
}
|
||||
}
|
||||
release_surface_readback(&surface_rb);
|
||||
}
|
||||
|
||||
IDirect3DTexture9_Release(texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
skip("D3DFMT_DXT3 textures are not supported, skipping tests.\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
|
||||
|
|
Loading…
Reference in a new issue