mirror of
https://github.com/reactos/wine.git
synced 2024-11-28 22:20:26 +00:00
d3d9/tests: d3d9ex video memory accounting tests.
This commit is contained in:
parent
10929cbe43
commit
30e9a37bbb
@ -908,6 +908,54 @@ done:
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_vidmem_accounting(void)
|
||||
{
|
||||
IDirect3DDevice9Ex *device;
|
||||
unsigned int i;
|
||||
HWND window;
|
||||
HRESULT hr = D3D_OK;
|
||||
ULONG ref;
|
||||
UINT vidmem_start, vidmem_end;
|
||||
INT diff;
|
||||
IDirect3DTexture9 *textures[20];
|
||||
|
||||
window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, 640, 480, 0, 0, 0, 0);
|
||||
if (!(device = create_device(window, window, TRUE)))
|
||||
{
|
||||
skip("Failed to create a D3D device, skipping tests.\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
vidmem_start = IDirect3DDevice9_GetAvailableTextureMem(device);
|
||||
memset(textures, 0, sizeof(textures));
|
||||
for (i = 0; i < 20 && SUCCEEDED(hr); i++)
|
||||
{
|
||||
hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 1, D3DUSAGE_RENDERTARGET,
|
||||
D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &textures[i], NULL);
|
||||
/* No D3DERR_OUTOFVIDEOMEMORY in d3d9ex */
|
||||
ok(SUCCEEDED(hr) || hr == E_OUTOFMEMORY, "Failed to create texture, hr %#x.\n", hr);
|
||||
}
|
||||
vidmem_end = IDirect3DDevice9_GetAvailableTextureMem(device);
|
||||
|
||||
diff = vidmem_start - vidmem_end;
|
||||
diff = abs(diff);
|
||||
ok(diff < 1024 * 1024, "Expected a video memory difference of less than 1 MB, got %u MB.\n",
|
||||
diff / 1024 / 1024);
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
if (textures[i])
|
||||
IDirect3DTexture9_Release(textures[i]);
|
||||
}
|
||||
|
||||
ref = IDirect3DDevice9_Release(device);
|
||||
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
|
||||
|
||||
done:
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(d3d9ex)
|
||||
{
|
||||
d3d9_handle = LoadLibraryA("d3d9.dll");
|
||||
@ -935,4 +983,5 @@ START_TEST(d3d9ex)
|
||||
test_texture_sysmem_create();
|
||||
test_reset();
|
||||
test_reset_resources();
|
||||
test_vidmem_accounting();
|
||||
}
|
||||
|
@ -6396,6 +6396,63 @@ done:
|
||||
|
||||
}
|
||||
|
||||
static void test_vidmem_accounting(void)
|
||||
{
|
||||
IDirect3DDevice9 *device;
|
||||
IDirect3D9 *d3d9;
|
||||
ULONG refcount;
|
||||
HWND window;
|
||||
HRESULT hr = D3D_OK;
|
||||
IDirect3DTexture9 *textures[20];
|
||||
unsigned int i;
|
||||
UINT vidmem_start, vidmem_end, diff;
|
||||
|
||||
if (!(d3d9 = pDirect3DCreate9(D3D_SDK_VERSION)))
|
||||
{
|
||||
skip("Failed to create IDirect3D9 object, skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, 640, 480, 0, 0, 0, 0);
|
||||
if (!(device = create_device(d3d9, window, window, TRUE)))
|
||||
{
|
||||
skip("Failed to create a D3D device, skipping tests.\n");
|
||||
IDirect3D9_Release(d3d9);
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
|
||||
vidmem_start = IDirect3DDevice9_GetAvailableTextureMem(device);
|
||||
memset(textures, 0, sizeof(textures));
|
||||
for (i = 0; i < sizeof(textures) / sizeof(*textures) && SUCCEEDED(hr); i++)
|
||||
{
|
||||
hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 1, D3DUSAGE_RENDERTARGET,
|
||||
D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &textures[i], NULL);
|
||||
/* D3DERR_OUTOFVIDEOMEMORY is returned when the card runs out of video memory
|
||||
* E_FAIL is returned on address space or system memory exhaustion */
|
||||
ok(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY,
|
||||
"Failed to create texture, hr %#x.\n", hr);
|
||||
}
|
||||
vidmem_end = IDirect3DDevice9_GetAvailableTextureMem(device);
|
||||
|
||||
ok(vidmem_start > vidmem_end, "Expected available texture memory to decrease during texture creation.\n");
|
||||
diff = vidmem_start - vidmem_end;
|
||||
ok(diff > 1024 * 1024 * 2 * i, "Expected a video memory difference of at least %u MB, got %u MB.\n",
|
||||
2 * i, diff / 1024 / 1024);
|
||||
|
||||
for (i = 0; i < sizeof(textures) / sizeof(*textures); i++)
|
||||
{
|
||||
if (textures[i])
|
||||
IDirect3DTexture9_Release(textures[i]);
|
||||
}
|
||||
|
||||
refcount = IDirect3DDevice9_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
IDirect3D9_Release(d3d9);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(device)
|
||||
{
|
||||
HMODULE d3d9_handle = LoadLibraryA( "d3d9.dll" );
|
||||
@ -6485,6 +6542,7 @@ START_TEST(device)
|
||||
test_swvp_buffer();
|
||||
test_rtpatch();
|
||||
test_npot_textures();
|
||||
test_vidmem_accounting();
|
||||
}
|
||||
|
||||
out:
|
||||
|
Loading…
Reference in New Issue
Block a user