Henri Verbeet : d3d9/tests: Use a separate device for float_texture_test() .
Alexandre Julliard
julliard at winehq.org
Tue Apr 8 14:02:50 CDT 2014
Module: wine
Branch: master
Commit: 1abd58edea2e136d14da0503bcf144f5d63dbf47
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1abd58edea2e136d14da0503bcf144f5d63dbf47
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Tue Apr 8 09:21:56 2014 +0200
d3d9/tests: Use a separate device for float_texture_test().
---
dlls/d3d9/tests/visual.c | 71 ++++++++++++++++++++++++++++------------------
1 file changed, 44 insertions(+), 27 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 4275b04..41ef190 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -3791,37 +3791,48 @@ static void release_buffer_test(IDirect3DDevice9 *device)
IDirect3DVertexBuffer9_Release(vb);
}
-static void float_texture_test(IDirect3DDevice9 *device)
+static void float_texture_test(void)
{
- IDirect3D9 *d3d = NULL;
- HRESULT hr;
- IDirect3DTexture9 *texture = NULL;
+ IDirect3DTexture9 *texture;
+ IDirect3DDevice9 *device;
D3DLOCKED_RECT lr;
+ IDirect3D9 *d3d;
+ ULONG refcount;
float *data;
DWORD color;
- float quad[] = {
- -1.0, -1.0, 0.1, 0.0, 0.0,
- -1.0, 1.0, 0.1, 0.0, 1.0,
- 1.0, -1.0, 0.1, 1.0, 0.0,
- 1.0, 1.0, 0.1, 1.0, 1.0,
+ HWND window;
+ HRESULT hr;
+
+ static const float quad[] =
+ {
+ -1.0f, -1.0f, 0.1f, 0.0f, 0.0f,
+ -1.0f, 1.0f, 0.1f, 0.0f, 1.0f,
+ 1.0f, -1.0f, 0.1f, 1.0f, 0.0f,
+ 1.0f, 1.0f, 0.1f, 1.0f, 1.0f,
};
- memset(&lr, 0, sizeof(lr));
- IDirect3DDevice9_GetDirect3D(device, &d3d);
- if(IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0,
- D3DRTYPE_TEXTURE, D3DFMT_R32F) != D3D_OK) {
- skip("D3DFMT_R32F textures not supported\n");
- goto out;
+ window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object.\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
}
- hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_R32F,
- D3DPOOL_MANAGED, &texture, NULL);
- ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed with %08x\n", hr);
- if(!texture) {
- skip("Failed to create R32F texture\n");
- goto out;
+ if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL,
+ D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_R32F) != D3D_OK)
+ {
+ skip("D3DFMT_R32F textures not supported\n");
+ IDirect3DDevice9_Release(device);
+ goto done;
}
+ hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_R32F, D3DPOOL_MANAGED, &texture, NULL);
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+
+ memset(&lr, 0, sizeof(lr));
hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
ok(hr == D3D_OK, "IDirect3DTexture9_LockRect failed with %08x\n", hr);
data = lr.pBits;
@@ -3829,9 +3840,14 @@ static void float_texture_test(IDirect3DDevice9 *device)
hr = IDirect3DTexture9_UnlockRect(texture, 0);
ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect failed with %08x\n", hr);
- hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %08x\n", hr);
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+
hr = IDirect3DDevice9_BeginScene(device);
ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %08x\n", hr);
if(SUCCEEDED(hr))
@@ -3845,8 +3861,6 @@ static void float_texture_test(IDirect3DDevice9 *device)
hr = IDirect3DDevice9_EndScene(device);
ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %08x\n", hr);
}
- hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
- ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %08x\n", hr);
color = getPixelColor(device, 240, 320);
ok(color == 0x0000ffff, "R32F with value 0.0 has color %08x, expected 0x0000ffff\n", color);
@@ -3854,9 +3868,12 @@ static void float_texture_test(IDirect3DDevice9 *device)
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
-out:
- if(texture) IDirect3DTexture9_Release(texture);
+ IDirect3DTexture9_Release(texture);
+ refcount = IDirect3DDevice9_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+done:
IDirect3D9_Release(d3d);
+ DestroyWindow(window);
}
static void g16r16_texture_test(void)
@@ -16606,11 +16623,11 @@ START_TEST(visual)
shademode_test(device_ptr);
srgbtexture_test(device_ptr);
release_buffer_test(device_ptr);
- float_texture_test(device_ptr);
cleanup_device(device_ptr);
device_ptr = NULL;
+ float_texture_test();
g16r16_texture_test();
pixelshader_blending_test();
texture_transform_flags_test();
More information about the wine-cvs
mailing list