From a97d992a37ac22023f9bce4a84d0869e5614101f Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Mon, 13 Nov 2023 13:32:25 +0800 Subject: [PATCH] disable createquery option for re1, 0, rev and rev2 --- .../scripts/ResidentEvil.FusionFix.ini | 1 + .../scripts/ResidentEvil0.FusionFix.ini | 1 + .../ResidentEvilRevelations.FusionFix.ini | 3 ++- .../ResidentEvilRevelations2.FusionFix.ini | 5 ++-- source/ResidentEvil.FusionFix/dllmain.cpp | 25 +++++++++++++++++++ source/ResidentEvil0.FusionFix/dllmain.cpp | 25 +++++++++++++++++++ .../dllmain.cpp | 25 +++++++++++++++++++ .../dllmain.cpp | 25 +++++++++++++++++++ 8 files changed, 107 insertions(+), 3 deletions(-) diff --git a/data/ResidentEvil.FusionFix/scripts/ResidentEvil.FusionFix.ini b/data/ResidentEvil.FusionFix/scripts/ResidentEvil.FusionFix.ini index 1e7f8acd6..7f17ba00e 100644 --- a/data/ResidentEvil.FusionFix/scripts/ResidentEvil.FusionFix.ini +++ b/data/ResidentEvil.FusionFix/scripts/ResidentEvil.FusionFix.ini @@ -7,3 +7,4 @@ LightSyncRGB = 1 // Only Logitech hardware is supported, requir DisableNoise = 0 DisableColorCorrection = 0 DisableFog = 0 +DisableCreateQuery = 0 // Use for potential performance improvement diff --git a/data/ResidentEvil0.FusionFix/scripts/ResidentEvil0.FusionFix.ini b/data/ResidentEvil0.FusionFix/scripts/ResidentEvil0.FusionFix.ini index 1cfbe565f..8684fde42 100644 --- a/data/ResidentEvil0.FusionFix/scripts/ResidentEvil0.FusionFix.ini +++ b/data/ResidentEvil0.FusionFix/scripts/ResidentEvil0.FusionFix.ini @@ -6,3 +6,4 @@ LightSyncRGB = 1 // Only Logitech hardware is supported, requir DisableNoise = 0 DisableColorCorrection = 0 DisableFog = 0 +DisableCreateQuery = 0 // Use for potential performance improvement diff --git a/data/ResidentEvilRevelations.FusionFix/scripts/ResidentEvilRevelations.FusionFix.ini b/data/ResidentEvilRevelations.FusionFix/scripts/ResidentEvilRevelations.FusionFix.ini index 56bbe959d..898557f95 100644 --- a/data/ResidentEvilRevelations.FusionFix/scripts/ResidentEvilRevelations.FusionFix.ini +++ b/data/ResidentEvilRevelations.FusionFix/scripts/ResidentEvilRevelations.FusionFix.ini @@ -1,4 +1,5 @@ [MAIN] BorderlessWindowed = 1 DisableDamageOverlay = 1 -FOVFactor = 1.0 \ No newline at end of file +FOVFactor = 1.0 +DisableCreateQuery = 0 // Use for potential performance improvement \ No newline at end of file diff --git a/data/ResidentEvilRevelations2.FusionFix/scripts/ResidentEvilRevelations2.FusionFix.ini b/data/ResidentEvilRevelations2.FusionFix/scripts/ResidentEvilRevelations2.FusionFix.ini index 69b72413d..0fe87645e 100644 --- a/data/ResidentEvilRevelations2.FusionFix/scripts/ResidentEvilRevelations2.FusionFix.ini +++ b/data/ResidentEvilRevelations2.FusionFix/scripts/ResidentEvilRevelations2.FusionFix.ini @@ -3,5 +3,6 @@ SkipIntro = 1 BorderlessWindowed = 1 DisableDamageOverlay = 1 DisableFilmGrain = 1 -DisableFade = 0 // not recommended -FOVFactor = 1.0 \ No newline at end of file +DisableFade = 0 // Not recommended +FOVFactor = 1.0 +DisableCreateQuery = 0 // Use for potential performance improvement \ No newline at end of file diff --git a/source/ResidentEvil.FusionFix/dllmain.cpp b/source/ResidentEvil.FusionFix/dllmain.cpp index 156ad54db..47ebbef38 100644 --- a/source/ResidentEvil.FusionFix/dllmain.cpp +++ b/source/ResidentEvil.FusionFix/dllmain.cpp @@ -330,6 +330,24 @@ IDirect3DPixelShader9* __stdcall CreatePixelShaderHook(const DWORD** a1) return pShader; } +bool bDisableCreateQuery = false; +void __fastcall gpuCommandBufferSync(IDirect3DDevice9** m_ppD3DDevice, void* edx) +{ + if (bDisableCreateQuery) + return; + + IDirect3DQuery9* pEventQuery = NULL; + m_ppD3DDevice[38]->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery); + + if (pEventQuery) + { + pEventQuery->Issue(D3DISSUE_END); + while (pEventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) + Sleep(0); + pEventQuery->Release(); + } +} + void Init() { CIniReader iniReader(""); @@ -341,6 +359,7 @@ void Init() bDisableNoise = iniReader.ReadInteger("MAIN", "DisableNoise", 0) != 0; bDisableColorCorrection = iniReader.ReadInteger("MAIN", "DisableColorCorrection", 0) != 0; bDisableFog = iniReader.ReadInteger("MAIN", "DisableFog", 0) != 0; + bDisableCreateQuery = iniReader.ReadInteger("MAIN", "DisableCreateQuery", 0) != 0; if (bUnlockAllResolutions) { @@ -505,6 +524,12 @@ void Init() injector::MakeCALL(hook::get_pattern("E8 ? ? ? ? 89 47 08 66 8B 4C 24 ? 0F B7 C1 43 83 C5 0C 3B D8 72 C7 33 C0"), CreatePixelShaderHook, true); } + if (bDisableCreateQuery) + { + auto pattern = hook::pattern("51 8B 91 ? ? ? ? 56 8B 35"); + injector::MakeJMP(pattern.get_first(), gpuCommandBufferSync, true); + } + if (bLightSyncRGB) { auto pattern = hook::pattern("8B 44 24 04 8B 91 ? ? ? ? 89 81 ? ? ? ? 3B C2"); diff --git a/source/ResidentEvil0.FusionFix/dllmain.cpp b/source/ResidentEvil0.FusionFix/dllmain.cpp index c37bcb5d8..51fa9ede0 100644 --- a/source/ResidentEvil0.FusionFix/dllmain.cpp +++ b/source/ResidentEvil0.FusionFix/dllmain.cpp @@ -225,6 +225,24 @@ BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) return TRUE; } +bool bDisableCreateQuery = false; +void __fastcall gpuCommandBufferSync(IDirect3DDevice9** m_ppD3DDevice, void* edx) +{ + if (bDisableCreateQuery) + return; + + IDirect3DQuery9* pEventQuery = NULL; + m_ppD3DDevice[38]->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery); + + if (pEventQuery) + { + pEventQuery->Issue(D3DISSUE_END); + while (pEventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) + Sleep(0); + pEventQuery->Release(); + } +} + void Init() { CIniReader iniReader(""); @@ -235,6 +253,7 @@ void Init() bDisableNoise = iniReader.ReadInteger("MAIN", "DisableNoise", 0) != 0; bDisableColorCorrection = iniReader.ReadInteger("MAIN", "DisableColorCorrection", 0) != 0; bDisableFog = iniReader.ReadInteger("MAIN", "DisableFog", 0) != 0; + bDisableCreateQuery = iniReader.ReadInteger("MAIN", "DisableCreateQuery", 0) != 0; if (nHideMouseCursorAfterMs) { @@ -332,6 +351,12 @@ void Init() injector::MakeCALL(hook::get_pattern("E8 ? ? ? ? 89 46 08 66 8B 4C 24 ? 0F B7 C1 43 83 C5 0C 3B D8 72 C7 33 C0"), CreatePixelShaderHook, true); } + if (bDisableCreateQuery) + { + auto pattern = hook::pattern("51 80 B9 ? ? ? ? ? 8B 91 ? ? ? ? 75 7B 8B 02 56"); + injector::MakeJMP(pattern.get_first(), gpuCommandBufferSync, true); + } + if (bLightSyncRGB) { auto pattern = hook::pattern("E8 ? ? ? ? 8B CE E8 ? ? ? ? 85 C0 75 09"); diff --git a/source/ResidentEvilRevelations.FusionFix/dllmain.cpp b/source/ResidentEvilRevelations.FusionFix/dllmain.cpp index bcc9fc069..a871cb074 100644 --- a/source/ResidentEvilRevelations.FusionFix/dllmain.cpp +++ b/source/ResidentEvilRevelations.FusionFix/dllmain.cpp @@ -402,6 +402,24 @@ void __fastcall sub_BA4440(void* _this, int edx, int* a2) return injector::fastcall::call(0xBA4440, _this, edx, a2); } +bool bDisableCreateQuery = false; +void __fastcall gpuCommandBufferSync(IDirect3DDevice9** m_ppD3DDevice, void* edx) +{ + if (bDisableCreateQuery) + return; + + IDirect3DQuery9* pEventQuery = NULL; + m_ppD3DDevice[38]->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery); + + if (pEventQuery) + { + pEventQuery->Issue(D3DISSUE_END); + while (pEventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) + Sleep(0); + pEventQuery->Release(); + } +} + void Init() { CIniReader iniReader(""); @@ -409,6 +427,7 @@ void Init() auto bDisableDamageOverlay = iniReader.ReadInteger("MAIN", "DisableDamageOverlay", 1) != 0; fFOVFactor= iniReader.ReadFloat("MAIN", "FOVFactor", 1.2f); if (fFOVFactor <= 0.0f) fFOVFactor = 1.0f; + bDisableCreateQuery = iniReader.ReadInteger("MAIN", "DisableCreateQuery", 0) != 0; // unrestrict resolutons struct ResList @@ -514,6 +533,12 @@ void Init() injector::WriteMemory(0x0107FF78, 1000, true); //max fps } + if (bDisableCreateQuery) + { + auto pattern = hook::pattern("51 8B 81 ? ? ? ? 56 8B 35 ? ? ? ? 68 ? ? ? ? 8D 54 24 08"); + injector::MakeJMP(pattern.get_first(), gpuCommandBufferSync, true); + } + { static auto sPlayerPtr = *hook::get_pattern("8B 0D ? ? ? ? 85 C9 75 14 68 ? ? ? ? 6A 3E 68 ? ? ? ? E8 ? ? ? ? 83 C4 0C 8B 0D ? ? ? ? 8D 54 24 0A", 2); static auto dword_116F398 = *hook::get_pattern("A1 ? ? ? ? 81 C6", 1); diff --git a/source/ResidentEvilRevelations2.FusionFix/dllmain.cpp b/source/ResidentEvilRevelations2.FusionFix/dllmain.cpp index 0e6c69fac..5854bdbd1 100644 --- a/source/ResidentEvilRevelations2.FusionFix/dllmain.cpp +++ b/source/ResidentEvilRevelations2.FusionFix/dllmain.cpp @@ -629,6 +629,24 @@ void __stdcall SplitScreenSetupBottom(void* a1, int32_t* a2) return injector::stdcall::call(0x4AC310, a1, a2); } +bool bDisableCreateQuery = false; +void __fastcall gpuCommandBufferSync(IDirect3DDevice9** m_ppD3DDevice, void* edx) +{ + if (bDisableCreateQuery) + return; + + IDirect3DQuery9* pEventQuery = NULL; + m_ppD3DDevice[38]->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery); + + if (pEventQuery) + { + pEventQuery->Issue(D3DISSUE_END); + while (pEventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) + Sleep(0); + pEventQuery->Release(); + } +} + void Init() { CIniReader iniReader(""); @@ -640,6 +658,7 @@ void Init() auto bDisableGUICommandFar = iniReader.ReadInteger("MAIN", "DisableGUICommandFar", 0) != 0; fFOVFactor= iniReader.ReadFloat("MAIN", "FOVFactor", 1.0f); if (fFOVFactor <= 0.0f) fFOVFactor = 1.0f; + bDisableCreateQuery = iniReader.ReadInteger("MAIN", "DisableCreateQuery", 0) != 0; if (bSkipIntro) { @@ -791,6 +810,12 @@ void Init() injector::WriteMemory(0xA9796C + 4, 1000, true); //max fps } + if (bDisableCreateQuery) + { + auto pattern = hook::pattern("51 80 B9 ? ? ? ? ? 8B 91"); + injector::MakeJMP(pattern.get_first(), gpuCommandBufferSync, true); + } + { static auto sPlayerPtr = *hook::get_pattern("8B 0D ? ? ? ? 56 E8 ? ? ? ? 85 C0 74 7B 8B C8", 2);