Skip to content

Commit

Permalink
disable createquery option for re1, 0, rev and rev2
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Nov 13, 2023
1 parent f4ce1ad commit a97d992
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[MAIN]
BorderlessWindowed = 1
DisableDamageOverlay = 1
FOVFactor = 1.0
FOVFactor = 1.0
DisableCreateQuery = 0 // Use for potential performance improvement
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ SkipIntro = 1
BorderlessWindowed = 1
DisableDamageOverlay = 1
DisableFilmGrain = 1
DisableFade = 0 // not recommended
FOVFactor = 1.0
DisableFade = 0 // Not recommended
FOVFactor = 1.0
DisableCreateQuery = 0 // Use for potential performance improvement
25 changes: 25 additions & 0 deletions source/ResidentEvil.FusionFix/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand All @@ -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)
{
Expand Down Expand Up @@ -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");
Expand Down
25 changes: 25 additions & 0 deletions source/ResidentEvil0.FusionFix/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand All @@ -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)
{
Expand Down Expand Up @@ -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");
Expand Down
25 changes: 25 additions & 0 deletions source/ResidentEvilRevelations.FusionFix/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,32 @@ void __fastcall sub_BA4440(void* _this, int edx, int* a2)
return injector::fastcall<void(void*, int, int*)>::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("");
auto bBorderlessWindowed = iniReader.ReadInteger("MAIN", "BorderlessWindowed", 1) != 0;
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
Expand Down Expand Up @@ -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<void*>("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<void*>("A1 ? ? ? ? 81 C6", 1);
Expand Down
25 changes: 25 additions & 0 deletions source/ResidentEvilRevelations2.FusionFix/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,24 @@ void __stdcall SplitScreenSetupBottom(void* a1, int32_t* a2)
return injector::stdcall<void(void*, int32_t*)>::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("");
Expand All @@ -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)
{
Expand Down Expand Up @@ -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<void*>("8B 0D ? ? ? ? 56 E8 ? ? ? ? 85 C0 74 7B 8B C8", 2);

Expand Down

0 comments on commit a97d992

Please sign in to comment.