mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-08-25 15:46:45 +00:00
Move native AL2 killing into common code
This commit is contained in:
@@ -337,7 +337,6 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
|
||||
<ClInclude Include="shaders\rcas\precompile\lc_da_sharpen_Shader_Dx11.h" />
|
||||
<ClInclude Include="shaders\rcas\precompile\lc_da_sharpen_Shader_Vk.h" />
|
||||
<ClInclude Include="hooks\Xell_Hooks.h" />
|
||||
<ClInclude Include="nvapi\fakenvapi\al2_proxy.h" />
|
||||
<ClInclude Include="low_latency\ll_util.h" />
|
||||
<ClInclude Include="low_latency\ll_vulkan_hooks.h" />
|
||||
<ClInclude Include="nvapi\fakenvapi\log.h" />
|
||||
@@ -592,7 +591,6 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
|
||||
<ClCompile Include="inputs\FSR2_Dx11.cpp" />
|
||||
<ClCompile Include="inputs\FSR2_Vk.cpp" />
|
||||
<ClCompile Include="inputs\XeSS_Dx11.cpp" />
|
||||
<ClCompile Include="nvapi\fakenvapi\al2_proxy.cpp" />
|
||||
<ClCompile Include="low_latency\ll_util.cpp" />
|
||||
<ClCompile Include="low_latency\ll_vulkan_hooks.cpp" />
|
||||
<ClCompile Include="nvapi\fakenvapi\log.cpp" />
|
||||
|
||||
@@ -749,9 +749,6 @@
|
||||
<ClInclude Include="spoofing\User32_Spoofing.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="nvapi\fakenvapi\al2_proxy.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="nvapi\fakenvapi\log.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -1253,9 +1250,6 @@
|
||||
<ClCompile Include="spoofing\User32_Spoofing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="nvapi\fakenvapi\al2_proxy.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="nvapi\fakenvapi\log.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Amdxc64_Hooks.h"
|
||||
|
||||
#include <fsr4/FSR4Upgrade.h>
|
||||
#include <ffx_antilag2_dx12.h>
|
||||
#include <proxies/KernelBase_Proxy.h>
|
||||
#include <proxies/Ntdll_Proxy.h>
|
||||
#include <misc/IdentifyGpu.h>
|
||||
@@ -138,6 +139,12 @@ HRESULT STDMETHODCALLTYPE Amdxc64Hooks::hkAmdExtD3DCreateInterface(IUnknown* pOu
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// else if (riid == IID_IAmdExtAntiLagApi && !disableAl2Kill)
|
||||
//{
|
||||
// LOG_INFO("Killing native AL2");
|
||||
// return E_NOINTERFACE;
|
||||
// }
|
||||
|
||||
else if (o_AmdExtD3DCreateInterface != nullptr)
|
||||
return o_AmdExtD3DCreateInterface(pOuter, riid, ppvObject);
|
||||
|
||||
|
||||
@@ -140,6 +140,8 @@ class Amdxc64Hooks
|
||||
|
||||
inline static PFN_AmdExtD3DCreateInterface o_AmdExtD3DCreateInterface = nullptr;
|
||||
|
||||
inline static bool disableAl2Kill = false;
|
||||
|
||||
static void Init();
|
||||
static HRESULT hkAmdExtD3DCreateInterface(IUnknown* pOuter, REFIID riid, void** ppvObject);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "ll_antilag2.h"
|
||||
#include <nvapi/fakenvapi/al2_proxy.h>
|
||||
#include <nvapi/fakenvapi/log.h>
|
||||
#include <hooks/Amdxc64_Hooks.h>
|
||||
|
||||
inline HRESULT AntiLag2::al2_sleep()
|
||||
{
|
||||
@@ -65,10 +65,10 @@ bool AntiLag2::init(IUnknown* pDevice)
|
||||
HRESULT hr = pDevice->QueryInterface(__uuidof(ID3D12Device), reinterpret_cast<void**>(&device));
|
||||
if (hr == S_OK)
|
||||
{
|
||||
AL2Proxy::disableAl2Kill = true;
|
||||
Amdxc64Hooks::disableAl2Kill = true;
|
||||
ScopedSkipVulkanHooks skipVulkanHooks {};
|
||||
HRESULT init_return = AMD::AntiLag2DX12::Initialize(&dx12_ctx, device);
|
||||
AL2Proxy::disableAl2Kill = false;
|
||||
Amdxc64Hooks::disableAl2Kill = false;
|
||||
if (init_return == S_OK)
|
||||
{
|
||||
LOG_INFO("FSR Latency Reduction 2.0 DX12 initialized");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "fakenvapi.h"
|
||||
#include "NvApiTypes.h"
|
||||
#include "fakenvapi/nvapi_calls.h"
|
||||
#include "fakenvapi/al2_proxy.h"
|
||||
#include <low_latency/ll_vulkan_hooks.h>
|
||||
|
||||
#define nvapi_interface_table nvapi_interface_table_extern
|
||||
@@ -45,8 +44,6 @@ void fakenvapi::init(bool onlyContext)
|
||||
}
|
||||
|
||||
LLVulkanHooks::hook_vulkan(vulkan_module);
|
||||
|
||||
AL2Proxy::hookAntiLag();
|
||||
}
|
||||
|
||||
void fakenvapi::deinit()
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
#include "pch.h"
|
||||
#include "al2_proxy.h"
|
||||
#include "log.h"
|
||||
|
||||
AMD::AntiLag2DX12::PFNAmdExtD3DCreateInterface AL2Proxy::o_AmdExtD3DCreateInterface = nullptr;
|
||||
bool AL2Proxy::disableAl2Kill = false;
|
||||
|
||||
HRESULT AL2Proxy::hkAmdExtD3DCreateInterface(IUnknown* pOuter, REFIID riid, void** ppvObject)
|
||||
{
|
||||
if (o_AmdExtD3DCreateInterface == nullptr)
|
||||
return E_NOINTERFACE;
|
||||
|
||||
if (riid == IID_IAmdExtAntiLagApi && !disableAl2Kill)
|
||||
{
|
||||
LOG_INFO("Killing native AL2");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
return o_AmdExtD3DCreateInterface(pOuter, riid, ppvObject);
|
||||
}
|
||||
|
||||
void AL2Proxy::hookAntiLag()
|
||||
{
|
||||
HMODULE hModule = GetModuleHandleA("amdxc64.dll");
|
||||
|
||||
if (hModule && o_AmdExtD3DCreateInterface == nullptr)
|
||||
{
|
||||
o_AmdExtD3DCreateInterface = reinterpret_cast<AMD::AntiLag2DX12::PFNAmdExtD3DCreateInterface>(
|
||||
(VOID*) GetProcAddress(hModule, "AmdExtD3DCreateInterface"));
|
||||
|
||||
if (o_AmdExtD3DCreateInterface)
|
||||
{
|
||||
LOG_INFO("AmdExtD3DCreateInterface hooked");
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
|
||||
DetourAttach(&(PVOID&) o_AmdExtD3DCreateInterface, hkAmdExtD3DCreateInterface);
|
||||
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d12.h>
|
||||
#include <ffx_antilag2_dx12.h>
|
||||
#include <detours/detours.h>
|
||||
|
||||
class AL2Proxy
|
||||
{
|
||||
public:
|
||||
static AMD::AntiLag2DX12::PFNAmdExtD3DCreateInterface o_AmdExtD3DCreateInterface;
|
||||
static bool disableAl2Kill;
|
||||
|
||||
static HRESULT hkAmdExtD3DCreateInterface(IUnknown* pOuter, REFIID riid, void** ppvObject);
|
||||
static void hookAntiLag();
|
||||
};
|
||||
Reference in New Issue
Block a user