diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c index 283f6e6dd2f..c857e53114a 100644 --- a/dlls/d3d9/tests/d3d9ex.c +++ b/dlls/d3d9/tests/d3d9ex.c @@ -1383,6 +1383,409 @@ cleanup: DestroyWindow(window); } +static void test_reset_ex(void) +{ + unsigned int height, orig_height = GetSystemMetrics(SM_CYSCREEN); + unsigned int width, orig_width = GetSystemMetrics(SM_CXSCREEN); + unsigned int i, adapter_mode_count, mode_count = 0; + D3DDISPLAYMODEEX mode, mode2, *modes; + D3DDISPLAYMODEFILTER mode_filter; + IDirect3DSwapChain9 *swapchain; + D3DPRESENT_PARAMETERS d3dpp; + IDirect3DDevice9Ex *device; + IDirect3D9Ex *d3d9; + DEVMODEW devmode; + D3DVIEWPORT9 vp; + ULONG refcount; + DWORD value; + HWND window; + HRESULT hr; + RECT rect; + LONG ret; + + window = create_window(); + if (!(device = create_device(window, NULL))) + { + skip("Failed to create a D3D device.\n"); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice9Ex_GetDirect3D(device, (IDirect3D9 **)&d3d9); + ok(SUCCEEDED(hr), "Failed to get d3d9, hr %#x.\n", hr); + + memset(&mode, 0, sizeof(mode)); + mode.Size = sizeof(mode); + hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9, D3DADAPTER_DEFAULT, &mode, NULL); + ok(SUCCEEDED(hr), "GetAdapterDisplayModeEx failed, hr %#x.\n", hr); + memset(&mode_filter, 0, sizeof(mode_filter)); + mode_filter.Size = sizeof(mode_filter); + mode_filter.Format = mode.Format; + adapter_mode_count = IDirect3D9Ex_GetAdapterModeCountEx(d3d9, D3DADAPTER_DEFAULT, &mode_filter); + modes = HeapAlloc(GetProcessHeap(), 0, sizeof(*modes) * adapter_mode_count); + for (i = 0; i < adapter_mode_count; ++i) + { + unsigned int j; + + memset(&mode2, 0, sizeof(mode)); + mode2.Size = sizeof(mode2); + hr = IDirect3D9Ex_EnumAdapterModesEx(d3d9, D3DADAPTER_DEFAULT, &mode_filter, i, &mode2); + ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr); + + for (j = 0; j < mode_count; ++j) + { + if (modes[j].Width == mode2.Width && modes[j].Height == mode2.Height) + break; + } + if (j == mode_count) + { + modes[j] = mode2; + ++mode_count; + } + } + + if (mode_count < 2) + { + skip("Less than 2 modes supported.\n"); + goto cleanup; + } + + i = 0; + if (modes[i].Width == orig_width && modes[i].Height == orig_height) + ++i; + + memset(&d3dpp, 0, sizeof(d3dpp)); + d3dpp.Windowed = FALSE; + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp.BackBufferWidth = modes[i].Width; + d3dpp.BackBufferHeight = modes[i].Height; + d3dpp.BackBufferFormat = modes[i].Format; + d3dpp.EnableAutoDepthStencil = TRUE; + d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; + modes[i].RefreshRate = 0; + modes[i].ScanLineOrdering = 0; + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, NULL); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]); + ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr); + hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); + ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr); + + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + ok(width == modes[i].Width, "Got screen width %u, expected %u.\n", width, modes[i].Width); + ok(height == modes[i].Height, "Got screen height %u, expected %u.\n", height, modes[i].Height); + + hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect); + ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr); + ok(rect.left == 0 && rect.top == 0 && rect.right == modes[i].Width && rect.bottom == modes[i].Height, + "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect)); + + hr = IDirect3DDevice9Ex_GetViewport(device, &vp); + ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr); + ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X); + ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y); + ok(vp.Width == modes[i].Width, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].Width); + ok(vp.Height == modes[i].Height, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].Height); + ok(vp.MinZ == 0.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ); + ok(vp.MaxZ == 1.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ); + + i = 1; + vp.X = 10; + vp.Y = 20; + vp.MinZ = 2.0f; + vp.MaxZ = 3.0f; + hr = IDirect3DDevice9Ex_SetViewport(device, &vp); + ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr); + + SetRect(&rect, 10, 20, 30, 40); + hr = IDirect3DDevice9Ex_SetScissorRect(device, &rect); + ok(SUCCEEDED(hr), "Failed to set scissor rect, hr %#x.\n", hr); + + hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value); + ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(!!value, "Got unexpected value %#x for D3DRS_LIGHTING.\n", value); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr); + + memset(&d3dpp, 0, sizeof(d3dpp)); + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp.Windowed = FALSE; + d3dpp.BackBufferWidth = modes[i].Width; + d3dpp.BackBufferHeight = modes[i].Height; + d3dpp.BackBufferFormat = modes[i].Format; + modes[i].RefreshRate = 0; + modes[i].ScanLineOrdering = 0; + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]); + ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr); + hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); + ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr); + + /* Render states are preserved in d3d9ex. */ + hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value); + ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(!value, "Got unexpected value %#x for D3DRS_LIGHTING.\n", value); + + hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect); + ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr); + ok(rect.left == 0 && rect.top == 0 && rect.right == modes[i].Width && rect.bottom == modes[i].Height, + "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect)); + + hr = IDirect3DDevice9Ex_GetViewport(device, &vp); + ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr); + ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X); + ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y); + ok(vp.Width == modes[i].Width, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].Width); + ok(vp.Height == modes[i].Height, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].Height); + ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ); + ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ); + + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + ok(width == modes[i].Width, "Got screen width %u, expected %u.\n", width, modes[i].Width); + ok(height == modes[i].Height, "Got screen height %u, expected %u.\n", height, modes[i].Height); + + hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain); + ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr); + hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp); + ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr); + ok(d3dpp.BackBufferWidth == modes[i].Width, "Got backbuffer width %u, expected %u.\n", + d3dpp.BackBufferWidth, modes[i].Width); + ok(d3dpp.BackBufferHeight == modes[i].Height, "Got backbuffer height %u, expected %u.\n", + d3dpp.BackBufferHeight, modes[i].Height); + IDirect3DSwapChain9_Release(swapchain); + + /* BackBufferWidth and BackBufferHeight have to match display mode. */ + memset(&d3dpp, 0, sizeof(d3dpp)); + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp.Windowed = FALSE; + d3dpp.BackBufferFormat = modes[i].Format; + d3dpp.BackBufferWidth = modes[i].Width - 10; + d3dpp.BackBufferHeight = modes[i].Height - 10; + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + d3dpp.BackBufferWidth = modes[i].Width - 1; + d3dpp.BackBufferHeight = modes[i].Height; + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + d3dpp.BackBufferWidth = modes[i].Width; + d3dpp.BackBufferHeight = modes[i].Height - 1; + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); + ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr); + + d3dpp.BackBufferWidth = modes[i].Width; + d3dpp.BackBufferHeight = modes[i].Height; + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &modes[i]); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); + ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr); + + hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect); + ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr); + ok(rect.left == 0 && rect.top == 0 && rect.right == modes[i].Width && rect.bottom == modes[i].Height, + "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect)); + + hr = IDirect3DDevice9Ex_GetViewport(device, &vp); + ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr); + ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X); + ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y); + ok(vp.Width == modes[i].Width, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].Width); + ok(vp.Height == modes[i].Height, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].Height); + ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ); + ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ); + + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + ok(width == modes[i].Width, "Got screen width %u, expected %u.\n", width, modes[i].Width); + ok(height == modes[i].Height, "Got screen height %u, expected %u.\n", height, modes[i].Height); + + hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain); + ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr); + hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp); + ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr); + ok(d3dpp.BackBufferWidth == modes[i].Width, "Got backbuffer width %u, expected %u.\n", + d3dpp.BackBufferWidth, modes[i].Width); + ok(d3dpp.BackBufferHeight == modes[i].Height, "Got backbuffer height %u, expected %u.\n", + d3dpp.BackBufferHeight, modes[i].Height); + IDirect3DSwapChain9_Release(swapchain); + + memset(&d3dpp, 0, sizeof(d3dpp)); + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp.Windowed = TRUE; + d3dpp.BackBufferWidth = 400; + d3dpp.BackBufferHeight = 300; + d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, NULL); + ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr); + hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); + ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr); + + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + ok(width == orig_width, "Got screen width %u, expected %u.\n", width, orig_width); + ok(height == orig_height, "Got screen height %u, expected %u.\n", height, orig_height); + + hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect); + ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr); + ok(rect.left == 0 && rect.top == 0 && rect.right == 400 && rect.bottom == 300, + "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect)); + + hr = IDirect3DDevice9Ex_GetViewport(device, &vp); + ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr); + ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X); + ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y); + ok(vp.Width == 400, "Got unexpected vp.Width %u.\n", vp.Width); + ok(vp.Height == 300, "Got unexpected vp.Height %u.\n", vp.Height); + ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ); + ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ); + + hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain); + ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr); + hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp); + ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr); + ok(d3dpp.BackBufferWidth == 400, "Got unexpected backbuffer width %u.\n", d3dpp.BackBufferWidth); + ok(d3dpp.BackBufferHeight == 300, "Got unexpected backbuffer height %u.\n", d3dpp.BackBufferHeight); + IDirect3DSwapChain9_Release(swapchain); + + memset(&devmode, 0, sizeof(devmode)); + devmode.dmSize = sizeof(devmode); + devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; + devmode.dmPelsWidth = modes[1].Width; + devmode.dmPelsHeight = modes[1].Height; + ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN); + ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret); + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + ok(width == modes[1].Width, "Screen width is %u, expected %u.\n", width, modes[1].Width); + ok(height == modes[1].Height, "Screen height is %u, expected %u.\n", height, modes[1].Height); + + d3dpp.BackBufferWidth = 500; + d3dpp.BackBufferHeight = 400; + d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, &mode); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, NULL); + ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr); + hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); + ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr); + + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + todo_wine ok(width == modes[1].Width, "Screen width is %u, expected %u.\n", width, modes[1].Width); + todo_wine ok(height == modes[1].Height, "Screen height is %u, expected %u.\n", height, modes[1].Height); + + hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect); + ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr); + ok(rect.left == 0 && rect.top == 0 && rect.right == 500 && rect.bottom == 400, + "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect)); + + hr = IDirect3DDevice9Ex_GetViewport(device, &vp); + ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr); + ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X); + ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y); + ok(vp.Width == 500, "Got unexpected vp.Width %u.\n", vp.Width); + ok(vp.Height == 400, "Got unexpected vp.Height %u.\n", vp.Height); + ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ); + ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ); + + hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain); + ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr); + memset(&d3dpp, 0, sizeof(d3dpp)); + hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp); + ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr); + ok(d3dpp.BackBufferWidth == 500, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth); + ok(d3dpp.BackBufferHeight == 400, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight); + IDirect3DSwapChain9_Release(swapchain); + + devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; + devmode.dmPelsWidth = orig_width; + devmode.dmPelsHeight = orig_height; + ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN); + ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret); + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + ok(width == orig_width, "Got screen width %u, expected %u.\n", width, orig_width); + ok(height == orig_height, "Got screen height %u, expected %u.\n", height, orig_height); + + SetRect(&rect, 0, 0, 200, 150); + ok(AdjustWindowRect(&rect, GetWindowLongW(window, GWL_STYLE), FALSE), "Failed to adjust window rect.\n"); + ok(SetWindowPos(window, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, + SWP_NOMOVE | SWP_NOZORDER), "Failed to set window position.\n"); + + memset(&d3dpp, 0, sizeof(d3dpp)); + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp.Windowed = TRUE; + d3dpp.BackBufferWidth = 0; + d3dpp.BackBufferHeight = 0; + d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; + hr = IDirect3DDevice9Ex_ResetEx(device, &d3dpp, NULL); + ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr); + hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); + ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr); + + ok(d3dpp.BackBufferWidth == 200, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth); + ok(d3dpp.BackBufferHeight == 150, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight); + ok(d3dpp.BackBufferFormat == mode.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n", + d3dpp.BackBufferFormat, mode.Format); + ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount); + ok(!d3dpp.MultiSampleType, "Got unexpected MultiSampleType %u.\n", d3dpp.MultiSampleType); + ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %u.\n", d3dpp.MultiSampleQuality); + ok(d3dpp.SwapEffect == D3DSWAPEFFECT_DISCARD, "Got unexpected SwapEffect %#x.\n", d3dpp.SwapEffect); + ok(!d3dpp.hDeviceWindow, "Got unexpected hDeviceWindow %p.\n", d3dpp.hDeviceWindow); + ok(d3dpp.Windowed, "Got unexpected Windowed %#x.\n", d3dpp.Windowed); + ok(!d3dpp.EnableAutoDepthStencil, "Got unexpected EnableAutoDepthStencil %#x.\n", d3dpp.EnableAutoDepthStencil); + ok(!d3dpp.AutoDepthStencilFormat, "Got unexpected AutoDepthStencilFormat %#x.\n", d3dpp.AutoDepthStencilFormat); + ok(!d3dpp.Flags, "Got unexpected Flags %#x.\n", d3dpp.Flags); + ok(!d3dpp.FullScreen_RefreshRateInHz, "Got unexpected FullScreen_RefreshRateInHz %u.\n", + d3dpp.FullScreen_RefreshRateInHz); + ok(!d3dpp.PresentationInterval, "Got unexpected PresentationInterval %#x.\n", d3dpp.PresentationInterval); + + hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect); + ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr); + ok(rect.left == 0 && rect.top == 0 && rect.right == 200 && rect.bottom == 150, + "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect)); + + hr = IDirect3DDevice9Ex_GetViewport(device, &vp); + ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr); + ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X); + ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y); + ok(vp.Width == 200, "Got unexpected vp.Width %u.\n", vp.Width); + ok(vp.Height == 150, "Got unexpected vp.Height %u.\n", vp.Height); + ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ); + ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ); + + hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain); + ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr); + hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp); + ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr); + ok(d3dpp.BackBufferWidth == 200, "Got unexpected backbuffer width %u.\n", d3dpp.BackBufferWidth); + ok(d3dpp.BackBufferHeight == 150, "Got unexpected backbuffer height %u.\n", d3dpp.BackBufferHeight); + ok(d3dpp.BackBufferFormat == mode.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n", + d3dpp.BackBufferFormat, mode.Format); + ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount); + ok(!d3dpp.MultiSampleType, "Got unexpected MultiSampleType %u.\n", d3dpp.MultiSampleType); + ok(!d3dpp.MultiSampleQuality, "Got unexpected MultiSampleQuality %u.\n", d3dpp.MultiSampleQuality); + ok(d3dpp.SwapEffect == D3DSWAPEFFECT_DISCARD, "Got unexpected SwapEffect %#x.\n", d3dpp.SwapEffect); + ok(d3dpp.hDeviceWindow == window, "Got unexpected hDeviceWindow %p, expected %p.\n", d3dpp.hDeviceWindow, window); + ok(d3dpp.Windowed, "Got unexpected Windowed %#x.\n", d3dpp.Windowed); + ok(!d3dpp.EnableAutoDepthStencil, "Got unexpected EnableAutoDepthStencil %#x.\n", d3dpp.EnableAutoDepthStencil); + ok(!d3dpp.AutoDepthStencilFormat, "Got unexpected AutoDepthStencilFormat %#x.\n", d3dpp.AutoDepthStencilFormat); + ok(!d3dpp.Flags, "Got unexpected Flags %#x.\n", d3dpp.Flags); + ok(!d3dpp.FullScreen_RefreshRateInHz, "Got unexpected FullScreen_RefreshRateInHz %u.\n", + d3dpp.FullScreen_RefreshRateInHz); + ok(!d3dpp.PresentationInterval, "Got unexpected PresentationInterval %#x.\n", d3dpp.PresentationInterval); + IDirect3DSwapChain9_Release(swapchain); + +cleanup: + HeapFree(GetProcessHeap(), 0, modes); + IDirect3D9Ex_Release(d3d9); + refcount = IDirect3DDevice9Ex_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + static void test_reset_resources(void) { IDirect3DSurface9 *surface, *rt; @@ -3182,6 +3585,7 @@ static void test_swapchain_parameters(void) IDirect3D9Ex_Release(d3d9ex); DestroyWindow(window); } + START_TEST(d3d9ex) { DEVMODEW current_mode; @@ -3219,6 +3623,7 @@ START_TEST(d3d9ex) test_create_depth_stencil_surface_ex(); test_user_memory(); test_reset(); + test_reset_ex(); test_reset_resources(); test_vidmem_accounting(); test_user_memory_getdc();