Commit cf896386 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3dx9/tests: Move tests for texture functions from surface.c to texture.c.

parent 685be772
...@@ -833,90 +833,6 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) ...@@ -833,90 +833,6 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
if(testbitmap_ok) DeleteFileA("testbitmap.bmp"); if(testbitmap_ok) DeleteFileA("testbitmap.bmp");
} }
static void test_D3DXCreateCubeTexture(IDirect3DDevice9 *device)
{
HRESULT hr;
ULONG ref;
DWORD levelcount;
IDirect3DCubeTexture9 *cube_texture;
D3DSURFACE_DESC surface_desc;
todo_wine {
hr = D3DXCreateCubeTextureFromFileInMemory(NULL, dds_cube_map, sizeof(dds_cube_map), &cube_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateCubeTextureFromFileInMemory(device, NULL, sizeof(dds_cube_map), &cube_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateCubeTextureFromFileInMemory(device, dds_cube_map, 0, &cube_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateCubeTextureFromFileInMemory(device, dds_cube_map, sizeof(dds_cube_map), NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateCubeTextureFromFileInMemory(device, dds_cube_map, sizeof(dds_cube_map), &cube_texture);
if(SUCCEEDED(hr)) {
levelcount = IDirect3DCubeTexture9_GetLevelCount(cube_texture);
ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
hr = IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &surface_desc);
ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
ok(surface_desc.Width == 4, "Got width %u, expected 4\n", surface_desc.Width);
ok(surface_desc.Height == 4, "Got height %u, expected 4\n", surface_desc.Height);
hr = IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 3, &surface_desc);
ok(hr == D3DERR_INVALIDCALL, "GetLevelDesc returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
ref = IDirect3DCubeTexture9_Release(cube_texture);
ok(ref == 0, "Invalid reference count. Got %u, expected 0\n", ref);
} else skip("Couldn't create cube texture\n");
}
}
static void test_D3DXCreateVolumeTexture(IDirect3DDevice9 *device)
{
HRESULT hr;
ULONG ref;
DWORD levelcount;
IDirect3DVolumeTexture9 *volume_texture;
D3DVOLUME_DESC volume_desc;
todo_wine {
hr = D3DXCreateVolumeTextureFromFileInMemory(NULL, dds_volume_map, sizeof(dds_volume_map), &volume_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateVolumeTextureFromFileInMemory(device, NULL, sizeof(dds_volume_map), &volume_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateVolumeTextureFromFileInMemory(device, dds_volume_map, 0, &volume_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateVolumeTextureFromFileInMemory(device, dds_volume_map, sizeof(dds_volume_map), NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateVolumeTextureFromFileInMemory(device, dds_volume_map, sizeof(dds_volume_map), &volume_texture);
if(SUCCEEDED(hr)) {
levelcount = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &volume_desc);
ok(hr == D3D_OK, "GetLevelDesc returend %#x, expected %#x\n", hr, D3D_OK);
ok(volume_desc.Width == 4, "Got width %u, expected 4\n", volume_desc.Width);
ok(volume_desc.Height == 4, "Got height %u, expected 4\n", volume_desc.Height);
ok(volume_desc.Depth == 2, "Got depth %u, expected 2\n", volume_desc.Depth);
hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 1, &volume_desc);
ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
ok(volume_desc.Width == 2, "Got width %u, expected 2\n", volume_desc.Width);
ok(volume_desc.Height == 2, "Got height %u, expected 2\n", volume_desc.Height);
ok(volume_desc.Depth == 1, "Got depth %u, expected 1\n", volume_desc.Depth);
ref = IDirect3DVolumeTexture9_Release(volume_texture);
ok(ref == 0, "Invalid reference count. Got %u, expected 0\n", ref);
}
}
}
static void test_D3DXSaveSurfaceToFile(IDirect3DDevice9 *device) static void test_D3DXSaveSurfaceToFile(IDirect3DDevice9 *device)
{ {
HRESULT hr; HRESULT hr;
...@@ -1033,8 +949,6 @@ START_TEST(surface) ...@@ -1033,8 +949,6 @@ START_TEST(surface)
test_D3DXGetImageInfo(); test_D3DXGetImageInfo();
test_D3DXLoadSurface(device); test_D3DXLoadSurface(device);
test_D3DXCreateCubeTexture(device);
test_D3DXCreateVolumeTexture(device);
test_D3DXSaveSurfaceToFile(device); test_D3DXSaveSurfaceToFile(device);
check_release((IUnknown*)device, 0); check_release((IUnknown*)device, 0);
......
...@@ -25,6 +25,40 @@ ...@@ -25,6 +25,40 @@
#include "d3dx9tex.h" #include "d3dx9tex.h"
#include "resources.h" #include "resources.h"
/* 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
};
static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device) static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
{ {
UINT width, height, mipmaps; UINT width, height, mipmaps;
...@@ -1072,6 +1106,92 @@ static void test_D3DXFillVolumeTexture(IDirect3DDevice9 *device) ...@@ -1072,6 +1106,92 @@ static void test_D3DXFillVolumeTexture(IDirect3DDevice9 *device)
IDirect3DVolumeTexture9_Release(tex); IDirect3DVolumeTexture9_Release(tex);
} }
static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
{
HRESULT hr;
ULONG ref;
DWORD levelcount;
IDirect3DCubeTexture9 *cube_texture;
D3DSURFACE_DESC surface_desc;
todo_wine {
hr = D3DXCreateCubeTextureFromFileInMemory(NULL, dds_cube_map, sizeof(dds_cube_map), &cube_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateCubeTextureFromFileInMemory(device, NULL, sizeof(dds_cube_map), &cube_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateCubeTextureFromFileInMemory(device, dds_cube_map, 0, &cube_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateCubeTextureFromFileInMemory(device, dds_cube_map, sizeof(dds_cube_map), NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateCubeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateCubeTextureFromFileInMemory(device, dds_cube_map, sizeof(dds_cube_map), &cube_texture);
if (SUCCEEDED(hr))
{
levelcount = IDirect3DCubeTexture9_GetLevelCount(cube_texture);
ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
hr = IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 0, &surface_desc);
ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
ok(surface_desc.Width == 4, "Got width %u, expected 4\n", surface_desc.Width);
ok(surface_desc.Height == 4, "Got height %u, expected 4\n", surface_desc.Height);
hr = IDirect3DCubeTexture9_GetLevelDesc(cube_texture, 3, &surface_desc);
ok(hr == D3DERR_INVALIDCALL, "GetLevelDesc returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
ref = IDirect3DCubeTexture9_Release(cube_texture);
ok(ref == 0, "Invalid reference count. Got %u, expected 0\n", ref);
} else skip("Couldn't create cube texture\n");
}
}
static void test_D3DXCreateVolumeTextureFromFileInMemory(IDirect3DDevice9 *device)
{
HRESULT hr;
ULONG ref;
DWORD levelcount;
IDirect3DVolumeTexture9 *volume_texture;
D3DVOLUME_DESC volume_desc;
todo_wine {
hr = D3DXCreateVolumeTextureFromFileInMemory(NULL, dds_volume_map, sizeof(dds_volume_map), &volume_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateVolumeTextureFromFileInMemory(device, NULL, sizeof(dds_volume_map), &volume_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateVolumeTextureFromFileInMemory(device, dds_volume_map, 0, &volume_texture);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateVolumeTextureFromFileInMemory(device, dds_volume_map, sizeof(dds_volume_map), NULL);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateVolumeTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateVolumeTextureFromFileInMemory(device, dds_volume_map, sizeof(dds_volume_map), &volume_texture);
if (SUCCEEDED(hr))
{
levelcount = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
ok(levelcount == 3, "GetLevelCount returned %u, expected 3\n", levelcount);
hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 0, &volume_desc);
ok(hr == D3D_OK, "GetLevelDesc returend %#x, expected %#x\n", hr, D3D_OK);
ok(volume_desc.Width == 4, "Got width %u, expected 4\n", volume_desc.Width);
ok(volume_desc.Height == 4, "Got height %u, expected 4\n", volume_desc.Height);
ok(volume_desc.Depth == 2, "Got depth %u, expected 2\n", volume_desc.Depth);
hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, 1, &volume_desc);
ok(hr == D3D_OK, "GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
ok(volume_desc.Width == 2, "Got width %u, expected 2\n", volume_desc.Width);
ok(volume_desc.Height == 2, "Got height %u, expected 2\n", volume_desc.Height);
ok(volume_desc.Depth == 1, "Got depth %u, expected 1\n", volume_desc.Depth);
ref = IDirect3DVolumeTexture9_Release(volume_texture);
ok(ref == 0, "Invalid reference count. Got %u, expected 0\n", ref);
}
}
}
START_TEST(texture) START_TEST(texture)
{ {
HWND wnd; HWND wnd;
...@@ -1111,6 +1231,8 @@ START_TEST(texture) ...@@ -1111,6 +1231,8 @@ START_TEST(texture)
test_D3DXFillTexture(device); test_D3DXFillTexture(device);
test_D3DXFillCubeTexture(device); test_D3DXFillCubeTexture(device);
test_D3DXFillVolumeTexture(device); test_D3DXFillVolumeTexture(device);
test_D3DXCreateCubeTextureFromFileInMemory(device);
test_D3DXCreateVolumeTextureFromFileInMemory(device);
IDirect3DDevice9_Release(device); IDirect3DDevice9_Release(device);
IDirect3D9_Release(d3d); IDirect3D9_Release(d3d);
......
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