Fix Battle Realms: Zen Edition failing to start. The game expects to find a device without D3DDEVCAPS_HWTRANSFORMANDLIGHT.
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/ddraw/tests/d3d.c | 89 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+)
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index 87d0648b699..bfe90f6a511 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -517,6 +517,19 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
ok(hal->dwFlags == 0, "RGB Device %u hal caps has hardware flags %#lx\n", ver, hal->dwFlags); ok(hel->dwFlags != 0, "RGB Device %u hel caps has hardware flags %#lx\n", ver, hel->dwFlags); + + todo_wine + ok((hal->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "RGB Device %d hal device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + todo_wine + ok((hel->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "RGB Device %d hel device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + todo_wine + ok((hal->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "RGB Device %d hal device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); + todo_wine + ok((hel->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "RGB Device %d hel device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); } else if(IsEqualGUID(&IID_IDirect3DHALDevice, Guid)) { @@ -526,6 +539,17 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
ok(hal->dwFlags != 0, "HAL Device %u hal caps has hardware flags %#lx\n", ver, hal->dwFlags); ok(hel->dwFlags != 0, "HAL Device %u hel caps has hardware flags %#lx\n", ver, hel->dwFlags); + + ok(hal->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT, + "HAL Device %d hal device caps does not have D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + todo_wine + ok((hel->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "RGB Device %d hel device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + ok(hal->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX, + "HAL Device %d hal device caps does not have D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); + todo_wine + ok((hel->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "RGB Device %d hel device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); } else if(IsEqualGUID(&IID_IDirect3DRefDevice, Guid)) { @@ -546,6 +570,15 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription, "REF Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE, "REF Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver); + + ok((hal->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "REF Device %d hal device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + ok((hel->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "REF Device %d hel device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + ok((hal->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "REF Device %d hal device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); + ok((hel->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "REF Device %d hel device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); } else if(IsEqualGUID(&IID_IDirect3DRampDevice, Guid)) { @@ -573,6 +606,15 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
ok(hal->dwFlags == 0, "Ramp Device %u hal caps has hardware flags %#lx\n", ver, hal->dwFlags); ok(hel->dwFlags != 0, "Ramp Device %u hel caps has hardware flags %#lx\n", ver, hel->dwFlags); + + ok((hal->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "Ramp Device %d hal device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + ok((hel->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "Ramp Device %d hel device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + ok((hal->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "Ramp Device %d hal device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); + ok((hel->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "Ramp Device %d hel device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); } else if(IsEqualGUID(&IID_IDirect3DMMXDevice, Guid)) { @@ -599,6 +641,15 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
ok(hal->dwFlags == 0, "MMX Device %u hal caps has hardware flags %#lx\n", ver, hal->dwFlags); ok(hel->dwFlags != 0, "MMX Device %u hel caps has hardware flags %#lx\n", ver, hel->dwFlags); + + ok((hal->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "MMX Device %d hal device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + ok((hel->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "MMX Device %d hel device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); + ok((hal->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "MMX Device %d hal device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); + ok((hel->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "MMX Device %d hel device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); } else { @@ -663,6 +714,41 @@ static HRESULT WINAPI enumDevicesLifetimeTest7(char *DeviceDescription, char *De return DDENUMRET_OK; }
+static HRESULT WINAPI enumDevicesCapsTest7(char *DeviceDescription, char *DeviceName, + D3DDEVICEDESC7 *lpdd7, void *Context) +{ + if (IsEqualGUID(&lpdd7->deviceGUID, &IID_IDirect3DTnLHalDevice)) + { + ok(lpdd7->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT, + "TnLHal Device device caps does not have D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n"); + ok(lpdd7->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX, + "TnLHal Device device caps does not have D3DDEVCAPS_DRAWPRIMITIVES2EX set\n"); + } + else if (IsEqualGUID(&lpdd7->deviceGUID, &IID_IDirect3DHALDevice)) + { + todo_wine + ok((lpdd7->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "HAL Device device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n"); + ok(lpdd7->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX, + "HAL Device device caps does not have D3DDEVCAPS_DRAWPRIMITIVES2EX set\n"); + } + else if (IsEqualGUID(&lpdd7->deviceGUID, &IID_IDirect3DRGBDevice)) + { + todo_wine + ok((lpdd7->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, + "RGB Device device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n"); + todo_wine + ok((lpdd7->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, + "RGB Device device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n"); + } + else + { + ok(FALSE, "Unexpected device enumerated: "%s" "%s"\n", DeviceDescription, DeviceName); + } + + return DDENUMRET_OK; +} + /* Check the deviceGUID of devices enumerated by IDirect3D7_EnumDevices. */ static void D3D7EnumTest(void) @@ -782,6 +868,9 @@ static void CapsTest(void) HRESULT hr; UINT ver;
+ hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesCapsTest7, NULL); + ok(hr == D3D_OK, "Got hr %#lx.\n", hr); + hr = DirectDrawCreate(NULL, &dd1, NULL); ok(hr == DD_OK, "Got hr %#lx.\n", hr); hr = IDirectDraw_QueryInterface(dd1, &IID_IDirect3D3, (void **) &d3d3);
From: Zhiyi Zhang zzhang@codeweavers.com
Fix Battle Realms: Zen Edition failing to start. The game expects to find a device without D3DDEVCAPS_HWTRANSFORMANDLIGHT. --- dlls/ddraw/ddraw.c | 7 +++++++ dlls/ddraw/tests/d3d.c | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index bb244222018..64eb7235ebf 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -49,6 +49,7 @@ static struct enum_device_entry char interface_name[100]; char device_name[100]; const GUID *device_guid; + DWORD unsupported_caps; } device_list7[] = { /* T&L HAL device */ @@ -56,6 +57,7 @@ static struct enum_device_entry "WINE Direct3D7 Hardware Transform and Lighting acceleration using WineD3D", "Wine D3D7 T&L HAL", &IID_IDirect3DTnLHalDevice, + 0, },
/* HAL device */ @@ -63,6 +65,7 @@ static struct enum_device_entry "WINE Direct3D7 Hardware acceleration using WineD3D", "Direct3D HAL", &IID_IDirect3DHALDevice, + D3DDEVCAPS_HWTRANSFORMANDLIGHT, },
/* RGB device */ @@ -70,6 +73,7 @@ static struct enum_device_entry "WINE Direct3D7 RGB Software Emulation using WineD3D", "Wine D3D7 RGB", &IID_IDirect3DRGBDevice, + D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_DRAWPRIMITIVES2EX, }, };
@@ -3757,6 +3761,7 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA { struct ddraw *ddraw = impl_from_IDirect3D7(iface); D3DDEVICEDESC7 device_desc7; + DWORD dev_caps; HRESULT hr; size_t i;
@@ -3772,12 +3777,14 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA wined3d_mutex_unlock(); return hr; } + dev_caps = device_desc7.dwDevCaps;
for (i = 0; i < ARRAY_SIZE(device_list7); i++) { HRESULT ret;
device_desc7.deviceGUID = *device_list7[i].device_guid; + device_desc7.dwDevCaps = dev_caps & ~device_list7[i].unsupported_caps; ret = callback(device_list7[i].interface_name, device_list7[i].device_name, &device_desc7, context); if (ret != DDENUMRET_OK) { diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index bfe90f6a511..5d44a109b9f 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -726,7 +726,6 @@ static HRESULT WINAPI enumDevicesCapsTest7(char *DeviceDescription, char *Device } else if (IsEqualGUID(&lpdd7->deviceGUID, &IID_IDirect3DHALDevice)) { - todo_wine ok((lpdd7->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, "HAL Device device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n"); ok(lpdd7->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX, @@ -734,10 +733,8 @@ static HRESULT WINAPI enumDevicesCapsTest7(char *DeviceDescription, char *Device } else if (IsEqualGUID(&lpdd7->deviceGUID, &IID_IDirect3DRGBDevice)) { - todo_wine ok((lpdd7->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, "RGB Device device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n"); - todo_wine ok((lpdd7->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, "RGB Device device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n"); }
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/ddraw/ddraw.c | 5 +++++ dlls/ddraw/tests/d3d.c | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 64eb7235ebf..e52943efa17 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -3882,6 +3882,9 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA hal_desc.dcmColorModel = 0; /* RGB, RAMP and MMX devices cannot report HAL hardware flags */ hal_desc.dwFlags = 0; + /* RGB, REF, RAMP and MMX devices cannot report hardware transform and lighting capability */ + hal_desc.dwDevCaps &= ~(D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_DRAWPRIMITIVES2EX); + hel_desc.dwDevCaps &= ~(D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_DRAWPRIMITIVES2EX);
hr = callback((GUID *)&IID_IDirect3DRGBDevice, reference_description, device_name, &hal_desc, &hel_desc, context); @@ -3906,6 +3909,8 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA | D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE); /* HAL devices have a HEL dcmColorModel of 0 */ hel_desc.dcmColorModel = 0; + /* HAL devices reports hardware transform and lighting capability, but not in hel */ + hel_desc.dwDevCaps &= ~(D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_DRAWPRIMITIVES2EX);
hr = callback((GUID *)&IID_IDirect3DHALDevice, wined3d_description, device_name, &hal_desc, &hel_desc, context); diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index 5d44a109b9f..dffb985ce19 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -518,16 +518,12 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription, ok(hal->dwFlags == 0, "RGB Device %u hal caps has hardware flags %#lx\n", ver, hal->dwFlags); ok(hel->dwFlags != 0, "RGB Device %u hel caps has hardware flags %#lx\n", ver, hel->dwFlags);
- todo_wine ok((hal->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, "RGB Device %d hal device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); - todo_wine ok((hel->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, "RGB Device %d hel device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); - todo_wine ok((hal->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, "RGB Device %d hal device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); - todo_wine ok((hel->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, "RGB Device %d hel device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); } @@ -542,12 +538,10 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
ok(hal->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT, "HAL Device %d hal device caps does not have D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); - todo_wine ok((hel->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0, "RGB Device %d hel device caps has D3DDEVCAPS_HWTRANSFORMANDLIGHT set\n", ver); ok(hal->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX, "HAL Device %d hal device caps does not have D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); - todo_wine ok((hel->dwDevCaps & D3DDEVCAPS_DRAWPRIMITIVES2EX) == 0, "RGB Device %d hel device caps has D3DDEVCAPS_DRAWPRIMITIVES2EX set\n", ver); }