mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 21:03:43 +01:00
Use ReShade Addon when available instead of hooking IDXGISwapChain::Present
This commit is contained in:
parent
ca3e4088f6
commit
e40c317417
24 changed files with 6977 additions and 305 deletions
|
|
@ -158,6 +158,14 @@
|
|||
<ClInclude Include="..\lib\CoreCLR\core\coreclr_delegates.h" />
|
||||
<ClInclude Include="..\lib\CoreCLR\core\hostfxr.h" />
|
||||
<ClInclude Include="..\lib\CoreCLR\nethost\nethost.h" />
|
||||
<ClInclude Include="..\lib\reshade\include\reshade.hpp" />
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api.hpp" />
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api_device.hpp" />
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api_format.hpp" />
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api_pipeline.hpp" />
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api_resource.hpp" />
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_events.hpp" />
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_overlay.hpp" />
|
||||
<ClInclude Include="..\lib\TsudaKageyu-minhook\include\MinHook.h" />
|
||||
<ClInclude Include="..\lib\TsudaKageyu-minhook\src\buffer.h" />
|
||||
<ClInclude Include="..\lib\TsudaKageyu-minhook\src\HDE\hde32.h" />
|
||||
|
|
@ -187,4 +195,4 @@
|
|||
<Delete Files="$(OutDir)$(TargetName).lib" />
|
||||
<Delete Files="$(OutDir)$(TargetName).exp" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
@ -17,6 +17,9 @@
|
|||
<Filter Include="MinHook">
|
||||
<UniqueIdentifier>{6ec5597d-e293-4d2a-a307-7444c8fac04b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ReshadePlugin">
|
||||
<UniqueIdentifier>{fff0ec42-beda-42f6-997b-953cc54d3d29}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
|
|
@ -140,6 +143,30 @@
|
|||
</ClInclude>
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="crashhandler_shared.h" />
|
||||
<ClInclude Include="..\lib\reshade\include\reshade.hpp">
|
||||
<Filter>ReshadePlugin</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api.hpp">
|
||||
<Filter>ReshadePlugin</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api_device.hpp">
|
||||
<Filter>ReshadePlugin</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api_format.hpp">
|
||||
<Filter>ReshadePlugin</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api_pipeline.hpp">
|
||||
<Filter>ReshadePlugin</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_api_resource.hpp">
|
||||
<Filter>ReshadePlugin</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_events.hpp">
|
||||
<Filter>ReshadePlugin</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\reshade\include\reshade_overlay.hpp">
|
||||
<Filter>ReshadePlugin</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Dalamud.Boot.rc" />
|
||||
|
|
|
|||
|
|
@ -8,6 +8,14 @@
|
|||
|
||||
HMODULE g_hModule;
|
||||
HINSTANCE g_hGameInstance = GetModuleHandleW(nullptr);
|
||||
bool g_bReshadeAvailable = false;
|
||||
|
||||
static void(*s_pfnReshadeOverlayCallback)(void*) = nullptr;
|
||||
|
||||
static void OnReshadeOverlay(reshade::api::effect_runtime *runtime) {
|
||||
if (s_pfnReshadeOverlayCallback)
|
||||
s_pfnReshadeOverlayCallback(reinterpret_cast<void*>(runtime->get_native()));
|
||||
}
|
||||
|
||||
DWORD WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
||||
g_startInfo.from_envvars();
|
||||
|
|
@ -127,7 +135,7 @@ DWORD WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
|||
if (result != 0)
|
||||
return result;
|
||||
|
||||
using custom_component_entry_point_fn = void (CORECLR_DELEGATE_CALLTYPE*)(LPVOID, HANDLE);
|
||||
using custom_component_entry_point_fn = void (CORECLR_DELEGATE_CALLTYPE*)(LPVOID, HANDLE, LPVOID);
|
||||
const auto entrypoint_fn = reinterpret_cast<custom_component_entry_point_fn>(entrypoint_vfn);
|
||||
|
||||
// ============================== VEH ======================================== //
|
||||
|
|
@ -153,7 +161,7 @@ DWORD WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
|||
// utils::wait_for_game_window();
|
||||
|
||||
logging::I("Initializing Dalamud...");
|
||||
entrypoint_fn(lpParam, hMainThreadContinue);
|
||||
entrypoint_fn(lpParam, hMainThreadContinue, g_bReshadeAvailable ? &s_pfnReshadeOverlayCallback : nullptr);
|
||||
logging::I("Done!");
|
||||
|
||||
return 0;
|
||||
|
|
@ -169,6 +177,9 @@ BOOL APIENTRY DllMain(const HMODULE hModule, const DWORD dwReason, LPVOID lpRese
|
|||
switch (dwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
g_hModule = hModule;
|
||||
g_bReshadeAvailable = reshade::register_addon(hModule);
|
||||
if (g_bReshadeAvailable)
|
||||
reshade::register_event<reshade::addon_event::reshade_overlay>(&OnReshadeOverlay);
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
|
|
@ -178,7 +189,10 @@ BOOL APIENTRY DllMain(const HMODULE hModule, const DWORD dwReason, LPVOID lpRese
|
|||
// process is terminating; don't bother cleaning up
|
||||
if (lpReserved)
|
||||
return TRUE;
|
||||
|
||||
|
||||
if (g_bReshadeAvailable)
|
||||
reshade::unregister_event<reshade::addon_event::reshade_overlay>(&OnReshadeOverlay);
|
||||
|
||||
logging::update_dll_load_status(false);
|
||||
|
||||
xivfixes::apply_all(false);
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@
|
|||
// https://github.com/nlohmann/json
|
||||
#include "../lib/nlohmann-json/json.hpp"
|
||||
|
||||
// https://github.com/crosire/reshade/tree/main/include
|
||||
#include "../lib/reshade/include/reshade.hpp"
|
||||
|
||||
#include "unicode.h"
|
||||
|
||||
// Commonly used macros
|
||||
|
|
@ -67,6 +70,7 @@
|
|||
// Global variables
|
||||
extern HMODULE g_hModule;
|
||||
extern HINSTANCE g_hGameInstance;
|
||||
extern bool g_bReshadeAvailable;
|
||||
extern std::optional<CoreCLR> g_clr;
|
||||
|
||||
#endif //PCH_H
|
||||
|
|
|
|||
|
|
@ -368,7 +368,8 @@ DllExport void WINAPI RewrittenEntryPoint(RewrittenEntryPointParameters& params)
|
|||
loadInfo = params.pLoadInfo;
|
||||
}
|
||||
|
||||
InitializeImpl(&loadInfo[0], params.hMainThreadContinue);
|
||||
if (const auto err = InitializeImpl(&loadInfo[0], params.hMainThreadContinue))
|
||||
throw std::exception(std::format("{:08X}", err).c_str());
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
MessageBoxA(nullptr, std::format("Failed to load Dalamud.\n\nError: {}", e.what()).c_str(), "Dalamud.Boot", MB_OK | MB_ICONERROR);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue