d3d9/tests: Use a separate device for test_cube_wrap().

This commit is contained in:
Henri Verbeet 2014-04-10 10:05:44 +02:00 committed by Alexandre Julliard
parent 8a170e9d48
commit 0453e4e44a
1 changed files with 50 additions and 28 deletions

View File

@ -1496,40 +1496,65 @@ static void fog_test(IDirect3DDevice9 *device)
* interpolate between the edge texels of the three involved faces. It should * interpolate between the edge texels of the three involved faces. It should
* never involve the border color or the other side (texcoord wrapping) of a * never involve the border color or the other side (texcoord wrapping) of a
* face in the interpolation. */ * face in the interpolation. */
static void test_cube_wrap(IDirect3DDevice9 *device) static void test_cube_wrap(void)
{ {
static const float quad[][6] = { IDirect3DVertexDeclaration9 *vertex_declaration;
IDirect3DSurface9 *face_surface, *surface;
IDirect3DCubeTexture9 *texture;
D3DLOCKED_RECT locked_rect;
IDirect3DDevice9 *device;
unsigned int x, y, face;
IDirect3D9 *d3d;
ULONG refcount;
D3DCAPS9 caps;
HWND window;
HRESULT hr;
static const float quad[][6] =
{
{-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f}, {-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
{-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
{ 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f}, { 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
{ 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
}; };
static const D3DVERTEXELEMENT9 decl_elements[] =
static const D3DVERTEXELEMENT9 decl_elements[] = { {
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, {0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
D3DDECL_END() D3DDECL_END()
}; };
static const struct
static const struct { {
D3DTEXTUREADDRESS mode; D3DTEXTUREADDRESS mode;
const char *name; const char *name;
} address_modes[] = { }
{D3DTADDRESS_WRAP, "D3DTADDRESS_WRAP"}, address_modes[] =
{D3DTADDRESS_MIRROR, "D3DTADDRESS_MIRROR"}, {
{D3DTADDRESS_CLAMP, "D3DTADDRESS_CLAMP"}, {D3DTADDRESS_WRAP, "D3DTADDRESS_WRAP"},
{D3DTADDRESS_BORDER, "D3DTADDRESS_BORDER"}, {D3DTADDRESS_MIRROR, "D3DTADDRESS_MIRROR"},
{D3DTADDRESS_CLAMP, "D3DTADDRESS_CLAMP"},
{D3DTADDRESS_BORDER, "D3DTADDRESS_BORDER"},
{D3DTADDRESS_MIRRORONCE, "D3DTADDRESS_MIRRORONCE"}, {D3DTADDRESS_MIRRORONCE, "D3DTADDRESS_MIRRORONCE"},
}; };
IDirect3DVertexDeclaration9 *vertex_declaration = NULL; window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
IDirect3DCubeTexture9 *texture = NULL; 0, 0, 640, 480, NULL, NULL, NULL, NULL);
IDirect3DSurface9 *surface = NULL; d3d = Direct3DCreate9(D3D_SDK_VERSION);
IDirect3DSurface9 *face_surface; ok(!!d3d, "Failed to create a D3D object.\n");
D3DLOCKED_RECT locked_rect; if (!(device = create_device(d3d, window, window, TRUE)))
HRESULT hr; {
UINT x; skip("Failed to create a D3D device, skipping tests.\n");
INT y, face; goto done;
}
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
if (!(caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP))
{
skip("No cube texture support, skipping tests.\n");
IDirect3DDevice9_Release(device);
goto done;
}
hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration); hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (0x%08x)\n", hr); ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (0x%08x)\n", hr);
@ -1645,12 +1670,14 @@ static void test_cube_wrap(IDirect3DDevice9 *device)
ok(SUCCEEDED(hr), "Clear failed (0x%08x)\n", hr); ok(SUCCEEDED(hr), "Clear failed (0x%08x)\n", hr);
} }
hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
ok(SUCCEEDED(hr), "SetTexture failed (0x%08x)\n", hr);
IDirect3DVertexDeclaration9_Release(vertex_declaration); IDirect3DVertexDeclaration9_Release(vertex_declaration);
IDirect3DCubeTexture9_Release(texture); IDirect3DCubeTexture9_Release(texture);
IDirect3DSurface9_Release(surface); IDirect3DSurface9_Release(surface);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
} }
static void offscreen_test(void) static void offscreen_test(void)
@ -16687,16 +16714,11 @@ START_TEST(visual)
clear_test(device_ptr); clear_test(device_ptr);
color_fill_test(device_ptr); color_fill_test(device_ptr);
fog_test(device_ptr); fog_test(device_ptr);
if(caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP)
{
test_cube_wrap(device_ptr);
} else {
skip("No cube texture support\n");
}
cleanup_device(device_ptr); cleanup_device(device_ptr);
device_ptr = NULL; device_ptr = NULL;
test_cube_wrap();
z_range_test(); z_range_test();
maxmip_test(); maxmip_test();
offscreen_test(); offscreen_test();