diff --git a/patches/ddraw-version-check/0001-ddraw-Return-correct-devices-based-off-requested-Dir.patch b/patches/ddraw-version-check/0001-ddraw-Return-correct-devices-based-off-requested-Dir.patch index a02889e7..12cb5e9f 100644 --- a/patches/ddraw-version-check/0001-ddraw-Return-correct-devices-based-off-requested-Dir.patch +++ b/patches/ddraw-version-check/0001-ddraw-Return-correct-devices-based-off-requested-Dir.patch @@ -1,18 +1,18 @@ -From 16d001f5562c37ac293fa547feef19887e635363 Mon Sep 17 00:00:00 2001 +From e4688a88901a1c13b2df67a0444c34e3ee02bbab Mon Sep 17 00:00:00 2001 From: Andrew D'Addesio Date: Fri, 8 Feb 2019 18:48:33 -1000 Subject: [PATCH] ddraw: Return correct devices based off requested DirectX version. --- - dlls/ddraw/ddraw.c | 231 +++++++++++++++++++++++++-------------------- - 1 file changed, 130 insertions(+), 101 deletions(-) + dlls/ddraw/ddraw.c | 232 +++++++++++++++++++++++++-------------------- + 1 file changed, 129 insertions(+), 103 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c -index 83eeb33589e..324a149a425 100644 +index 5887854556b..5ac95dc3043 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c -@@ -47,37 +47,80 @@ static const DDDEVICEIDENTIFIER2 deviceidentifier = +@@ -44,37 +44,80 @@ static const DDDEVICEIDENTIFIER2 deviceidentifier = 0 }; @@ -28,7 +28,7 @@ index 83eeb33589e..324a149a425 100644 + char device_desc[100]; char device_name[100]; const GUID *device_guid; - DWORD remove_caps; + DWORD unsupported_caps; -} device_list7[] = +} device_list[] = { @@ -38,7 +38,7 @@ index 83eeb33589e..324a149a425 100644 - "WINE Direct3D7 Hardware Transform and Lighting acceleration using WineD3D", - "Wine D3D7 T&L HAL", - &IID_IDirect3DTnLHalDevice, -+ D3D_VERSION(1)|D3D_VERSION(2), ++ D3D_VERSION(1) | D3D_VERSION(2), + "WineD3D Ramp Software Emulation", + "Ramp Emulation", + &IID_IDirect3DRampDevice, @@ -49,20 +49,20 @@ index 83eeb33589e..324a149a425 100644 + /* RGB Emulation (D3D 1-7) */ { - "WINE Direct3D7 Hardware acceleration using WineD3D", -+ D3D_VERSION(1)|D3D_VERSION(2)|D3D_VERSION(3)|D3D_VERSION(7), ++ D3D_VERSION(1) | D3D_VERSION(2) | D3D_VERSION(3) | D3D_VERSION(7), + "WineD3D RGB Software Emulation", + "RGB Emulation", + &IID_IDirect3DRGBDevice, -+ D3DDEVCAPS_HWTRANSFORMANDLIGHT, ++ D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWRASTERIZATION, + }, + + /* Direct3D HAL (D3D 1-7) */ + { -+ D3D_VERSION(1)|D3D_VERSION(2)|D3D_VERSION(3)|D3D_VERSION(7), ++ D3D_VERSION(1) | D3D_VERSION(2) | D3D_VERSION(3) | D3D_VERSION(7), + "WineD3D Hardware Acceleration", "Direct3D HAL", &IID_IDirect3DHALDevice, - 0, + D3DDEVCAPS_HWTRANSFORMANDLIGHT, }, - /* RGB device */ @@ -71,13 +71,13 @@ index 83eeb33589e..324a149a425 100644 - "WINE Direct3D7 RGB Software Emulation using WineD3D", - "Wine D3D7 RGB", - &IID_IDirect3DRGBDevice, -- D3DDEVCAPS_HWTRANSFORMANDLIGHT, +- D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWRASTERIZATION, + D3D_VERSION(2), + "WineD3D MMX Software Emulation", + "MMX Emulation", + &IID_IDirect3DMMXDevice, + 0, -+ }, + }, + + /* Direct3D T&L HAL (D3D7 only) */ + { @@ -86,7 +86,7 @@ index 83eeb33589e..324a149a425 100644 + "Direct3D T&L HAL", + &IID_IDirect3DTnLHalDevice, + 0, - }, ++ }, + + /* In the future, we may wish to add the "Reference Rasterizer" and + * "Null device", which are only available in DX6-8 and must be explicitly @@ -106,7 +106,7 @@ index 83eeb33589e..324a149a425 100644 }; static void STDMETHODCALLTYPE ddraw_null_wined3d_object_destroyed(void *parent) {} -@@ -1389,15 +1432,6 @@ HRESULT ddraw_get_d3dcaps(const struct ddraw *ddraw, D3DDEVICEDESC7 *caps) +@@ -1415,15 +1458,6 @@ HRESULT ddraw_get_d3dcaps(const struct ddraw *ddraw, D3DDEVICEDESC7 *caps) D3DPTADDRESSCAPS_WRAP | D3DPTADDRESSCAPS_MIRROR | D3DPTADDRESSCAPS_CLAMP | D3DPTADDRESSCAPS_BORDER | D3DPTADDRESSCAPS_INDEPENDENTUV); @@ -122,7 +122,7 @@ index 83eeb33589e..324a149a425 100644 /* Fill the missing members, and do some fixup */ caps->dpcLineCaps.dwSize = sizeof(caps->dpcLineCaps); caps->dpcLineCaps.dwTextureBlendCaps = D3DPTBLENDCAPS_ADD -@@ -3713,8 +3747,7 @@ static HRESULT WINAPI ddraw1_DuplicateSurface(IDirectDraw *iface, IDirectDrawSur +@@ -3746,8 +3780,7 @@ static HRESULT WINAPI ddraw1_DuplicateSurface(IDirectDraw *iface, IDirectDrawSur /***************************************************************************** * IDirect3D7::EnumDevices * @@ -132,8 +132,8 @@ index 83eeb33589e..324a149a425 100644 * * Params: * callback: Function to call for each enumerated device -@@ -3747,14 +3780,17 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA - +@@ -3779,13 +3812,16 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA + } dev_caps = device_desc7.dwDevCaps; - for (i = 0; i < ARRAY_SIZE(device_list7); i++) @@ -142,19 +142,18 @@ index 83eeb33589e..324a149a425 100644 HRESULT ret; - device_desc7.deviceGUID = *device_list7[i].device_guid; -- device_desc7.dwDevCaps = dev_caps & ~device_list7[i].remove_caps; +- 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 (!(device_list[i].version_mask & D3D_VERSION(ddraw->d3dversion))) + continue; + + device_desc7.deviceGUID = *device_list[i].device_guid; -+ device_desc7.dwDevCaps = dev_caps & ~device_list[i].remove_caps; - -- ret = callback(device_list7[i].interface_name, device_list7[i].device_name, &device_desc7, context); ++ device_desc7.dwDevCaps = dev_caps & ~device_list[i].unsupported_caps; + ret = callback(device_list[i].device_name, device_list[i].device_name, &device_desc7, context); if (ret != DDENUMRET_OK) { TRACE("Application cancelled the enumeration.\n"); -@@ -3770,11 +3806,21 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA +@@ -3801,11 +3837,21 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA return D3D_OK; } @@ -178,7 +177,7 @@ index 83eeb33589e..324a149a425 100644 * * Versions 1, 2 and 3 * -@@ -3789,18 +3835,18 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA +@@ -3820,18 +3866,18 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA *****************************************************************************/ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBACK callback, void *context) { @@ -206,7 +205,7 @@ index 83eeb33589e..324a149a425 100644 TRACE("iface %p, callback %p, context %p.\n", iface, callback, context); -@@ -3809,52 +3855,58 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA +@@ -3840,55 +3886,60 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA wined3d_mutex_lock(); @@ -246,9 +245,15 @@ index 83eeb33589e..324a149a425 100644 - * flag set. This way it refuses the emulation device, and HAL devices - * never have POW2 unset in d3d7 on windows. */ - if (ddraw->d3dversion != 1) -- { ++ clear_device_desc(&empty_desc1); ++ empty_desc1.dwSize = desc_size; ++ ++ for (i = 0; i < ARRAY_SIZE(device_list); i++) + { - static CHAR reference_description[] = "RGB Direct3D emulation"; -- ++ if (!(device_list[i].version_mask & D3D_VERSION(ddraw->d3dversion))) ++ continue; + - TRACE("Enumerating WineD3D D3DDevice interface.\n"); - hal_desc = device_desc1; - hel_desc = device_desc1; @@ -261,22 +266,16 @@ index 83eeb33589e..324a149a425 100644 - hal_desc.dcmColorModel = 0; - /* RGB, RAMP and MMX devices cannot report HAL hardware flags */ - hal_desc.dwFlags = 0; -- -- hr = callback((GUID *)&IID_IDirect3DRGBDevice, reference_description, -- device_name, &hal_desc, &hel_desc, context); -- if (hr != D3DENUMRET_OK) -+ clear_device_desc(&empty_desc1); -+ empty_desc1.dwSize = desc_size; -+ -+ for (i = 0; i < ARRAY_SIZE(device_list); i++) -+ { -+ if (!(device_list[i].version_mask & D3D_VERSION(ddraw->d3dversion))) -+ continue; -+ +- /* RGB, REF, RAMP and MMX devices don't report hardware transform and lighting capability */ +- hal_desc.dwDevCaps &= ~(D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWRASTERIZATION); +- hel_desc.dwDevCaps &= ~(D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWRASTERIZATION); + if (IsEqualGUID(&IID_IDirect3DHALDevice, device_list[i].device_guid)) + { + hal_desc = device_desc1; -+ + +- hr = callback((GUID *)&IID_IDirect3DRGBDevice, reference_description, +- device_name, &hal_desc, &hel_desc, context); +- if (hr != D3DENUMRET_OK) + /* The HAL device's hel_desc is almost empty -- but not completely */ + hel_desc = empty_desc1; + hel_desc.dwFlags = D3DDD_COLORMODEL | D3DDD_DEVCAPS | D3DDD_TRANSFORMCAPS @@ -296,6 +295,8 @@ index 83eeb33589e..324a149a425 100644 + /* Ramp device supports grayscale only */ + if (IsEqualGUID(&IID_IDirect3DRampDevice, device_list[i].device_guid)) + hel_desc.dcmColorModel = D3DCOLOR_MONO; ++ /* RGB, REF, RAMP and MMX devices don't report hardware transform and lighting capability */ ++ hel_desc.dwDevCaps &= ~(D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWRASTERIZATION); + } + + hr = callback((GUID *)device_list[i].device_guid, device_list[i].device_desc, @@ -304,7 +305,7 @@ index 83eeb33589e..324a149a425 100644 { TRACE("Application cancelled the enumeration.\n"); wined3d_mutex_unlock(); -@@ -3862,29 +3914,6 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA +@@ -3896,31 +3947,6 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA } } @@ -321,6 +322,8 @@ index 83eeb33589e..324a149a425 100644 - | D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE); - /* HAL devices have a HEL dcmColorModel of 0 */ - hel_desc.dcmColorModel = 0; +- /* HAL devices report 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); @@ -335,5 +338,5 @@ index 83eeb33589e..324a149a425 100644 wined3d_mutex_unlock(); -- -2.20.1 +2.43.0 diff --git a/patches/ddraw-version-check/definition b/patches/ddraw-version-check/definition index c67bf740..a1b0659b 100644 --- a/patches/ddraw-version-check/definition +++ b/patches/ddraw-version-check/definition @@ -8,4 +8,3 @@ # The Sims Online Fixes: [19153] Resident Evil 1 fails to start (needs IDirect3D3::EnumDevices() to return a device named "RGB Emulation") Depends: ddraw-Device_Caps -Disabled: True