d3d8/tests: Add LockRect tests with dynamic textures.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2017-02-04 19:56:55 +09:00 committed by Alexandre Julliard
parent 87fe9779ec
commit 49f9e545fb
1 changed files with 32 additions and 3 deletions

View File

@ -5216,8 +5216,10 @@ static void add_dirty_rect_test_draw(IDirect3DDevice8 *device)
static void add_dirty_rect_test(void)
{
IDirect3DSurface8 *surface_dst2, *surface_src_green, *surface_src_red, *surface_managed;
IDirect3DTexture8 *tex_dst1, *tex_dst2, *tex_src_red, *tex_src_green, *tex_managed;
IDirect3DTexture8 *tex_dst1, *tex_dst2, *tex_src_red, *tex_src_green,
*tex_managed, *tex_dynamic;
IDirect3DSurface8 *surface_dst2, *surface_src_green, *surface_src_red,
*surface_managed, *surface_dynamic;
D3DLOCKED_RECT locked_rect;
IDirect3DDevice8 *device;
IDirect3D8 *d3d;
@ -5254,6 +5256,9 @@ static void add_dirty_rect_test(void)
hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8,
D3DPOOL_MANAGED, &tex_managed);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, D3DUSAGE_DYNAMIC,
D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &tex_dynamic);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = IDirect3DTexture8_GetSurfaceLevel(tex_dst2, 0, &surface_dst2);
ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
@ -5263,6 +5268,8 @@ static void add_dirty_rect_test(void)
ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
hr = IDirect3DTexture8_GetSurfaceLevel(tex_managed, 0, &surface_managed);
ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
hr = IDirect3DTexture8_GetSurfaceLevel(tex_dynamic, 0, &surface_dynamic);
ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr);
fill_surface(surface_src_red, 0x00ff0000, 0);
fill_surface(surface_src_green, 0x0000ff00, 0);
@ -5455,6 +5462,7 @@ static void add_dirty_rect_test(void)
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
/* Tests with managed textures. */
fill_surface(surface_managed, 0x00ff0000, 0);
hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)tex_managed);
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
@ -5489,7 +5497,6 @@ static void add_dirty_rect_test(void)
/* So does ResourceManagerDiscardBytes. */
fill_surface(surface_managed, 0x000000ff, D3DLOCK_NO_DIRTY_UPDATE);
ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
hr = IDirect3DDevice8_ResourceManagerDiscardBytes(device, 0);
ok(SUCCEEDED(hr), "Failed to evict managed resources, hr %#x.\n", hr);
add_dirty_rect_test_draw(device);
@ -5499,6 +5506,26 @@ static void add_dirty_rect_test(void)
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
/* Tests with dynamic textures */
fill_surface(surface_dynamic, 0x0000ffff, 0);
hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)tex_dynamic);
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
add_dirty_rect_test_draw(device);
color = getPixelColor(device, 320, 240);
ok(color_match(color, 0x0000ffff, 1),
"Expected color 0x0000ffff, got 0x%08x.\n", color);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
/* Dynamic textures don't honor D3DLOCK_NO_DIRTY_UPDATE. */
fill_surface(surface_dynamic, 0x00ffff00, D3DLOCK_NO_DIRTY_UPDATE);
add_dirty_rect_test_draw(device);
color = getPixelColor(device, 320, 240);
todo_wine ok(color_match(color, 0x00ffff00, 1),
"Expected color 0x00ffff00, got 0x%08x.\n", color);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
/* AddDirtyRect on a locked texture is allowed. */
hr = IDirect3DTexture8_LockRect(tex_src_red, 0, &locked_rect, NULL, 0);
ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
@ -5517,11 +5544,13 @@ static void add_dirty_rect_test(void)
IDirect3DSurface8_Release(surface_managed);
IDirect3DSurface8_Release(surface_src_red);
IDirect3DSurface8_Release(surface_src_green);
IDirect3DSurface8_Release(surface_dynamic);
IDirect3DTexture8_Release(tex_src_red);
IDirect3DTexture8_Release(tex_src_green);
IDirect3DTexture8_Release(tex_dst1);
IDirect3DTexture8_Release(tex_dst2);
IDirect3DTexture8_Release(tex_managed);
IDirect3DTexture8_Release(tex_dynamic);
refcount = IDirect3DDevice8_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
done: