wined3d: Properly handle backbuffer_width/_height=0 in wined3d_device_reset.
This commit is contained in:
parent
2e226b9ad8
commit
33d31a3547
|
@ -1265,8 +1265,8 @@ static void test_reset(void)
|
|||
{
|
||||
ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X);
|
||||
ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\n", vp.Y);
|
||||
todo_wine ok(vp.Width == 200, "D3DVIEWPORT->Width = %u, expected 200.\n", vp.Width);
|
||||
todo_wine ok(vp.Height == 150, "D3DVIEWPORT->Height = %u, expected 150.\n", vp.Height);
|
||||
ok(vp.Width == 200, "D3DVIEWPORT->Width = %u, expected 200.\n", vp.Width);
|
||||
ok(vp.Height == 150, "D3DVIEWPORT->Height = %u, expected 150.\n", vp.Height);
|
||||
ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %.8e, expected 0.\n", vp.MinZ);
|
||||
ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ);
|
||||
}
|
||||
|
@ -1275,10 +1275,8 @@ static void test_reset(void)
|
|||
ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
|
||||
hr = IDirect3DSurface8_GetDesc(surface, &surface_desc);
|
||||
ok(hr == D3D_OK, "GetDesc failed, hr %#x.\n", hr);
|
||||
todo_wine ok(surface_desc.Width == 200, "Back buffer width is %u, expected 200.\n",
|
||||
surface_desc.Width);
|
||||
todo_wine ok(surface_desc.Height == 150, "Back buffer height is %u, expected 150.\n",
|
||||
surface_desc.Height);
|
||||
ok(surface_desc.Width == 200, "Back buffer width is %u, expected 200.\n", surface_desc.Width);
|
||||
ok(surface_desc.Height == 150, "Back buffer height is %u, expected 150.\n", surface_desc.Height);
|
||||
IDirect3DSurface8_Release(surface);
|
||||
|
||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||
|
@ -1443,6 +1441,17 @@ static void test_reset(void)
|
|||
hr = IDirect3DDevice8_TestCooperativeLevel(device1);
|
||||
ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned %#x, expected %#x.\n", hr, D3DERR_DEVICENOTRESET);
|
||||
|
||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.Windowed = FALSE;
|
||||
d3dpp.BackBufferWidth = 0;
|
||||
d3dpp.BackBufferHeight = 0;
|
||||
d3dpp.BackBufferFormat = d3ddm.Format;
|
||||
hr = IDirect3DDevice8_Reset(device1, &d3dpp);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Reset returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
|
||||
hr = IDirect3DDevice8_TestCooperativeLevel(device1);
|
||||
ok(hr == D3DERR_DEVICENOTRESET, "TestCooperativeLevel returned %#x, expected %#x.\n", hr, D3DERR_DEVICENOTRESET);
|
||||
|
||||
hr = IDirect3D8_GetAdapterDisplayMode(d3d8, D3DADAPTER_DEFAULT, &d3ddm);
|
||||
ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#x.\n", hr);
|
||||
|
||||
|
|
|
@ -690,7 +690,7 @@ static void test_reset(void)
|
|||
|
||||
hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect);
|
||||
ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr);
|
||||
todo_wine ok(rect.left == 0 && rect.top == 0 && rect.right == 200 && rect.bottom == 150,
|
||||
ok(rect.left == 0 && rect.top == 0 && rect.right == 200 && rect.bottom == 150,
|
||||
"Got unexpected scissor rect {%d, %d, %d, %d}.\n",
|
||||
rect.left, rect.top, rect.right, rect.bottom);
|
||||
|
||||
|
@ -698,8 +698,8 @@ static void test_reset(void)
|
|||
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);
|
||||
todo_wine ok(vp.Width == 200, "Got unexpected vp.Width %u.\n", vp.Width);
|
||||
todo_wine ok(vp.Height == 150, "Got unexpected vp.Height %u.\n", vp.Height);
|
||||
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);
|
||||
|
||||
|
@ -707,8 +707,8 @@ static void test_reset(void)
|
|||
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);
|
||||
todo_wine ok(d3dpp.BackBufferWidth == 200, "Got unexpected backbuffer width %u.\n", d3dpp.BackBufferWidth);
|
||||
todo_wine ok(d3dpp.BackBufferHeight == 150, "Got unexpected backbuffer height %u.\n", d3dpp.BackBufferHeight);
|
||||
ok(d3dpp.BackBufferWidth == 200, "Got unexpected backbuffer width %u.\n", d3dpp.BackBufferWidth);
|
||||
ok(d3dpp.BackBufferHeight == 150, "Got unexpected backbuffer height %u.\n", d3dpp.BackBufferHeight);
|
||||
IDirect3DSwapChain9_Release(swapchain);
|
||||
|
||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||
|
|
|
@ -1110,8 +1110,8 @@ static void test_reset(void)
|
|||
{
|
||||
ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
|
||||
ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\n", vp.Y);
|
||||
todo_wine ok(vp.Width == 200, "D3DVIEWPORT->Width = %d\n", vp.Width);
|
||||
todo_wine ok(vp.Height == 150, "D3DVIEWPORT->Height = %d\n", vp.Height);
|
||||
ok(vp.Width == 200, "D3DVIEWPORT->Width = %d\n", vp.Width);
|
||||
ok(vp.Height == 150, "D3DVIEWPORT->Height = %d\n", vp.Height);
|
||||
ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %f\n", vp.MinZ);
|
||||
ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
|
||||
}
|
||||
|
@ -1125,8 +1125,8 @@ static void test_reset(void)
|
|||
ok(hr == D3D_OK, "IDirect3DSwapChain9_GetPresentParameters returned %08x\n", hr);
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
todo_wine ok(d3dpp.BackBufferWidth == 200, "Back buffer width is %d\n", d3dpp.BackBufferWidth);
|
||||
todo_wine ok(d3dpp.BackBufferHeight == 150, "Back buffer height is %d\n", d3dpp.BackBufferHeight);
|
||||
ok(d3dpp.BackBufferWidth == 200, "Back buffer width is %d\n", d3dpp.BackBufferWidth);
|
||||
ok(d3dpp.BackBufferHeight == 150, "Back buffer height is %d\n", d3dpp.BackBufferHeight);
|
||||
}
|
||||
IDirect3DSwapChain9_Release(pSwapchain);
|
||||
}
|
||||
|
@ -1291,6 +1291,16 @@ static void test_reset(void)
|
|||
hr = IDirect3DDevice9_TestCooperativeLevel(device1);
|
||||
ok(hr == D3DERR_DEVICENOTRESET, "IDirect3DDevice9_TestCooperativeLevel after a failed reset returned %#x\n", hr);
|
||||
|
||||
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.Windowed = FALSE;
|
||||
d3dpp.BackBufferWidth = 0;
|
||||
d3dpp.BackBufferHeight = 0;
|
||||
hr = IDirect3DDevice9_Reset(device1, &d3dpp);
|
||||
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_Reset to w=0, h=0, windowed=FALSE failed with %08x\n", hr);
|
||||
hr = IDirect3DDevice9_TestCooperativeLevel(device1);
|
||||
ok(hr == D3DERR_DEVICENOTRESET, "IDirect3DDevice9_TestCooperativeLevel after a failed reset returned %#x\n", hr);
|
||||
|
||||
IDirect3D9_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
|
||||
|
||||
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
||||
|
|
|
@ -4904,6 +4904,8 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
|||
struct wined3d_display_mode m;
|
||||
BOOL DisplayModeChanged = FALSE;
|
||||
BOOL update_desc = FALSE;
|
||||
UINT backbuffer_width = swapchain_desc->backbuffer_width;
|
||||
UINT backbuffer_height = swapchain_desc->backbuffer_height;
|
||||
HRESULT hr = WINED3D_OK;
|
||||
unsigned int i;
|
||||
|
||||
|
@ -5034,16 +5036,38 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
|||
m.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Should Width == 800 && Height == 0 set 800x600? */
|
||||
if (swapchain_desc->backbuffer_width && swapchain_desc->backbuffer_height
|
||||
&& (swapchain_desc->backbuffer_width != swapchain->desc.backbuffer_width
|
||||
|| swapchain_desc->backbuffer_height != swapchain->desc.backbuffer_height))
|
||||
if (!backbuffer_width || !backbuffer_height)
|
||||
{
|
||||
/* The application is requesting that either the swapchain width or
|
||||
* height be set to the corresponding dimension in the window's
|
||||
* client rect. */
|
||||
|
||||
RECT client_rect;
|
||||
|
||||
if (!swapchain_desc->windowed)
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
if (!GetClientRect(swapchain->device_window, &client_rect))
|
||||
{
|
||||
ERR("Failed to get client rect, last error %#x.\n", GetLastError());
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
if (!backbuffer_width)
|
||||
backbuffer_width = client_rect.right;
|
||||
|
||||
if (!backbuffer_height)
|
||||
backbuffer_height = client_rect.bottom;
|
||||
}
|
||||
|
||||
if (backbuffer_width != swapchain->desc.backbuffer_width
|
||||
|| backbuffer_height != swapchain->desc.backbuffer_height)
|
||||
{
|
||||
if (!swapchain_desc->windowed)
|
||||
DisplayModeChanged = TRUE;
|
||||
|
||||
swapchain->desc.backbuffer_width = swapchain_desc->backbuffer_width;
|
||||
swapchain->desc.backbuffer_height = swapchain_desc->backbuffer_height;
|
||||
swapchain->desc.backbuffer_width = backbuffer_width;
|
||||
swapchain->desc.backbuffer_height = backbuffer_height;
|
||||
update_desc = TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue