mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-21 16:09:19 +01:00
hacky (re|g)shade workaround
This commit is contained in:
parent
80cb19d4d2
commit
ef1a94adde
2 changed files with 53 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using Dalamud.Game.Internal.DXGI.Definitions;
|
using Dalamud.Game.Internal.DXGI.Definitions;
|
||||||
|
|
@ -26,6 +28,11 @@ namespace Dalamud.Game.Internal.DXGI
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IntPtr ResizeBuffers { get; set; }
|
public IntPtr ResizeBuffers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether or not ReShade is loaded/used.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsReshade { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override unsafe void Setup64Bit(SigScanner sig)
|
protected override unsafe void Setup64Bit(SigScanner sig)
|
||||||
{
|
{
|
||||||
|
|
@ -34,6 +41,32 @@ namespace Dalamud.Game.Internal.DXGI
|
||||||
var scVtbl = GetVTblAddresses(new IntPtr(kernelDev->SwapChain->DXGISwapChain), Enum.GetValues(typeof(IDXGISwapChainVtbl)).Length);
|
var scVtbl = GetVTblAddresses(new IntPtr(kernelDev->SwapChain->DXGISwapChain), Enum.GetValues(typeof(IDXGISwapChainVtbl)).Length);
|
||||||
|
|
||||||
this.Present = scVtbl[(int)IDXGISwapChainVtbl.Present];
|
this.Present = scVtbl[(int)IDXGISwapChainVtbl.Present];
|
||||||
|
|
||||||
|
var modules = Process.GetCurrentProcess().Modules;
|
||||||
|
foreach (ProcessModule processModule in modules)
|
||||||
|
{
|
||||||
|
if (processModule.FileName != null && processModule.FileName.EndsWith("game\\dxgi.dll"))
|
||||||
|
{
|
||||||
|
// reshade master@4232872 RVA
|
||||||
|
// var p = processModule.BaseAddress + 0x82C7E0; // DXGISwapChain::Present
|
||||||
|
// var p = processModule.BaseAddress + 0x82FAC0; // DXGISwapChain::runtime_present
|
||||||
|
|
||||||
|
var scanner = new SigScanner(processModule);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var p = scanner.ScanText("F6 C2 01 0F 85 ?? ?? ?? ??");
|
||||||
|
Log.Information($"ReShade DLL: {processModule.FileName} with DXGISwapChain::runtime_present at {p:X}");
|
||||||
|
|
||||||
|
this.Present = p;
|
||||||
|
this.IsReshade = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "Could not find reshade DXGISwapChain::runtime_present offset!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.ResizeBuffers = scVtbl[(int)IDXGISwapChainVtbl.ResizeBuffers];
|
this.ResizeBuffers = scVtbl[(int)IDXGISwapChainVtbl.ResizeBuffers];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -320,6 +320,10 @@ namespace Dalamud.Interface.Internal
|
||||||
Util.Fatal($"One or more files required by XIVLauncher were not found.\nPlease restart and report this error if it occurs again.\n\n{path}", "Error");
|
Util.Fatal($"One or more files required by XIVLauncher were not found.\nPlease restart and report this error if it occurs again.\n\n{path}", "Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE(goat): When hooking ReShade DXGISwapChain::runtime_present, this is missing the syncInterval arg.
|
||||||
|
* Seems to work fine regardless, I guess, so whatever.
|
||||||
|
*/
|
||||||
private IntPtr PresentDetour(IntPtr swapChain, uint syncInterval, uint presentFlags)
|
private IntPtr PresentDetour(IntPtr swapChain, uint syncInterval, uint presentFlags)
|
||||||
{
|
{
|
||||||
if (this.scene != null && swapChain != this.scene.SwapChain.NativePointer)
|
if (this.scene != null && swapChain != this.scene.SwapChain.NativePointer)
|
||||||
|
|
@ -398,6 +402,22 @@ namespace Dalamud.Interface.Internal
|
||||||
Service<DalamudIME>.Get().Enable();
|
Service<DalamudIME>.Get().Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.address.IsReshade)
|
||||||
|
{
|
||||||
|
var pRes = this.presentHook.Original(swapChain, syncInterval, presentFlags);
|
||||||
|
|
||||||
|
this.RenderImGui();
|
||||||
|
|
||||||
|
return pRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RenderImGui();
|
||||||
|
|
||||||
|
return this.presentHook.Original(swapChain, syncInterval, presentFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RenderImGui()
|
||||||
|
{
|
||||||
// Process information needed by ImGuiHelpers each frame.
|
// Process information needed by ImGuiHelpers each frame.
|
||||||
ImGuiHelpers.NewFrame();
|
ImGuiHelpers.NewFrame();
|
||||||
|
|
||||||
|
|
@ -405,8 +425,6 @@ namespace Dalamud.Interface.Internal
|
||||||
this.CheckViewportState();
|
this.CheckViewportState();
|
||||||
|
|
||||||
this.scene.Render();
|
this.scene.Render();
|
||||||
|
|
||||||
return this.presentHook.Original(swapChain, syncInterval, presentFlags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckViewportState()
|
private void CheckViewportState()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue