Module: wine Branch: master Commit: 87fe9779ec91937211dc26c3a30c8ac93b8a0720 URL: http://source.winehq.org/git/wine.git/?a=commit;h=87fe9779ec91937211dc26c3a3...
Author: Akihiro Sagawa sagawa.aki@gmail.com Date: Sat Feb 4 19:56:53 2017 +0900
d3d9/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
---
dlls/d3d9/tests/visual.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 601461f..824e2de 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -17290,8 +17290,10 @@ static void add_dirty_rect_test_draw(IDirect3DDevice9 *device) static void add_dirty_rect_test(void) { HRESULT hr; - IDirect3DTexture9 *tex_dst1, *tex_dst2, *tex_src_red, *tex_src_green, *tex_managed; - IDirect3DSurface9 *surface_dst2, *surface_src_green, *surface_src_red, *surface_managed; + IDirect3DTexture9 *tex_dst1, *tex_dst2, *tex_src_red, *tex_src_green, + *tex_managed, *tex_dynamic; + IDirect3DSurface9 *surface_dst2, *surface_src_green, *surface_src_red, + *surface_managed, *surface_dynamic; IDirect3DDevice9 *device; IDirect3D9 *d3d; unsigned int i; @@ -17328,6 +17330,9 @@ static void add_dirty_rect_test(void) hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &tex_managed, NULL); ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, D3DUSAGE_DYNAMIC, + D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &tex_dynamic, NULL); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = IDirect3DTexture9_GetSurfaceLevel(tex_dst2, 0, &surface_dst2); ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); @@ -17337,6 +17342,8 @@ static void add_dirty_rect_test(void) ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); hr = IDirect3DTexture9_GetSurfaceLevel(tex_managed, 0, &surface_managed); ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + hr = IDirect3DTexture9_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); @@ -17529,6 +17536,7 @@ static void add_dirty_rect_test(void) hr = IDirect3DDevice9_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 = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)tex_managed); ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr); @@ -17563,7 +17571,6 @@ static void add_dirty_rect_test(void)
/* So does EvictManagedResources. */ fill_surface(surface_managed, 0x000000ff, D3DLOCK_NO_DIRTY_UPDATE); - ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr); hr = IDirect3DDevice9_EvictManagedResources(device); ok(SUCCEEDED(hr), "Failed to evict managed resources, hr %#x.\n", hr); add_dirty_rect_test_draw(device); @@ -17573,6 +17580,26 @@ static void add_dirty_rect_test(void) hr = IDirect3DDevice9_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 = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)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 = IDirect3DDevice9_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 = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr); + /* AddDirtyRect on a locked texture is allowed. */ hr = IDirect3DTexture9_LockRect(tex_src_red, 0, &locked_rect, NULL, 0); ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr); @@ -17595,11 +17622,13 @@ static void add_dirty_rect_test(void) IDirect3DSurface9_Release(surface_managed); IDirect3DSurface9_Release(surface_src_red); IDirect3DSurface9_Release(surface_src_green); + IDirect3DSurface9_Release(surface_dynamic); IDirect3DTexture9_Release(tex_src_red); IDirect3DTexture9_Release(tex_src_green); IDirect3DTexture9_Release(tex_dst1); IDirect3DTexture9_Release(tex_dst2); IDirect3DTexture9_Release(tex_managed); + IDirect3DTexture9_Release(tex_dynamic); refcount = IDirect3DDevice9_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); IDirect3D9_Release(d3d);