ddraw: Accept the d3d1 and d3d2 versions of D3DFINDDEVICERESULT in ddraw_find_device().

Based off a patch by Michael Müller.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2018-09-11 18:39:28 +04:30 committed by Alexandre Julliard
parent 8577ff54ad
commit 96ba1bc478
5 changed files with 296 additions and 11 deletions

View File

@ -25,6 +25,8 @@
#include "wine/port.h"
#include "ddraw_private.h"
#include "ddrawi.h"
#include "d3dhal.h"
#include "wine/exception.h"
@ -4019,20 +4021,44 @@ static HRESULT WINAPI d3d1_CreateViewport(IDirect3D *iface, IDirect3DViewport **
}
static HRESULT ddraw_find_device(struct ddraw *ddraw, const D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr,
unsigned int guid_count, const GUID * const *guids)
unsigned int guid_count, const GUID * const *guids, DWORD device_desc_size)
{
struct ddraw_find_device_result_v1
{
DWORD size;
GUID guid;
D3DDEVICEDESC_V1 hw_desc;
D3DDEVICEDESC_V1 sw_desc;
} *fdr1;
struct ddraw_find_device_result_v2
{
DWORD size;
GUID guid;
D3DDEVICEDESC_V2 hw_desc;
D3DDEVICEDESC_V2 sw_desc;
} *fdr2;
D3DDEVICEDESC7 desc7;
D3DDEVICEDESC desc1;
unsigned int i;
HRESULT hr;
TRACE("ddraw %p, fds %p, fdr %p, guid_count %u, guids %p.\n", ddraw, fds, fdr, guid_count, guids);
TRACE("ddraw %p, fds %p, fdr %p, guid_count %u, guids %p, device_desc_size %u.\n",
ddraw, fds, fdr, guid_count, guids, device_desc_size);
if (!fds || !fdr)
return DDERR_INVALIDPARAMS;
if (fds->dwSize != sizeof(*fds) || fdr->dwSize != sizeof(*fdr))
if (fds->dwSize != sizeof(*fds))
{
WARN("Got invalid search structure size %u.\n", fds->dwSize);
return DDERR_INVALIDPARAMS;
}
if (fdr->dwSize != sizeof(*fdr) && fdr->dwSize != sizeof(*fdr2) && fdr->dwSize != sizeof(*fdr1))
{
WARN("Got invalid result structure size %u.\n", fdr->dwSize);
return DDERR_INVALIDPARAMS;
}
if (fds->dwFlags & D3DFDS_COLORMODEL)
WARN("Ignoring colour model %#x.\n", fds->dcmColorModel);
@ -4066,8 +4092,33 @@ static HRESULT ddraw_find_device(struct ddraw *ddraw, const D3DFINDDEVICESEARCH
/* Now return our own GUID */
ddraw_d3dcaps1_from_7(&desc1, &desc7);
fdr->guid = IID_D3DDEVICE_WineD3D;
fdr->ddHwDesc = desc1;
fdr->ddSwDesc = desc1;
/* Note that "device_desc_size" doesn't necessarily have any relation to
* the actual structure size. However, this matches the behaviour of
* Windows since at least Windows 2000. */
if (fdr->dwSize == sizeof(*fdr1))
{
fdr1 = (struct ddraw_find_device_result_v1 *)fdr;
memcpy(&fdr1->hw_desc, &desc1, sizeof(fdr1->hw_desc));
fdr1->hw_desc.dwSize = device_desc_size;
memcpy(&fdr1->sw_desc, &desc1, sizeof(fdr1->sw_desc));
fdr1->sw_desc.dwSize = device_desc_size;
}
else if (fdr->dwSize == sizeof(*fdr2))
{
fdr2 = (struct ddraw_find_device_result_v2 *)fdr;
memcpy(&fdr2->hw_desc, &desc1, sizeof(fdr2->hw_desc));
fdr2->hw_desc.dwSize = device_desc_size;
memcpy(&fdr2->sw_desc, &desc1, sizeof(fdr2->sw_desc));
fdr2->sw_desc.dwSize = device_desc_size;
}
else
{
fdr->ddHwDesc = desc1;
fdr->ddHwDesc.dwSize = device_desc_size;
fdr->ddSwDesc = desc1;
fdr->ddSwDesc.dwSize = device_desc_size;
}
TRACE("Returning Wine's wined3d device with (undumped) capabilities.\n");
@ -4086,7 +4137,7 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
return ddraw_find_device(ddraw, fds, fdr, ARRAY_SIZE(guids), guids);
return ddraw_find_device(ddraw, fds, fdr, ARRAY_SIZE(guids), guids, sizeof(D3DDEVICEDESC_V3));
}
static HRESULT WINAPI d3d2_FindDevice(IDirect3D2 *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
@ -4103,7 +4154,7 @@ static HRESULT WINAPI d3d2_FindDevice(IDirect3D2 *iface, D3DFINDDEVICESEARCH *fd
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
return ddraw_find_device(ddraw, fds, fdr, ARRAY_SIZE(guids), guids);
return ddraw_find_device(ddraw, fds, fdr, ARRAY_SIZE(guids), guids, sizeof(D3DDEVICEDESC_V2));
}
static HRESULT WINAPI d3d1_FindDevice(IDirect3D *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
@ -4119,7 +4170,7 @@ static HRESULT WINAPI d3d1_FindDevice(IDirect3D *iface, D3DFINDDEVICESEARCH *fds
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
return ddraw_find_device(ddraw, fds, fdr, ARRAY_SIZE(guids), guids);
return ddraw_find_device(ddraw, fds, fdr, ARRAY_SIZE(guids), guids, sizeof(D3DDEVICEDESC_V1));
}
/*****************************************************************************

View File

@ -22,7 +22,8 @@
#include "wine/test.h"
#include <limits.h>
#include <math.h>
#include "d3d.h"
#include "ddrawi.h"
#include "d3dhal.h"
static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
static DEVMODEW registry_mode;
@ -11724,6 +11725,22 @@ static void test_find_device(void)
HWND window;
HRESULT hr;
struct
{
DWORD size;
GUID guid;
D3DDEVICEDESC_V1 hw_desc;
D3DDEVICEDESC_V1 sw_desc;
} result_v1;
struct
{
DWORD size;
GUID guid;
D3DDEVICEDESC_V2 hw_desc;
D3DDEVICEDESC_V2 sw_desc;
} result_v2;
static const struct
{
const GUID *guid;
@ -11761,6 +11778,10 @@ static void test_find_device(void)
hr = IDirect3D_FindDevice(d3d, &search, &result);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(result.dwSize == sizeof(result), "Got unexpected result size %u.\n", result.dwSize);
ok(result.ddHwDesc.dwSize == sizeof(result_v1.hw_desc),
"Got unexpected HW desc size %u.\n", result.ddHwDesc.dwSize);
ok(result.ddSwDesc.dwSize == sizeof(result_v1.sw_desc),
"Got unexpected SW desc size %u.\n", result.ddSwDesc.dwSize);
memset(&search, 0, sizeof(search));
memset(&result, 0, sizeof(result));
@ -11772,6 +11793,26 @@ static void test_find_device(void)
hr = IDirect3D_FindDevice(d3d, &search, &result);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
search.dwSize = sizeof(search);
memset(&result_v1, 0, sizeof(result_v1));
result_v1.size = sizeof(result_v1);
hr = IDirect3D_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v1);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(result_v1.hw_desc.dwSize == sizeof(result_v1.hw_desc),
"Got unexpected HW desc size %u.\n", result_v1.hw_desc.dwSize);
ok(result_v1.sw_desc.dwSize == sizeof(result_v1.sw_desc),
"Got unexpected SW desc size %u.\n", result_v1.sw_desc.dwSize);
memset(&result_v2, 0, sizeof(result_v2));
result_v2.size = sizeof(result_v2);
hr = IDirect3D_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v2);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(result_v2.hw_desc.dwSize == sizeof(result_v1.hw_desc),
"Got unexpected HW desc size %u.\n", result_v2.hw_desc.dwSize);
ok(result_v2.sw_desc.dwSize == sizeof(result_v1.sw_desc),
"Got unexpected SW desc size %u.\n", result_v2.sw_desc.dwSize);
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
memset(&search, 0, sizeof(search));
@ -11785,6 +11826,20 @@ static void test_find_device(void)
hr = IDirect3D_FindDevice(d3d, &search, &result);
ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %u.\n", i, result.dwSize);
if (SUCCEEDED(hr))
{
ok(result.ddHwDesc.dwSize == sizeof(result_v1.hw_desc),
"Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
ok(result.ddSwDesc.dwSize == sizeof(result_v1.sw_desc),
"Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
}
else
{
ok(!result.ddHwDesc.dwSize,
"Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
ok(!result.ddSwDesc.dwSize,
"Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
}
}
/* The HAL device can only be enumerated if hardware acceleration is present. */

View File

@ -24,7 +24,8 @@
#include "wine/test.h"
#include <limits.h>
#include <math.h>
#include "d3d.h"
#include "ddrawi.h"
#include "d3dhal.h"
static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
static DEVMODEW registry_mode;
@ -13006,6 +13007,22 @@ static void test_find_device(void)
HWND window;
HRESULT hr;
struct
{
DWORD size;
GUID guid;
D3DDEVICEDESC_V1 hw_desc;
D3DDEVICEDESC_V1 sw_desc;
} result_v1;
struct
{
DWORD size;
GUID guid;
D3DDEVICEDESC_V2 hw_desc;
D3DDEVICEDESC_V2 sw_desc;
} result_v2;
static const struct
{
const GUID *guid;
@ -13043,6 +13060,10 @@ static void test_find_device(void)
hr = IDirect3D2_FindDevice(d3d, &search, &result);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(result.dwSize == sizeof(result), "Got unexpected result size %u.\n", result.dwSize);
ok(result.ddHwDesc.dwSize == sizeof(result_v2.hw_desc),
"Got unexpected HW desc size %u.\n", result.ddHwDesc.dwSize);
ok(result.ddSwDesc.dwSize == sizeof(result_v2.sw_desc),
"Got unexpected SW desc size %u.\n", result.ddSwDesc.dwSize);
memset(&search, 0, sizeof(search));
memset(&result, 0, sizeof(result));
@ -13054,6 +13075,26 @@ static void test_find_device(void)
hr = IDirect3D2_FindDevice(d3d, &search, &result);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
search.dwSize = sizeof(search);
memset(&result_v1, 0, sizeof(result_v1));
result_v1.size = sizeof(result_v1);
hr = IDirect3D2_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v1);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(result_v1.hw_desc.dwSize == sizeof(result_v2.hw_desc),
"Got unexpected HW desc size %u.\n", result_v1.hw_desc.dwSize);
ok(result_v1.sw_desc.dwSize == sizeof(result_v2.sw_desc),
"Got unexpected SW desc size %u.\n", result_v1.sw_desc.dwSize);
memset(&result_v2, 0, sizeof(result_v2));
result_v2.size = sizeof(result_v2);
hr = IDirect3D2_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v2);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(result_v2.hw_desc.dwSize == sizeof(result_v2.hw_desc),
"Got unexpected HW desc size %u.\n", result_v2.hw_desc.dwSize);
ok(result_v2.sw_desc.dwSize == sizeof(result_v2.sw_desc),
"Got unexpected SW desc size %u.\n", result_v2.sw_desc.dwSize);
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
memset(&search, 0, sizeof(search));
@ -13067,6 +13108,20 @@ static void test_find_device(void)
hr = IDirect3D2_FindDevice(d3d, &search, &result);
ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %u.\n", i, result.dwSize);
if (SUCCEEDED(hr))
{
ok(result.ddHwDesc.dwSize == sizeof(result_v2.hw_desc),
"Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
ok(result.ddSwDesc.dwSize == sizeof(result_v2.sw_desc),
"Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
}
else
{
ok(!result.ddHwDesc.dwSize,
"Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
ok(!result.ddSwDesc.dwSize,
"Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
}
}
/* The HAL device can only be enumerated if hardware acceleration is present. */

View File

@ -22,7 +22,8 @@
#include "wine/test.h"
#include <limits.h>
#include <math.h>
#include "d3d.h"
#include "ddrawi.h"
#include "d3dhal.h"
HRESULT WINAPI GetSurfaceFromDC(HDC dc, struct IDirectDrawSurface **surface, HDC *device_dc);
@ -15100,6 +15101,22 @@ static void test_find_device(void)
HWND window;
HRESULT hr;
struct
{
DWORD size;
GUID guid;
D3DDEVICEDESC_V1 hw_desc;
D3DDEVICEDESC_V1 sw_desc;
} result_v1;
struct
{
DWORD size;
GUID guid;
D3DDEVICEDESC_V2 hw_desc;
D3DDEVICEDESC_V2 sw_desc;
} result_v2;
static const struct
{
const GUID *guid;
@ -15137,6 +15154,10 @@ static void test_find_device(void)
hr = IDirect3D3_FindDevice(d3d, &search, &result);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(result.dwSize == sizeof(result), "Got unexpected result size %u.\n", result.dwSize);
ok(result.ddHwDesc.dwSize == sizeof(result.ddHwDesc),
"Got unexpected HW desc size %u.\n", result.ddHwDesc.dwSize);
ok(result.ddSwDesc.dwSize == sizeof(result.ddSwDesc),
"Got unexpected SW desc size %u.\n", result.ddSwDesc.dwSize);
memset(&search, 0, sizeof(search));
memset(&result, 0, sizeof(result));
@ -15148,6 +15169,26 @@ static void test_find_device(void)
hr = IDirect3D3_FindDevice(d3d, &search, &result);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
search.dwSize = sizeof(search);
memset(&result_v1, 0, sizeof(result_v1));
result_v1.size = sizeof(result_v1);
hr = IDirect3D3_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v1);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(result_v1.hw_desc.dwSize == sizeof(result.ddHwDesc),
"Got unexpected HW desc size %u.\n", result_v1.hw_desc.dwSize);
ok(result_v1.sw_desc.dwSize == sizeof(result.ddSwDesc),
"Got unexpected SW desc size %u.\n", result_v1.sw_desc.dwSize);
memset(&result_v2, 0, sizeof(result_v2));
result_v2.size = sizeof(result_v2);
hr = IDirect3D3_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v2);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(result_v2.hw_desc.dwSize == sizeof(result.ddHwDesc),
"Got unexpected HW desc size %u.\n", result_v2.hw_desc.dwSize);
ok(result_v2.sw_desc.dwSize == sizeof(result.ddSwDesc),
"Got unexpected SW desc size %u.\n", result_v2.sw_desc.dwSize);
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
memset(&search, 0, sizeof(search));
@ -15161,6 +15202,20 @@ static void test_find_device(void)
hr = IDirect3D3_FindDevice(d3d, &search, &result);
ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %u.\n", i, result.dwSize);
if (SUCCEEDED(hr))
{
ok(result.ddHwDesc.dwSize == sizeof(result.ddHwDesc),
"Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
ok(result.ddSwDesc.dwSize == sizeof(result.ddSwDesc),
"Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
}
else
{
ok(!result.ddHwDesc.dwSize,
"Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
ok(!result.ddSwDesc.dwSize,
"Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
}
}
/* The HAL device can only be enumerated if hardware acceleration is present. */

View File

@ -47,6 +47,75 @@ typedef struct _D3DDeviceDesc_V1 {
DWORD dwMaxVertexCount;
} D3DDEVICEDESC_V1,*LPD3DDEVICEDESC_V1;
typedef struct _D3DDeviceDesc_V2
{
DWORD dwSize;
DWORD dwFlags;
D3DCOLORMODEL dcmColorModel;
DWORD dwDevCaps;
D3DTRANSFORMCAPS dtcTransformCaps;
BOOL bClipping;
D3DLIGHTINGCAPS dlcLightingCaps;
D3DPRIMCAPS dpcLineCaps;
D3DPRIMCAPS dpcTriCaps;
DWORD dwDeviceRenderBitDepth;
DWORD dwDeviceZBufferBitDepth;
DWORD dwMaxBufferSize;
DWORD dwMaxVertexCount;
/* DirectX 5 */
DWORD dwMinTextureWidth;
DWORD dwMinTextureHeight;
DWORD dwMaxTextureWidth;
DWORD dwMaxTextureHeight;
DWORD dwMinStippleWidth;
DWORD dwMaxStippleWidth;
DWORD dwMinStippleHeight;
DWORD dwMaxStippleHeight;
} D3DDEVICEDESC_V2, *LPD3DDEVICEDESC_V2;
typedef struct _D3DDeviceDesc_V3
{
DWORD dwSize;
DWORD dwFlags;
D3DCOLORMODEL dcmColorModel;
DWORD dwDevCaps;
D3DTRANSFORMCAPS dtcTransformCaps;
BOOL bClipping;
D3DLIGHTINGCAPS dlcLightingCaps;
D3DPRIMCAPS dpcLineCaps;
D3DPRIMCAPS dpcTriCaps;
DWORD dwDeviceRenderBitDepth;
DWORD dwDeviceZBufferBitDepth;
DWORD dwMaxBufferSize;
DWORD dwMaxVertexCount;
/* DirectX 5 */
DWORD dwMinTextureWidth;
DWORD dwMinTextureHeight;
DWORD dwMaxTextureWidth;
DWORD dwMaxTextureHeight;
DWORD dwMinStippleWidth;
DWORD dwMaxStippleWidth;
DWORD dwMinStippleHeight;
DWORD dwMaxStippleHeight;
/* DirectX 6 */
DWORD dwMaxTextureRepeat;
DWORD dwMaxTextureAspectRatio;
DWORD dwMaxAnisotropy;
D3DVALUE dvGuardBandLeft;
D3DVALUE dvGuardBandTop;
D3DVALUE dvGuardBandRight;
D3DVALUE dvGuardBandBottom;
D3DVALUE dvExtentsAdjust;
DWORD dwStencilCaps;
DWORD dwFVFCaps;
DWORD dwTextureOpCaps;
WORD wMaxTextureBlendStages;
WORD wMaxSimultaneousTextures;
} D3DDEVICEDESC_V3, *LPD3DDEVICEDESC_V3;
typedef struct _D3DHAL_GLOBALDRIVERDATA {
DWORD dwSize;
D3DDEVICEDESC_V1 hwCaps;