Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3d9/tests/visual.c | 301 ++++++++++++++++----------------------- 1 file changed, 121 insertions(+), 180 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 0e71e23018..3eb29d0e92 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -3828,16 +3828,17 @@ static void fill_surface(IDirect3DSurface9 *surface, DWORD color, DWORD flags)
static void stretchrect_test(void) { - IDirect3DSurface9 *surf_tex_rt32, *surf_tex_rt64, *surf_tex_rt_dest64, *surf_tex_rt_dest640_480; - IDirect3DSurface9 *surf_offscreen32, *surf_offscreen64, *surf_offscreen_dest64; + static IDirect3DSurface9 *surf_tex_rt32, *surf_tex_rt64, *surf_tex_rt_dest64, *surf_tex_rt_dest640_480; + static IDirect3DSurface9 *surf_offscreen32, *surf_offscreen64, *surf_offscreen_dest64; IDirect3DTexture9 *tex_rt32, *tex_rt64, *tex_rt_dest64, *tex_rt_dest640_480; - IDirect3DSurface9 *surf_tex32, *surf_tex64, *surf_tex_dest64; - IDirect3DSurface9 *surf_rt32, *surf_rt64, *surf_rt_dest64; + static IDirect3DSurface9 *surf_tex32, *surf_tex64, *surf_tex_dest64; + static IDirect3DSurface9 *surf_rt32, *surf_rt64, *surf_rt_dest64; IDirect3DTexture9 *tex32, *tex64, *tex_dest64; IDirect3DSurface9 *surf_temp32, *surf_temp64; - IDirect3DSurface9 *backbuffer; + static IDirect3DSurface9 *backbuffer; IDirect3DDevice9 *device; IDirect3D9 *d3d; + unsigned int i; D3DCOLOR color; ULONG refcount; HWND window; @@ -3852,6 +3853,75 @@ static void stretchrect_test(void) static const RECT dst_rect64 = {0, 0, 64, 64}; static const RECT dst_rect64_flipy = {0, 64, 64, 0};
+ static const struct error_condition_test + { + IDirect3DSurface9 **src; + const RECT *src_rect; + IDirect3DSurface9 **dst; + const RECT *dst_rect; + D3DTEXTUREFILTERTYPE filter; + BOOL allowed; + BOOL todo; + } + error_condition_tests[] = + { + {&surf_offscreen64, &src_rect64_flipy, &surf_offscreen_dest64, &dst_rect64, D3DTEXF_NONE,}, + {&surf_offscreen64, &src_rect64, &surf_offscreen_dest64, &dst_rect64_flipy, D3DTEXF_NONE,}, + {&surf_offscreen64, &src_rect64_flipy, &surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE,}, + {&surf_offscreen64, &src_rect64, &surf_tex_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE,}, + {&surf_offscreen64, &src_rect64_flipy, &surf_rt_dest64, &dst_rect64, D3DTEXF_NONE,}, + {&surf_offscreen64, &src_rect64, &surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE,}, + {&surf_offscreen64, NULL, &surf_tex_dest64, NULL, D3DTEXF_NONE}, + {&surf_offscreen32, NULL, &surf_offscreen64, NULL, D3DTEXF_NONE, FALSE, TRUE}, + {&surf_offscreen32, NULL, &surf_tex_dest64, NULL, D3DTEXF_NONE}, + {&surf_tex64, NULL, &surf_offscreen64, NULL, D3DTEXF_NONE, FALSE, TRUE}, + {&surf_tex64, &src_rect64_flipy, &surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE}, + {&surf_tex64, &src_rect64, &surf_tex_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE}, + {&surf_tex64, &src_rect64_flipy, &surf_rt_dest64, &dst_rect64, D3DTEXF_NONE}, + {&surf_tex64, &src_rect64, &surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE}, + {&surf_tex64, NULL, &surf_tex_dest64, NULL, D3DTEXF_NONE}, + {&surf_tex32, NULL, &surf_offscreen64, NULL, D3DTEXF_NONE, FALSE, TRUE}, + {&surf_tex32, NULL, &surf_tex_dest64, NULL, D3DTEXF_NONE}, + {&surf_tex_rt64, NULL, &surf_offscreen64, NULL, D3DTEXF_NONE, FALSE, TRUE}, + {&surf_tex_rt64, &src_rect64_flipy, &surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE}, + {&surf_tex_rt64, &src_rect64, &surf_tex_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE}, + {&surf_tex_rt64, &src_rect64_flipy, &surf_rt_dest64, &dst_rect64, D3DTEXF_NONE}, + {&surf_tex_rt64, &src_rect64, &surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE}, + {&surf_tex_rt64, NULL, &surf_tex_dest64, NULL, D3DTEXF_NONE}, + {&surf_tex_rt32, NULL, &surf_offscreen64, NULL, D3DTEXF_NONE, FALSE, TRUE}, + {&surf_tex_rt32, NULL, &surf_tex_dest64, NULL, D3DTEXF_NONE}, + {&surf_rt64, NULL, &surf_offscreen64, NULL, D3DTEXF_NONE, FALSE, TRUE}, + {&surf_rt64, &src_rect64_flipy, &surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE}, + {&surf_rt64, &src_rect64, &surf_tex_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE}, + {&surf_rt64, &src_rect64_flipy, &surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE}, + {&surf_rt64, &src_rect64, &surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE}, + {&surf_rt64, NULL, &surf_tex_dest64, NULL, D3DTEXF_NONE}, + {&surf_rt32, NULL, &surf_offscreen64, NULL, D3DTEXF_NONE, FALSE, TRUE}, + {&surf_rt32, NULL, &surf_tex_dest64, NULL, D3DTEXF_NONE}, + {&backbuffer, &src_rect_flipy, &surf_tex_rt_dest640_480, &dst_rect, D3DTEXF_NONE}, + {&backbuffer, &src_rect, &surf_tex_rt_dest640_480, &dst_rect_flipy, D3DTEXF_NONE}, + /* Test filter. */ + {&surf_offscreen64, NULL, &surf_offscreen_dest64, NULL, D3DTEXF_NONE, TRUE}, + {&surf_offscreen64, NULL, &surf_offscreen_dest64, NULL, D3DTEXF_ANISOTROPIC, FALSE, TRUE}, + {&surf_offscreen32, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_NONE, TRUE}, + {&surf_offscreen32, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_ANISOTROPIC, FALSE, TRUE}, + {&surf_offscreen64, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_ANISOTROPIC, FALSE, TRUE}, + {&surf_offscreen64, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_PYRAMIDALQUAD, FALSE, TRUE}, + {&surf_offscreen64, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_GAUSSIANQUAD, FALSE, TRUE}, + {&surf_offscreen64, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_ANISOTROPIC, FALSE, TRUE}, + {&surf_offscreen64, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_CONVOLUTIONMONO, FALSE, TRUE}, + {&surf_offscreen64, NULL, &surf_tex_rt_dest64, NULL, 0xbadf, FALSE, TRUE}, + {&surf_tex64, NULL, &surf_rt_dest64, NULL, D3DTEXF_NONE, TRUE}, + {&surf_tex64, NULL, &surf_rt_dest64, NULL, D3DTEXF_ANISOTROPIC, FALSE, TRUE}, + {&surf_rt64, NULL, &surf_rt_dest64, NULL, D3DTEXF_ANISOTROPIC, FALSE, TRUE}, + {&surf_tex_rt64, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_NONE, TRUE}, + {&surf_tex_rt64, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_ANISOTROPIC, FALSE, TRUE}, + {&surf_rt64, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_NONE, TRUE}, + {&surf_rt64, NULL, &surf_tex_rt_dest64, NULL, D3DTEXF_ANISOTROPIC, FALSE, TRUE}, + {&backbuffer, NULL, &surf_tex_rt_dest640_480, NULL, D3DTEXF_NONE, TRUE}, + {&backbuffer, NULL, &surf_tex_rt_dest640_480, NULL, D3DTEXF_ANISOTROPIC, FALSE, TRUE}, + }; + window = create_window(); d3d = Direct3DCreate9(D3D_SDK_VERSION); ok(!!d3d, "Failed to create a D3D object.\n"); @@ -3864,70 +3934,70 @@ static void stretchrect_test(void) /* Create our temporary surfaces in system memory. */ hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surf_temp32, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surf_temp64, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* Create offscreen plain surfaces in D3DPOOL_DEFAULT. */ hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surf_offscreen32, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surf_offscreen64, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 64, 64, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surf_offscreen_dest64, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* Create render target surfaces. */ hr = IDirect3DDevice9_CreateRenderTarget(device, 32, 32, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &surf_rt32, NULL ); - ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateRenderTarget(device, 64, 64, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &surf_rt64, NULL ); - ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateRenderTarget(device, 64, 64, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &surf_rt_dest64, NULL ); - ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer); - ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* Create render target textures. */ hr = IDirect3DDevice9_CreateTexture(device, 32, 32, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_rt32, NULL); - ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_rt64, NULL); - ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_rt_dest64, NULL); - ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_rt_dest640_480, NULL); - ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DTexture9_GetSurfaceLevel(tex_rt32, 0, &surf_tex_rt32); - ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DTexture9_GetSurfaceLevel(tex_rt64, 0, &surf_tex_rt64); - ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DTexture9_GetSurfaceLevel(tex_rt_dest64, 0, &surf_tex_rt_dest64); - ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DTexture9_GetSurfaceLevel(tex_rt_dest640_480, 0, &surf_tex_rt_dest640_480); - ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* Create regular textures in D3DPOOL_DEFAULT. */ hr = IDirect3DDevice9_CreateTexture(device, 32, 32, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex32, NULL); - ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex64, NULL); - ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_CreateTexture(device, 64, 64, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex_dest64, NULL); - ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DTexture9_GetSurfaceLevel(tex32, 0, &surf_tex32); - ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DTexture9_GetSurfaceLevel(tex64, 0, &surf_tex64); - ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DTexture9_GetSurfaceLevel(tex_dest64, 0, &surf_tex_dest64); - ok(SUCCEEDED(hr), "Failed to get surface level, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/********************************************************************** * Tests for when the source parameter is an offscreen plain surface. * @@ -3945,35 +4015,19 @@ static void stretchrect_test(void) hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, &src_rect64, surf_offscreen_dest64, &dst_rect64, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, &src_rect64_flipy, - surf_offscreen_dest64, &dst_rect64, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, &src_rect64, - surf_offscreen_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* offscreenplain ==> rendertarget texture, same size. */ hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, NULL, surf_tex_rt_dest64, NULL, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); /* We can't lock rendertarget textures, so copy to our temp surface first. */ hr = IDirect3DDevice9_GetRenderTargetData(device, surf_tex_rt_dest64, surf_temp64); - ok(SUCCEEDED(hr), "Failed to get render target data, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); color = getPixelColorFromSurface(surf_temp64, 32, 32); ok(color == 0xff00ff00, "Got unexpected color 0x%08x.\n", color); /* Blit without scaling. */ hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, &src_rect64, surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, &src_rect64_flipy, - surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, &src_rect64, - surf_tex_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* offscreenplain ==> rendertarget surface, same size. */ hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, NULL, surf_rt_dest64, NULL, D3DTEXF_NONE); @@ -3984,32 +4038,16 @@ static void stretchrect_test(void) hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, &src_rect64, surf_rt_dest64, &dst_rect64, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, &src_rect64_flipy, - surf_rt_dest64, &dst_rect64, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, &src_rect64, - surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - - /* offscreenplain ==> texture, same size (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_offscreen64, NULL, surf_tex_dest64, NULL, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* Fill the smaller offscreen surface with red. */ fill_surface(surf_offscreen32, 0xffff0000, 0);
- /* offscreenplain ==> offscreenplain, scaling (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_offscreen32, NULL, surf_offscreen64, NULL, D3DTEXF_NONE); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* offscreenplain ==> rendertarget texture, scaling. */ hr = IDirect3DDevice9_StretchRect(device, surf_offscreen32, NULL, surf_tex_rt_dest64, NULL, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); /* We can't lock rendertarget textures, so copy to our temp surface first. */ hr = IDirect3DDevice9_GetRenderTargetData(device, surf_tex_rt_dest64, surf_temp64); - ok(SUCCEEDED(hr), "Failed to get render target data, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); color = getPixelColorFromSurface(surf_temp64, 48, 48); ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
@@ -4019,10 +4057,6 @@ static void stretchrect_test(void) color = getPixelColorFromSurface(surf_rt_dest64, 48, 48); ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
- /* offscreenplain ==> texture, scaling (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_offscreen32, NULL, surf_tex_dest64, NULL, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /************************************************************* * Tests for when the source parameter is a regular texture. * *************************************************************/ @@ -4031,32 +4065,20 @@ static void stretchrect_test(void) /* Can't fill the surf_tex directly because it's created in D3DPOOL_DEFAULT. */ fill_surface(surf_temp64, 0xff0000ff, 0); hr = IDirect3DDevice9_UpdateSurface(device, surf_temp64, NULL, surf_tex64, NULL); - ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr); - - /* texture ==> offscreenplain, same size. */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex64, NULL, surf_offscreen64, NULL, D3DTEXF_NONE); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* texture ==> rendertarget texture, same size. */ hr = IDirect3DDevice9_StretchRect(device, surf_tex64, NULL, surf_tex_rt_dest64, NULL, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); /* We can't lock rendertarget textures, so copy to our temp surface first. */ hr = IDirect3DDevice9_GetRenderTargetData(device, surf_tex_rt_dest64, surf_temp64); - ok(SUCCEEDED(hr), "Failed to get render target data, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); color = getPixelColorFromSurface(surf_temp64, 32, 32); ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color); /* Blit without scaling. */ hr = IDirect3DDevice9_StretchRect(device, surf_tex64, &src_rect64, surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex64, &src_rect64_flipy, - surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex64, &src_rect64, - surf_tex_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* texture ==> rendertarget surface, same size. */ hr = IDirect3DDevice9_StretchRect(device, surf_tex64, NULL, surf_rt_dest64, NULL, D3DTEXF_NONE); @@ -4067,35 +4089,19 @@ static void stretchrect_test(void) hr = IDirect3DDevice9_StretchRect(device, surf_tex64, &src_rect64, surf_rt_dest64, &dst_rect64, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex64, &src_rect64_flipy, - surf_rt_dest64, &dst_rect64, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex64, &src_rect64, - surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - - /* texture ==> texture, same size (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex64, NULL, surf_tex_dest64, NULL, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* Fill the surface of the smaller regular texture with red. */ /* Can't fill the surf_tex directly because it's created in D3DPOOL_DEFAULT. */ fill_surface(surf_temp32, 0xffff0000, 0); hr = IDirect3DDevice9_UpdateSurface(device, surf_temp32, NULL, surf_tex32, NULL); - ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr); - - /* texture ==> offscreenplain, scaling (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex32, NULL, surf_offscreen64, NULL, D3DTEXF_NONE); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* texture ==> rendertarget texture, scaling. */ hr = IDirect3DDevice9_StretchRect(device, surf_tex32, NULL, surf_tex_rt_dest64, NULL, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); /* We can't lock rendertarget textures, so copy to our temp surface first. */ hr = IDirect3DDevice9_GetRenderTargetData(device, surf_tex_rt_dest64, surf_temp64); - ok(SUCCEEDED(hr), "Failed to get render target data, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); color = getPixelColorFromSurface(surf_temp64, 48, 48); ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
@@ -4105,10 +4111,6 @@ static void stretchrect_test(void) color = getPixelColorFromSurface(surf_rt_dest64, 48, 48); ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
- /* texture ==> texture, scaling (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex32, NULL, surf_tex_dest64, NULL, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /****************************************************************** * Tests for when the source parameter is a rendertarget texture. * ******************************************************************/ @@ -4117,32 +4119,20 @@ static void stretchrect_test(void) /* Can't fill the surf_tex_rt directly because it's created in D3DPOOL_DEFAULT. */ fill_surface(surf_temp64, 0xffffffff, 0); hr = IDirect3DDevice9_UpdateSurface(device, surf_temp64, NULL, surf_tex_rt64, NULL); - ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr); - - /* rendertarget texture ==> offscreenplain, same size. */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, NULL, surf_offscreen64, NULL, D3DTEXF_NONE); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* rendertarget texture ==> rendertarget texture, same size. */ hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, NULL, surf_tex_rt_dest64, NULL, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); /* We can't lock rendertarget textures, so copy to our temp surface first. */ hr = IDirect3DDevice9_GetRenderTargetData(device, surf_tex_rt_dest64, surf_temp64); - ok(SUCCEEDED(hr), "Failed to get render target data, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); color = getPixelColorFromSurface(surf_temp64, 32, 32); ok(color == 0xffffffff, "Got unexpected color 0x%08x.\n", color); /* Blit without scaling. */ hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, &src_rect64, surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, &src_rect64_flipy, - surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, &src_rect64, - surf_tex_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* rendertarget texture ==> rendertarget surface, same size. */ hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, NULL, surf_rt_dest64, NULL, D3DTEXF_NONE); @@ -4153,35 +4143,19 @@ static void stretchrect_test(void) hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, &src_rect64, surf_rt_dest64, &dst_rect64, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, &src_rect64_flipy, - surf_rt_dest64, &dst_rect64, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, &src_rect64, - surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - - /* rendertarget texture ==> texture, same size (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt64, NULL, surf_tex_dest64, NULL, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* Fill the surface of the smaller rendertarget texture with red. */ /* Can't fill the surf_tex_rt directly because it's created in D3DPOOL_DEFAULT. */ fill_surface(surf_temp32, 0xffff0000, 0); hr = IDirect3DDevice9_UpdateSurface(device, surf_temp32, NULL, surf_tex_rt32, NULL); - ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr); - - /* rendertarget texture ==> offscreenplain, scaling (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt32, NULL, surf_offscreen64, NULL, D3DTEXF_NONE); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* rendertarget texture ==> rendertarget texture, scaling. */ hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt32, NULL, surf_tex_rt_dest64, NULL, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); /* We can't lock rendertarget textures, so copy to our temp surface first. */ hr = IDirect3DDevice9_GetRenderTargetData(device, surf_tex_rt_dest64, surf_temp64); - ok(SUCCEEDED(hr), "Failed to get render target data, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); color = getPixelColorFromSurface(surf_temp64, 48, 48); ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
@@ -4191,10 +4165,6 @@ static void stretchrect_test(void) color = getPixelColorFromSurface(surf_rt_dest64, 48, 48); ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
- /* rendertarget texture ==> texture, scaling (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_tex_rt32, NULL, surf_tex_dest64, NULL, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /****************************************************************** * Tests for when the source parameter is a rendertarget surface. * ******************************************************************/ @@ -4202,30 +4172,18 @@ static void stretchrect_test(void) /* Fill the surface of the rendertarget surface with black. */ fill_surface(surf_rt64, 0xff000000, 0);
- /* rendertarget texture ==> offscreenplain, same size. */ - hr = IDirect3DDevice9_StretchRect(device, surf_rt64, NULL, surf_offscreen64, NULL, D3DTEXF_NONE); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* rendertarget surface ==> rendertarget texture, same size. */ hr = IDirect3DDevice9_StretchRect(device, surf_rt64, NULL, surf_tex_rt_dest64, NULL, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); /* We can't lock rendertarget textures, so copy to our temp surface first. */ hr = IDirect3DDevice9_GetRenderTargetData(device, surf_tex_rt_dest64, surf_temp64); - ok(SUCCEEDED(hr), "Failed to get render target data, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); color = getPixelColorFromSurface(surf_temp64, 32, 32); ok(color == 0xff000000, "Got unexpected color 0x%08x.\n", color); /* Blit without scaling. */ hr = IDirect3DDevice9_StretchRect(device, surf_rt64, &src_rect64, surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_rt64, &src_rect64_flipy, - surf_tex_rt_dest64, &dst_rect64, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_rt64, &src_rect64, - surf_tex_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* rendertarget surface ==> rendertarget surface, same size. */ hr = IDirect3DDevice9_StretchRect(device, surf_rt64, NULL, surf_rt_dest64, NULL, D3DTEXF_NONE); @@ -4236,32 +4194,16 @@ static void stretchrect_test(void) hr = IDirect3DDevice9_StretchRect(device, surf_rt64, &src_rect64, surf_rt_dest64, &dst_rect64, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_rt64, &src_rect64_flipy, - surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, surf_rt64, &src_rect64, - surf_rt_dest64, &dst_rect64_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - - /* rendertarget surface ==> texture, same size (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_rt64, NULL, surf_tex_dest64, NULL, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
/* Fill the surface of the smaller rendertarget texture with red. */ fill_surface(surf_rt32, 0xffff0000, 0);
- /* rendertarget surface ==> offscreenplain, scaling (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_rt32, NULL, surf_offscreen64, NULL, D3DTEXF_NONE); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* rendertarget surface ==> rendertarget texture, scaling. */ hr = IDirect3DDevice9_StretchRect(device, surf_rt32, NULL, surf_tex_rt_dest64, NULL, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); /* We can't lock rendertarget textures, so copy to our temp surface first. */ hr = IDirect3DDevice9_GetRenderTargetData(device, surf_tex_rt_dest64, surf_temp64); - ok(SUCCEEDED(hr), "Failed to get render target data, hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); color = getPixelColorFromSurface(surf_temp64, 48, 48); ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
@@ -4271,10 +4213,6 @@ static void stretchrect_test(void) color = getPixelColorFromSurface(surf_rt_dest64, 48, 48); ok(color == 0xffff0000, "Got unexpected color 0x%08x.\n", color);
- /* rendertarget surface ==> texture, scaling (should fail). */ - hr = IDirect3DDevice9_StretchRect(device, surf_rt32, NULL, surf_tex_dest64, NULL, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* backbuffer ==> surface tests (no scaling). */ /* Blit with NULL rectangles. */ hr = IDirect3DDevice9_StretchRect(device, backbuffer, NULL, surf_tex_rt_dest640_480, NULL, D3DTEXF_NONE); @@ -4283,14 +4221,17 @@ static void stretchrect_test(void) hr = IDirect3DDevice9_StretchRect(device, backbuffer, &src_rect, surf_tex_rt_dest640_480, &dst_rect, D3DTEXF_NONE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through src_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, backbuffer, &src_rect_flipy, - surf_tex_rt_dest640_480, &dst_rect, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); - /* Flipping in y-direction through dst_rect, no scaling (not allowed). */ - hr = IDirect3DDevice9_StretchRect(device, backbuffer, &src_rect, - surf_tex_rt_dest640_480, &dst_rect_flipy, D3DTEXF_NONE); - ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + + /* Test error conditions. */ + for (i = 0; i < ARRAY_SIZE(error_condition_tests); ++i) + { + const struct error_condition_test *test = &error_condition_tests[i]; + + hr = IDirect3DDevice9_StretchRect(device, *test->src, test->src_rect, *test->dst, + test->dst_rect, test->filter); + todo_wine_if(test->todo) + ok(hr == test->allowed ? D3D_OK : D3DERR_INVALIDCALL, "Test %u, got unexpected hr %#x.\n", i, hr); + }
/* TODO: Test format conversions. */