Based off a patch by Michael Muller.
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/ddraw/ddraw.c | 40 ++++++++++++++++++++++++++++++++++++---- dlls/ddraw/tests/d3d.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 5 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index e60c5f3..fe81f90 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -25,6 +25,8 @@ #include "wine/port.h"
#include "ddraw_private.h" +#include "ddrawi.h" +#include "d3dhal.h"
#include "wine/exception.h"
@@ -74,6 +76,20 @@ static struct enum_device_entry }, };
+typedef struct _D3DFINDDEVICERESULT1 { + DWORD dwSize; + GUID guid; + D3DDEVICEDESC_V1 ddHwDesc; + D3DDEVICEDESC_V1 ddSwDesc; +} D3DFINDDEVICERESULT_V1; + +typedef struct _D3DFINDDEVICERESULT2 { + DWORD dwSize; + GUID guid; + D3DDEVICEDESC_V2 ddHwDesc; + D3DDEVICEDESC_V2 ddSwDesc; +} D3DFINDDEVICERESULT_V2; + static void STDMETHODCALLTYPE ddraw_null_wined3d_object_destroyed(void *parent) {}
const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops = @@ -4045,8 +4061,8 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd
if (!fds || !fdr) return DDERR_INVALIDPARAMS;
- if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH) - || fdr->dwSize != sizeof(D3DFINDDEVICERESULT)) + if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH) || (fdr->dwSize != sizeof(D3DFINDDEVICERESULT_V1) && + fdr->dwSize != sizeof(D3DFINDDEVICERESULT_V2) && fdr->dwSize != sizeof(D3DFINDDEVICERESULT))) return DDERR_INVALIDPARAMS;
if ((fds->dwFlags & D3DFDS_COLORMODEL) @@ -4075,8 +4091,24 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd /* Now return our own GUID */ ddraw_d3dcaps1_from_7(&desc1, &desc7); fdr->guid = IID_D3DDEVICE_WineD3D; - fdr->ddHwDesc = desc1; - fdr->ddSwDesc = desc1; + + if (fdr->dwSize == sizeof(D3DFINDDEVICERESULT_V1)) + { + D3DFINDDEVICERESULT_V1 *fdr1 = (D3DFINDDEVICERESULT_V1 *)fdr; + memcpy(&fdr1->ddHwDesc, &desc1, sizeof(fdr1->ddHwDesc)); + memcpy(&fdr1->ddSwDesc, &desc1, sizeof(fdr1->ddSwDesc)); + } + else if (fdr->dwSize == sizeof(D3DFINDDEVICERESULT_V2)) + { + D3DFINDDEVICERESULT_V2 *fdr2 = (D3DFINDDEVICERESULT_V2 *)fdr; + memcpy(&fdr2->ddHwDesc, &desc1, sizeof(fdr2->ddHwDesc)); + memcpy(&fdr2->ddSwDesc, &desc1, sizeof(fdr2->ddSwDesc)); + } + else + { + fdr->ddHwDesc = desc1; + fdr->ddSwDesc = desc1; + }
TRACE("Returning Wine's wined3d device with (undumped) capabilities.\n");
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index ec0f8d7..2234399 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -27,6 +27,8 @@ #include "initguid.h" #include "ddraw.h" #include "d3d.h" +#include "ddrawi.h" +#include "d3dhal.h" #include "unknwn.h"
static IDirectDraw7 *lpDD; @@ -44,6 +46,20 @@ static IDirect3DExecuteBuffer *ExecuteBuffer = NULL; static IDirect3DViewport *Viewport = NULL; static IDirect3DLight *Light = NULL;
+typedef struct _D3DFINDDEVICERESULT1 { + DWORD dwSize; + GUID guid; + D3DDEVICEDESC_V1 ddHwDesc; + D3DDEVICEDESC_V1 ddSwDesc; +} D3DFINDDEVICERESULT_V1; + +typedef struct _D3DFINDDEVICERESULT2 { + DWORD dwSize; + GUID guid; + D3DDEVICEDESC_V2 ddHwDesc; + D3DDEVICEDESC_V2 ddSwDesc; +} D3DFINDDEVICERESULT_V2; + typedef struct { int total; int rgb; @@ -1628,7 +1644,6 @@ static void FindDevice(void) &IID_IDirect3DRefDevice, &IID_IDirect3DTnLHalDevice, &IID_IDirect3DNullDevice}; - D3DFINDDEVICESEARCH search = {0}; D3DFINDDEVICERESULT result = {0}; IDirect3DDevice *d3dhal; @@ -1671,6 +1686,18 @@ static void FindDevice(void) ok(hr == D3D_OK, "Expected IDirect3D1::FindDevice to return D3D_OK, got 0x%08x\n", hr);
+ result.dwSize = sizeof(D3DFINDDEVICERESULT_V1); + + hr = IDirect3D_FindDevice(Direct3D1, &search, (D3DFINDDEVICERESULT *)&result); + ok(hr == D3D_OK, + "Expected IDirect3D1::FindDevice to return D3D_OK, got 0x%08x\n", hr); + + result.dwSize = sizeof(D3DFINDDEVICERESULT_V2); + + hr = IDirect3D_FindDevice(Direct3D1, &search, (D3DFINDDEVICERESULT *)&result); + ok(hr == D3D_OK, + "Expected IDirect3D1::FindDevice to return D3D_OK, got 0x%08x\n", hr); + /* Try an arbitrary non-device GUID. */ search.dwSize = sizeof(search); search.dwFlags = D3DFDS_GUID;