Skip to content

Commit

Permalink
Disable imgui and share data between instances
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Aug 24, 2024
1 parent 47be4eb commit ec472d5
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 117 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7110
#define BUILD_NUMBER 7111
5 changes: 4 additions & 1 deletion GDI/WndProc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ LRESULT CALLBACK WndProc::Handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPa

// Handle debug overlay
#ifdef ENABLE_DEBUGOVERLAY
ImGuiWndProc(hWnd, Msg, wParam, lParam);
if (Config.EnableImgui)
{
ImGuiWndProc(hWnd, Msg, wParam, lParam);
}
#endif

LRESULT lr = CallWndProc(pWndProc, hWnd, Msg, wParam, lParam);
Expand Down
1 change: 1 addition & 0 deletions Settings/AllSettings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ FullscreenWindowMode = 0
ForceExclusiveFullscreen = 0
ForceMixedVertexProcessing = 0
ForceSystemMemVertexCache = 0
EnableImgui = 0
SetSwapEffectShim = 0
DisableMaxWindowedMode = 0
ForceDirect3D9On12 = 0
Expand Down
2 changes: 2 additions & 0 deletions Settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
visit(EnableD3d9Wrapper) \
visit(EnableDinput8Wrapper) \
visit(EnableDsoundWrapper) \
visit(EnableImgui) \
visit(EnableVSync) \
visit(EnableWindowMode) \
visit(ExcludeProcess) \
Expand Down Expand Up @@ -257,6 +258,7 @@ struct CONFIG
DWORD EnableD3d9Wrapper = 0; // Enables the d3d9 wrapper
bool EnableDinput8Wrapper = false; // Enables the dinput8 wrapper
bool EnableDsoundWrapper = false; // Enables the dsound wrapper
bool EnableImgui = false; // Enables imgui for debugging
bool EnableWindowMode = false; // Enables WndMode for d3d9 wrapper
bool EnableVSync = false; // Enables VSync for d3d9 wrapper
bool FixHighFrequencyMouse = false; // Gets the latest mouse status by merging the DirectInput buffer data
Expand Down
38 changes: 19 additions & 19 deletions d3d9/AddressLookupTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,69 +56,69 @@ class AddressLookupTableD3d9
template <>
struct AddressCacheIndex<m_IDirect3DVolumeTexture9> { static constexpr UINT CacheIndex = 15; };

