Commit 8577ff54 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Find the correct GUIDs for each D3D version in FindDevice().

parent 29b794dc
...@@ -4018,35 +4018,20 @@ static HRESULT WINAPI d3d1_CreateViewport(IDirect3D *iface, IDirect3DViewport ** ...@@ -4018,35 +4018,20 @@ static HRESULT WINAPI d3d1_CreateViewport(IDirect3D *iface, IDirect3DViewport **
outer_unknown); outer_unknown);
} }
/***************************************************************************** static HRESULT ddraw_find_device(struct ddraw *ddraw, const D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr,
* IDirect3D3::FindDevice unsigned int guid_count, const GUID * const *guids)
*
* This method finds a device with the requested properties and returns a
* device description
*
* Versions 1, 2 and 3
* Params:
* fds: Describes the requested device characteristics
* fdr: Returns the device description
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if no device was found
*
*****************************************************************************/
static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
{ {
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
D3DDEVICEDESC7 desc7; D3DDEVICEDESC7 desc7;
D3DDEVICEDESC desc1; D3DDEVICEDESC desc1;
unsigned int i;
HRESULT hr; HRESULT hr;
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr); TRACE("ddraw %p, fds %p, fdr %p, guid_count %u, guids %p.\n", ddraw, fds, fdr, guid_count, guids);
if (!fds || !fdr) return DDERR_INVALIDPARAMS; if (!fds || !fdr)
return DDERR_INVALIDPARAMS;
if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH) if (fds->dwSize != sizeof(*fds) || fdr->dwSize != sizeof(*fdr))
|| fdr->dwSize != sizeof(D3DFINDDEVICERESULT))
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
if (fds->dwFlags & D3DFDS_COLORMODEL) if (fds->dwFlags & D3DFDS_COLORMODEL)
...@@ -4054,12 +4039,22 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd ...@@ -4054,12 +4039,22 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd
if (fds->dwFlags & D3DFDS_GUID) if (fds->dwFlags & D3DFDS_GUID)
{ {
TRACE("Trying to match guid %s.\n", debugstr_guid(&(fds->guid))); BOOL found = FALSE;
if (!IsEqualGUID(&IID_D3DDEVICE_WineD3D, &fds->guid)
&& !IsEqualGUID(&IID_IDirect3DHALDevice, &fds->guid) TRACE("Trying to match GUID %s.\n", debugstr_guid(&fds->guid));
&& !IsEqualGUID(&IID_IDirect3DRGBDevice, &fds->guid))
for (i = 0; i < guid_count; ++i)
{
if (IsEqualGUID(guids[i], &fds->guid))
{
found = TRUE;
break;
}
}
if (!found)
{ {
WARN("No match for this GUID.\n"); WARN("Failed to match GUID %s.\n", debugstr_guid(&fds->guid));
return DDERR_NOTFOUND; return DDERR_NOTFOUND;
} }
} }
...@@ -4079,22 +4074,52 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd ...@@ -4079,22 +4074,52 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd
return D3D_OK; return D3D_OK;
} }
static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
{
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
static const GUID * const guids[] =
{
&IID_D3DDEVICE_WineD3D,
&IID_IDirect3DHALDevice,
&IID_IDirect3DRGBDevice,
};
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
return ddraw_find_device(ddraw, fds, fdr, ARRAY_SIZE(guids), guids);
}
static HRESULT WINAPI d3d2_FindDevice(IDirect3D2 *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr) static HRESULT WINAPI d3d2_FindDevice(IDirect3D2 *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
{ {
struct ddraw *ddraw = impl_from_IDirect3D2(iface); struct ddraw *ddraw = impl_from_IDirect3D2(iface);
static const GUID * const guids[] =
{
&IID_D3DDEVICE_WineD3D,
&IID_IDirect3DHALDevice,
&IID_IDirect3DMMXDevice,
&IID_IDirect3DRGBDevice,
&IID_IDirect3DRampDevice,
};
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr); TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
return d3d3_FindDevice(&ddraw->IDirect3D3_iface, fds, fdr); return ddraw_find_device(ddraw, fds, fdr, ARRAY_SIZE(guids), guids);
} }
static HRESULT WINAPI d3d1_FindDevice(IDirect3D *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr) static HRESULT WINAPI d3d1_FindDevice(IDirect3D *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
{ {
struct ddraw *ddraw = impl_from_IDirect3D(iface); struct ddraw *ddraw = impl_from_IDirect3D(iface);
static const GUID * const guids[] =
{
&IID_D3DDEVICE_WineD3D,
&IID_IDirect3DHALDevice,
&IID_IDirect3DRGBDevice,
&IID_IDirect3DRampDevice,
};
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr); TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
return d3d3_FindDevice(&ddraw->IDirect3D3_iface, fds, fdr); return ddraw_find_device(ddraw, fds, fdr, ARRAY_SIZE(guids), guids);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -11728,12 +11728,11 @@ static void test_find_device(void) ...@@ -11728,12 +11728,11 @@ static void test_find_device(void)
{ {
const GUID *guid; const GUID *guid;
HRESULT hr; HRESULT hr;
BOOL todo;
} }
tests[] = tests[] =
{ {
{&IID_IDirect3D, DDERR_NOTFOUND}, {&IID_IDirect3D, DDERR_NOTFOUND},
{&IID_IDirect3DRampDevice, D3D_OK, TRUE}, {&IID_IDirect3DRampDevice, D3D_OK},
{&IID_IDirect3DRGBDevice, D3D_OK}, {&IID_IDirect3DRGBDevice, D3D_OK},
{&IID_IDirect3DMMXDevice, DDERR_NOTFOUND}, {&IID_IDirect3DMMXDevice, DDERR_NOTFOUND},
{&IID_IDirect3DRefDevice, DDERR_NOTFOUND}, {&IID_IDirect3DRefDevice, DDERR_NOTFOUND},
...@@ -11784,8 +11783,7 @@ static void test_find_device(void) ...@@ -11784,8 +11783,7 @@ static void test_find_device(void)
result.dwSize = sizeof(result); result.dwSize = sizeof(result);
hr = IDirect3D_FindDevice(d3d, &search, &result); hr = IDirect3D_FindDevice(d3d, &search, &result);
todo_wine_if(tests[i].todo) ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
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); ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %u.\n", i, result.dwSize);
} }
......
...@@ -13010,14 +13010,13 @@ static void test_find_device(void) ...@@ -13010,14 +13010,13 @@ static void test_find_device(void)
{ {
const GUID *guid; const GUID *guid;
HRESULT hr; HRESULT hr;
BOOL todo;
} }
tests[] = tests[] =
{ {
{&IID_IDirect3D, DDERR_NOTFOUND}, {&IID_IDirect3D, DDERR_NOTFOUND},
{&IID_IDirect3DRampDevice, D3D_OK, TRUE}, {&IID_IDirect3DRampDevice, D3D_OK},
{&IID_IDirect3DRGBDevice, D3D_OK}, {&IID_IDirect3DRGBDevice, D3D_OK},
{&IID_IDirect3DMMXDevice, D3D_OK, TRUE}, {&IID_IDirect3DMMXDevice, D3D_OK},
{&IID_IDirect3DRefDevice, DDERR_NOTFOUND}, {&IID_IDirect3DRefDevice, DDERR_NOTFOUND},
{&IID_IDirect3DTnLHalDevice, DDERR_NOTFOUND}, {&IID_IDirect3DTnLHalDevice, DDERR_NOTFOUND},
{&IID_IDirect3DNullDevice, DDERR_NOTFOUND}, {&IID_IDirect3DNullDevice, DDERR_NOTFOUND},
...@@ -13066,8 +13065,7 @@ static void test_find_device(void) ...@@ -13066,8 +13065,7 @@ static void test_find_device(void)
result.dwSize = sizeof(result); result.dwSize = sizeof(result);
hr = IDirect3D2_FindDevice(d3d, &search, &result); hr = IDirect3D2_FindDevice(d3d, &search, &result);
todo_wine_if(tests[i].todo) ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
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); ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %u.\n", i, result.dwSize);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment