1
0
Fork 0
mirror of https://gitlab.com/Mr_Goldberg/goldberg_emulator.git synced 2024-11-14 10:50:13 +01:00

Fixed everything that I've forgot

This commit is contained in:
Nemirtingas 2019-08-16 19:21:30 +02:00
parent d06fbba104
commit 5d4b4371f3
8 changed files with 66 additions and 76 deletions

View file

@ -9,8 +9,7 @@
#include <impls/imgui_impl_win32.h>
#include <impls/imgui_impl_dx10.h>
// This is created by DX10_Hook::Create, and deleted by the Hook_Manager if not used
static DX10_Hook* hook;
DX10_Hook* DX10_Hook::_inst = nullptr;
bool DX10_Hook::start_hook()
{
@ -146,20 +145,20 @@ void DX10_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
HRESULT STDMETHODCALLTYPE DX10_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags)
{
hook->prepareForOverlay(_this);
return (_this->*hook->Present)(SyncInterval, Flags);
DX10_Hook::Inst()->prepareForOverlay(_this);
return (_this->*DX10_Hook::Inst()->Present)(SyncInterval, Flags);
}
HRESULT STDMETHODCALLTYPE DX10_Hook::MyResizeTarget(IDXGISwapChain* _this, const DXGI_MODE_DESC* pNewTargetParameters)
{
hook->resetRenderState();
return (_this->*hook->ResizeTarget)(pNewTargetParameters);
DX10_Hook::Inst()->resetRenderState();
return (_this->*DX10_Hook::Inst()->ResizeTarget)(pNewTargetParameters);
}
HRESULT STDMETHODCALLTYPE DX10_Hook::MyResizeBuffers(IDXGISwapChain* _this, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags)
{
hook->resetRenderState();
return (_this->*hook->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags);
DX10_Hook::Inst()->resetRenderState();
return (_this->*DX10_Hook::Inst()->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags);
}
DX10_Hook::DX10_Hook():
@ -189,18 +188,15 @@ DX10_Hook::~DX10_Hook()
if (_hooked)
resetRenderState();
hook = nullptr;
_inst = nullptr;
}
void DX10_Hook::Create()
DX10_Hook* DX10_Hook::Inst()
{
if (hook == nullptr)
{
hook = new DX10_Hook;
hook->start_hook();
// Register the hook to the Hook Manager
Hook_Manager::Inst().AddHook(hook);
}
if (_inst == nullptr)
_inst = new DX10_Hook;
return _inst;
}
void DX10_Hook::loadFunctions(ID3D10Device *pDevice, IDXGISwapChain *pSwapChain)

View file

@ -13,6 +13,8 @@ public:
static constexpr const char *DLL_NAME = "d3d10.dll";
private:
static DX10_Hook* _inst;
// Variables
bool initialized;
ID3D10Device* pDevice;

View file

@ -9,8 +9,7 @@
#include <impls/imgui_impl_win32.h>
#include <impls/imgui_impl_dx11.h>
// This is created by DX11_Hook::Create, and deleted by the Hook_Manager if not used
static DX11_Hook* hook;
DX11_Hook* DX11_Hook::_inst = nullptr;
HRESULT GetDeviceAndCtxFromSwapchain(IDXGISwapChain* pSwapChain, ID3D11Device** ppDevice, ID3D11DeviceContext** ppContext)
{
@ -163,21 +162,21 @@ void DX11_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
HRESULT STDMETHODCALLTYPE DX11_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags)
{
hook->prepareForOverlay(_this);
DX11_Hook::Inst()->prepareForOverlay(_this);
return (_this->*hook->Present)(SyncInterval, Flags);
return (_this->*DX11_Hook::Inst()->Present)(SyncInterval, Flags);
}
HRESULT STDMETHODCALLTYPE DX11_Hook::MyResizeTarget(IDXGISwapChain* _this, const DXGI_MODE_DESC* pNewTargetParameters)
{
hook->resetRenderState();
return (_this->*hook->ResizeTarget)(pNewTargetParameters);
DX11_Hook::Inst()->resetRenderState();
return (_this->*DX11_Hook::Inst()->ResizeTarget)(pNewTargetParameters);
}
HRESULT STDMETHODCALLTYPE DX11_Hook::MyResizeBuffers(IDXGISwapChain* _this, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags)
{
hook->resetRenderState();
return (_this->*hook->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags);
DX11_Hook::Inst()->resetRenderState();
return (_this->*DX11_Hook::Inst()->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags);
}
DX11_Hook::DX11_Hook():
@ -207,18 +206,15 @@ DX11_Hook::~DX11_Hook()
if (_hooked)
resetRenderState();
hook = nullptr;
_inst = nullptr;
}
void DX11_Hook::Create()
DX11_Hook* DX11_Hook::Inst()
{
if (hook == nullptr)
{
hook = new DX11_Hook;
hook->start_hook();
// Register the hook to the Hook Manager
Hook_Manager::Inst().AddHook(hook);
}
if (_inst == nullptr)
_inst = new DX11_Hook;
return _inst;
}
void DX11_Hook::loadFunctions(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain)

View file

@ -13,6 +13,8 @@ public:
static constexpr const char *DLL_NAME = "d3d11.dll";
private:
static DX11_Hook* _inst;
// Variables
bool initialized;
ID3D11DeviceContext* pContext;

View file

@ -9,6 +9,8 @@
#include <impls/imgui_impl_win32.h>
#include <impls/imgui_impl_dx12.h>
DX12_Hook* DX12_Hook::_inst = nullptr;
bool DX12_Hook::start_hook()
{
if (!_hooked)
@ -112,21 +114,21 @@ void DX12_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
HRESULT STDMETHODCALLTYPE DX12_Hook::MyPresent(IDXGISwapChain *_this, UINT SyncInterval, UINT Flags)
{
hook->prepareForOverlay(_this);
DX12_Hook::Inst()->prepareForOverlay(_this);
return (_this->*hook->Present)(SyncInterval, Flags);
return (_this->*DX12_Hook::Inst()->Present)(SyncInterval, Flags);
}
HRESULT STDMETHODCALLTYPE DX12_Hook::MyResizeTarget(IDXGISwapChain* _this, const DXGI_MODE_DESC* pNewTargetParameters)
{
hook->resetRenderState();
return (_this->*hook->ResizeTarget)(pNewTargetParameters);
DX12_Hook::Inst()->resetRenderState();
return (_this->*DX12_Hook::Inst()->ResizeTarget)(pNewTargetParameters);
}
HRESULT STDMETHODCALLTYPE DX12_Hook::MyResizeBuffers(IDXGISwapChain* _this, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags)
{
hook->resetRenderState();
return (_this->*hook->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags);
DX12_Hook::Inst()->resetRenderState();
return (_this->*DX12_Hook::Inst()->ResizeBuffers)(BufferCount, Width, Height, NewFormat, SwapChainFlags);
}
DX12_Hook::DX12_Hook():
@ -157,18 +159,15 @@ DX12_Hook::~DX12_Hook()
if (_hooked)
resetRenderState();
hook = nullptr;
_inst = nullptr;
}
void DX12_Hook::Create()
DX12_Hook* DX12_Hook::Inst()
{
if (hook == nullptr)
{
hook = new DX12_Hook;
hook->start_hook();
// Register the hook to the Hook Manager
Hook_Manager::Inst().AddHook(hook);
}
if (_inst == nullptr)
_inst = new DX12_Hook();
return _inst;
}
void DX12_Hook::loadFunctions(ID3D12Device *pDevice, IDXGISwapChain *pSwapChain)

View file

@ -13,6 +13,8 @@ public:
static constexpr const char *DLL_NAME = "d3d12.dll";
private:
static DX12_Hook* _inst;
// Variables
bool initialized;
ID3D12CommandAllocator* pCmdAlloc;

View file

@ -10,13 +10,7 @@
#include "steam_overlay.h"
static DX9_Hook* hook;
//////////////////////////////////////////////////////////////////
///////// /////////
///////// This hook doesn't support game resize for now /////////
///////// /////////
//////////////////////////////////////////////////////////////////
DX9_Hook* DX9_Hook::_inst = nullptr;
bool DX9_Hook::start_hook()
{
@ -144,29 +138,29 @@ void DX9_Hook::prepareForOverlay(IDirect3DDevice9 *pDevice)
HRESULT STDMETHODCALLTYPE DX9_Hook::MyReset(IDirect3DDevice9* _this, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
hook->resetRenderState();
return (_this->*hook->Reset)(pPresentationParameters);
DX9_Hook::Inst()->resetRenderState();
return (_this->*DX9_Hook::Inst()->Reset)(pPresentationParameters);
}
HRESULT STDMETHODCALLTYPE DX9_Hook::MyEndScene(IDirect3DDevice9* _this)
{
if( !hook->uses_present )
hook->prepareForOverlay(_this);
return (_this->*hook->EndScene)();
if( !DX9_Hook::Inst()->uses_present )
DX9_Hook::Inst()->prepareForOverlay(_this);
return (_this->*DX9_Hook::Inst()->EndScene)();
}
HRESULT STDMETHODCALLTYPE DX9_Hook::MyPresent(IDirect3DDevice9* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion)
{
hook->uses_present = true;
hook->prepareForOverlay(_this);
return (_this->*hook->Present)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
DX9_Hook::Inst()->uses_present = true;
DX9_Hook::Inst()->prepareForOverlay(_this);
return (_this->*DX9_Hook::Inst()->Present)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
HRESULT STDMETHODCALLTYPE DX9_Hook::MyPresentEx(IDirect3DDevice9Ex* _this, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags)
{
hook->uses_present = true;
hook->prepareForOverlay(_this);
return (_this->*hook->PresentEx)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
DX9_Hook::Inst()->uses_present = true;
DX9_Hook::Inst()->prepareForOverlay(_this);
return (_this->*DX9_Hook::Inst()->PresentEx)(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
}
DX9_Hook::DX9_Hook():
@ -204,18 +198,15 @@ DX9_Hook::~DX9_Hook()
ImGui::DestroyContext();
}
hook = nullptr;
_inst = nullptr;
}
void DX9_Hook::Create()
DX9_Hook* DX9_Hook::Inst()
{
if( hook == nullptr )
{
hook = new DX9_Hook;
hook->start_hook();
// Register the hook to the Hook Manager
Hook_Manager::Inst().AddHook(hook);
}
if( _inst == nullptr )
_inst = new DX9_Hook;
return _inst;
}
void DX9_Hook::loadFunctions(IDirect3DDevice9Ex* pDeviceEx)

View file

@ -13,6 +13,8 @@ public:
static constexpr const char *DLL_NAME = "d3d9.dll";
private:
static DX9_Hook* _inst;
// Variables
bool initialized;
bool uses_present;