ddraw: Do not return unset viewport from GetViewport().

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-11-12 15:13:05 +01:00 committed by Alexandre Julliard
parent b119d3c54b
commit f4865564ec
5 changed files with 43 additions and 22 deletions

View File

@ -474,6 +474,13 @@ struct d3d_material
void material_activate(struct d3d_material *material) DECLSPEC_HIDDEN;
struct d3d_material *d3d_material_create(struct ddraw *ddraw) DECLSPEC_HIDDEN;
enum ddraw_viewport_version
{
DDRAW_VIEWPORT_VERSION_NONE,
DDRAW_VIEWPORT_VERSION_1,
DDRAW_VIEWPORT_VERSION_2,
};
/*****************************************************************************
* IDirect3DViewport - Wraps to D3D7
*****************************************************************************/
@ -491,7 +498,7 @@ struct d3d_viewport
DWORD num_lights;
DWORD map_lights;
int use_vp2;
enum ddraw_viewport_version version;
union
{

View File

@ -1260,7 +1260,7 @@ static void test_viewport_object(void)
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
desc.vp1.dwSize = sizeof(desc.vp1);
hr = IDirect3DViewport_GetViewport(viewport, &desc.vp1);
todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %u.\n", desc.vp1.dwSize);
/* E_FAIL return values are returned by Winetestbot Windows NT machines. While not supporting

View File

@ -1435,11 +1435,11 @@ static void test_viewport_object(void)
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
desc.vp1.dwSize = sizeof(desc.vp1);
hr = IDirect3DViewport2_GetViewport(viewport2, &desc.vp1);
todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %u.\n", desc.vp1.dwSize);
hr = IDirect3DViewport2_GetViewport2(viewport2, &desc.vp2);
todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
todo_wine ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %u.\n", desc.vp2.dwSize);
ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %u.\n", desc.vp2.dwSize);
desc.vp2.dwSize = sizeof(desc.vp2) + 1;
hr = IDirect3DViewport2_GetViewport2(viewport2, &desc.vp2);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);

View File

@ -1591,11 +1591,11 @@ static void test_viewport_object(void)
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
desc.vp1.dwSize = sizeof(desc.vp1);
hr = IDirect3DViewport3_GetViewport(viewport3, &desc.vp1);
todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %u.\n", desc.vp1.dwSize);
hr = IDirect3DViewport3_GetViewport2(viewport3, &desc.vp2);
todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
todo_wine ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %u.\n", desc.vp2.dwSize);
ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %u.\n", desc.vp2.dwSize);
desc.vp2.dwSize = sizeof(desc.vp2) + 1;
hr = IDirect3DViewport3_GetViewport2(viewport3, &desc.vp2);
todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);

View File

@ -69,7 +69,7 @@ void viewport_activate(struct d3d_viewport *This, BOOL ignore_lights)
}
/* And copy the values in the structure used by the device */
if (This->use_vp2)
if (This->version == DDRAW_VIEWPORT_VERSION_2)
{
vp.dwX = This->viewports.vp2.dwX;
vp.dwY = This->viewports.vp2.dwY;
@ -259,10 +259,17 @@ static HRESULT WINAPI d3d_viewport_GetViewport(IDirect3DViewport3 *iface, D3DVIE
if (!vp)
return DDERR_INVALIDPARAMS;
if (viewport->version == DDRAW_VIEWPORT_VERSION_NONE)
{
WARN("Viewport data was not set.\n");
return D3DERR_VIEWPORTDATANOTSET;
}
wined3d_mutex_lock();
size = vp->dwSize;
if (!viewport->use_vp2)
memset(vp, 0, size);
if (viewport->version == DDRAW_VIEWPORT_VERSION_1)
{
memcpy(vp, &viewport->viewports.vp1, size);
}
@ -275,10 +282,10 @@ static HRESULT WINAPI d3d_viewport_GetViewport(IDirect3DViewport3 *iface, D3DVIE
vp1.dwY = viewport->viewports.vp2.dwY;
vp1.dwWidth = viewport->viewports.vp2.dwWidth;
vp1.dwHeight = viewport->viewports.vp2.dwHeight;
vp1.dvMaxX = 0.0;
vp1.dvMaxY = 0.0;
vp1.dvScaleX = 0.0;
vp1.dvScaleY = 0.0;
vp1.dvMaxX = 0.0f;
vp1.dvMaxY = 0.0f;
vp1.dvScaleX = 0.0f;
vp1.dvScaleY = 0.0f;
vp1.dvMinZ = viewport->viewports.vp2.dvMinZ;
vp1.dvMaxZ = viewport->viewports.vp2.dvMaxZ;
memcpy(vp, &vp1, size);
@ -348,7 +355,7 @@ static HRESULT WINAPI d3d_viewport_SetViewport(IDirect3DViewport3 *iface, D3DVIE
}
}
viewport->use_vp2 = 0;
viewport->version = DDRAW_VIEWPORT_VERSION_1;
viewport->viewports.vp1 = *vp;
/* Empirical testing on a couple of d3d1 games showed that these values
@ -906,9 +913,16 @@ static HRESULT WINAPI d3d_viewport_GetViewport2(IDirect3DViewport3 *iface, D3DVI
if (!vp)
return DDERR_INVALIDPARAMS;
if (viewport->version == DDRAW_VIEWPORT_VERSION_NONE)
{
WARN("Viewport data was not set.\n");
return D3DERR_VIEWPORTDATANOTSET;
}
wined3d_mutex_lock();
size = vp->dwSize;
if (viewport->use_vp2)
memset(vp, 0, size);
if (viewport->version == DDRAW_VIEWPORT_VERSION_2)
{
memcpy(vp, &viewport->viewports.vp2, size);
}
@ -921,10 +935,10 @@ static HRESULT WINAPI d3d_viewport_GetViewport2(IDirect3DViewport3 *iface, D3DVI
vp2.dwY = viewport->viewports.vp1.dwY;
vp2.dwWidth = viewport->viewports.vp1.dwWidth;
vp2.dwHeight = viewport->viewports.vp1.dwHeight;
vp2.dvClipX = 0.0;
vp2.dvClipY = 0.0;
vp2.dvClipWidth = 0.0;
vp2.dvClipHeight = 0.0;
vp2.dvClipX = 0.0f;
vp2.dvClipY = 0.0f;
vp2.dvClipWidth = 0.0f;
vp2.dvClipHeight = 0.0f;
vp2.dvMinZ = viewport->viewports.vp1.dvMinZ;
vp2.dvMaxZ = viewport->viewports.vp1.dvMaxZ;
memcpy(vp, &vp2, size);
@ -994,7 +1008,7 @@ static HRESULT WINAPI d3d_viewport_SetViewport2(IDirect3DViewport3 *iface, D3DVI
}
}
viewport->use_vp2 = 1;
viewport->version = DDRAW_VIEWPORT_VERSION_2;
viewport->viewports.vp2 = *vp;
if (SUCCEEDED(IDirect3DDevice3_GetCurrentViewport(&device->IDirect3DDevice3_iface, &current_viewport)))
@ -1175,6 +1189,6 @@ void d3d_viewport_init(struct d3d_viewport *viewport, struct ddraw *ddraw)
viewport->IDirect3DViewport3_iface.lpVtbl = &d3d_viewport_vtbl;
viewport->ref = 1;
viewport->ddraw = ddraw;
viewport->use_vp2 = 0xff;
viewport->version = DDRAW_VIEWPORT_VERSION_NONE;
list_init(&viewport->light_list);
}