m_IDirect3D9Ex* CreateInterface(m_IDirect3D9Ex* Proxy, void*, REFIID riid)
m_IDirect3D9Ex* CreateInterface(m_IDirect3D9Ex* Proxy, void*, REFIID riid, void*)
{
return new m_IDirect3D9Ex(static_cast<m_IDirect3D9Ex*>(Proxy), riid);
}
m_IDirect3DDevice9Ex* CreateInterface(m_IDirect3DDevice9Ex* Proxy, m_IDirect3D9Ex* Device, REFIID riid)
m_IDirect3DDevice9Ex* CreateInterface(m_IDirect3DDevice9Ex* Proxy, m_IDirect3D9Ex* Device, REFIID riid, UINT Data)
{
return new m_IDirect3DDevice9Ex(static_cast<m_IDirect3DDevice9Ex*>(Proxy), Device, riid);
return new m_IDirect3DDevice9Ex(static_cast<m_IDirect3DDevice9Ex*>(Proxy), Device, riid, Data);
}
m_IDirect3DCubeTexture9* CreateInterface(m_IDirect3DCubeTexture9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DCubeTexture9* CreateInterface(m_IDirect3DCubeTexture9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DCubeTexture9(static_cast<m_IDirect3DCubeTexture9*>(Proxy), Device);
}
m_IDirect3DIndexBuffer9* CreateInterface(m_IDirect3DIndexBuffer9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DIndexBuffer9* CreateInterface(m_IDirect3DIndexBuffer9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DIndexBuffer9(static_cast<m_IDirect3DIndexBuffer9*>(Proxy), Device);
}
m_IDirect3DPixelShader9* CreateInterface(m_IDirect3DPixelShader9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DPixelShader9* CreateInterface(m_IDirect3DPixelShader9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DPixelShader9(static_cast<m_IDirect3DPixelShader9*>(Proxy), Device);
}
m_IDirect3DQuery9* CreateInterface(m_IDirect3DQuery9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DQuery9* CreateInterface(m_IDirect3DQuery9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DQuery9(static_cast<m_IDirect3DQuery9*>(Proxy), Device);
}
m_IDirect3DStateBlock9* CreateInterface(m_IDirect3DStateBlock9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DStateBlock9* CreateInterface(m_IDirect3DStateBlock9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DStateBlock9(static_cast<m_IDirect3DStateBlock9*>(Proxy), Device);
}
m_IDirect3DSurface9* CreateInterface(m_IDirect3DSurface9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DSurface9* CreateInterface(m_IDirect3DSurface9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DSurface9(static_cast<m_IDirect3DSurface9*>(Proxy), Device);
}
m_IDirect3DSwapChain9Ex* CreateInterface(m_IDirect3DSwapChain9Ex* Proxy, m_IDirect3DDevice9Ex* Device, REFIID riid)
m_IDirect3DSwapChain9Ex* CreateInterface(m_IDirect3DSwapChain9Ex* Proxy, m_IDirect3DDevice9Ex* Device, REFIID riid, void*)
{
return new m_IDirect3DSwapChain9Ex(static_cast<m_IDirect3DSwapChain9Ex*>(Proxy), Device, riid);
}
m_IDirect3DTexture9* CreateInterface(m_IDirect3DTexture9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DTexture9* CreateInterface(m_IDirect3DTexture9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DTexture9(static_cast<m_IDirect3DTexture9*>(Proxy), Device);
}
m_IDirect3DVertexBuffer9* CreateInterface(m_IDirect3DVertexBuffer9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DVertexBuffer9* CreateInterface(m_IDirect3DVertexBuffer9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DVertexBuffer9(static_cast<m_IDirect3DVertexBuffer9*>(Proxy), Device);
}
m_IDirect3DVertexDeclaration9* CreateInterface(m_IDirect3DVertexDeclaration9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DVertexDeclaration9* CreateInterface(m_IDirect3DVertexDeclaration9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DVertexDeclaration9(static_cast<m_IDirect3DVertexDeclaration9*>(Proxy), Device);
}
m_IDirect3DVertexShader9* CreateInterface(m_IDirect3DVertexShader9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DVertexShader9* CreateInterface(m_IDirect3DVertexShader9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DVertexShader9(static_cast<m_IDirect3DVertexShader9*>(Proxy), Device);
}
m_IDirect3DVolume9* CreateInterface(m_IDirect3DVolume9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DVolume9* CreateInterface(m_IDirect3DVolume9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DVolume9(static_cast<m_IDirect3DVolume9*>(Proxy), Device);
}
m_IDirect3DVolumeTexture9* CreateInterface(m_IDirect3DVolumeTexture9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID)
m_IDirect3DVolumeTexture9* CreateInterface(m_IDirect3DVolumeTexture9* Proxy, m_IDirect3DDevice9Ex* Device, REFIID, void*)
{
return new m_IDirect3DVolumeTexture9(static_cast<m_IDirect3DVolumeTexture9*>(Proxy), Device);
}

template <typename T, typename D>
T *FindAddress(void* Proxy, D* Device, REFIID riid)
template <typename T, typename D, typename L>
T *FindAddress(void* Proxy, D* Device, REFIID riid, L Data)
{
if (!Proxy)
{
Expand All @@ -133,7 +133,7 @@ class AddressLookupTableD3d9
return static_cast<T *>(it->second);
}

return CreateInterface((T*)Proxy, Device, riid);
return CreateInterface((T*)Proxy, Device, riid, Data);
}

template <typename T>
Expand Down
14 changes: 9 additions & 5 deletions d3d9/IDirect3D9Ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ HRESULT m_IDirect3D9Ex::QueryInterface(REFIID riid, void** ppvObj)
{
if (riid == IID_IDirect3D9 || riid == IID_IDirect3D9Ex)
{
*ppvObj = ProxyAddressLookupTable9.FindAddress<m_IDirect3D9Ex, void>(*ppvObj, nullptr, riid);
*ppvObj = ProxyAddressLookupTable9.FindAddress<m_IDirect3D9Ex, void>(*ppvObj, nullptr, riid, nullptr);
}
else
{
Expand Down Expand Up @@ -294,8 +294,10 @@ HRESULT m_IDirect3D9Ex::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND h
DeviceDetails.DeviceMultiSampleType = pPresentationParameters->MultiSampleType;
DeviceDetails.DeviceMultiSampleQuality = pPresentationParameters->MultiSampleQuality;

*ppReturnedDeviceInterface = new m_IDirect3DDevice9Ex((LPDIRECT3DDEVICE9EX)*ppReturnedDeviceInterface, this, IID_IDirect3DDevice9);
((m_IDirect3DDevice9Ex*)(*ppReturnedDeviceInterface))->SetDeviceDetails(DeviceDetails);
UINT DDKey = (UINT)ppReturnedDeviceInterface + (UINT)*ppReturnedDeviceInterface + (UINT)DeviceDetails.DeviceWindow;
DeviceDetailsMap[DDKey] = DeviceDetails;

*ppReturnedDeviceInterface = new m_IDirect3DDevice9Ex((LPDIRECT3DDEVICE9EX)*ppReturnedDeviceInterface, this, IID_IDirect3DDevice9, DDKey);

return D3D_OK;
}
Expand Down Expand Up @@ -365,8 +367,10 @@ HRESULT m_IDirect3D9Ex::CreateDeviceEx(THIS_ UINT Adapter, D3DDEVTYPE DeviceType
DeviceDetails.DeviceMultiSampleType = pPresentationParameters->MultiSampleType;
DeviceDetails.DeviceMultiSampleQuality = pPresentationParameters->MultiSampleQuality;

*ppReturnedDeviceInterface = new m_IDirect3DDevice9Ex(*ppReturnedDeviceInterface, this, IID_IDirect3DDevice9Ex);
((m_IDirect3DDevice9Ex*)(*ppReturnedDeviceInterface))->SetDeviceDetails(DeviceDetails);
UINT DDKey = (UINT)ppReturnedDeviceInterface + (UINT)*ppReturnedDeviceInterface + (UINT)DeviceDetails.DeviceWindow;
DeviceDetailsMap[DDKey] = DeviceDetails;

*ppReturnedDeviceInterface = new m_IDirect3DDevice9Ex(*ppReturnedDeviceInterface, this, IID_IDirect3DDevice9Ex, DDKey);

return D3D_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion d3d9/IDirect3DCubeTexture9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ HRESULT m_IDirect3DCubeTexture9::GetCubeMapSurface(THIS_ D3DCUBEMAP_FACES FaceTy

if (SUCCEEDED(hr) && ppCubeMapSurface)
{
*ppCubeMapSurface = ProxyAddressLookupTable9.FindAddress<m_IDirect3DSurface9, m_IDirect3DDevice9Ex>(*ppCubeMapSurface, m_pDeviceEx, IID_IDirect3DTexture9);
*ppCubeMapSurface = ProxyAddressLookupTable9.FindAddress<m_IDirect3DSurface9, m_IDirect3DDevice9Ex>(*ppCubeMapSurface, m_pDeviceEx, IID_IDirect3DSurface9, nullptr);
}

return hr;
Expand Down
Loading

0 comments on commit ec472d5

Please sign in to comment.