From d54d93c821ce042f6fa2607b8bd69098fe159538 Mon Sep 17 00:00:00 2001
From: FakeMichau <49685661+FakeMichau@users.noreply.github.com>
Date: Fri, 15 May 2026 19:42:26 +0200
Subject: [PATCH] Move native AL2 killing into common code
---
OptiScaler/OptiScaler.vcxproj | 2 -
OptiScaler/OptiScaler.vcxproj.filters | 6 ---
OptiScaler/hooks/Amdxc64_Hooks.cpp | 7 +++
OptiScaler/hooks/Amdxc64_Hooks.h | 2 +
.../low_latency_tech/ll_antilag2.cpp | 6 +--
OptiScaler/nvapi/fakenvapi.cpp | 3 --
OptiScaler/nvapi/fakenvapi/al2_proxy.cpp | 43 -------------------
OptiScaler/nvapi/fakenvapi/al2_proxy.h | 15 -------
8 files changed, 12 insertions(+), 72 deletions(-)
delete mode 100644 OptiScaler/nvapi/fakenvapi/al2_proxy.cpp
delete mode 100644 OptiScaler/nvapi/fakenvapi/al2_proxy.h
diff --git a/OptiScaler/OptiScaler.vcxproj b/OptiScaler/OptiScaler.vcxproj
index 9f099ab9..e65ba061 100644
--- a/OptiScaler/OptiScaler.vcxproj
+++ b/OptiScaler/OptiScaler.vcxproj
@@ -337,7 +337,6 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
-
@@ -592,7 +591,6 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
-
diff --git a/OptiScaler/OptiScaler.vcxproj.filters b/OptiScaler/OptiScaler.vcxproj.filters
index 6adc7a39..a5083b38 100644
--- a/OptiScaler/OptiScaler.vcxproj.filters
+++ b/OptiScaler/OptiScaler.vcxproj.filters
@@ -749,9 +749,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -1253,9 +1250,6 @@
Source Files
-
- Source Files
-
Source Files
diff --git a/OptiScaler/hooks/Amdxc64_Hooks.cpp b/OptiScaler/hooks/Amdxc64_Hooks.cpp
index 68472bcd..4987a081 100644
--- a/OptiScaler/hooks/Amdxc64_Hooks.cpp
+++ b/OptiScaler/hooks/Amdxc64_Hooks.cpp
@@ -2,6 +2,7 @@
#include "Amdxc64_Hooks.h"
#include
+#include
#include
#include
#include
@@ -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);
diff --git a/OptiScaler/hooks/Amdxc64_Hooks.h b/OptiScaler/hooks/Amdxc64_Hooks.h
index 65951754..3cbc9a0d 100644
--- a/OptiScaler/hooks/Amdxc64_Hooks.h
+++ b/OptiScaler/hooks/Amdxc64_Hooks.h
@@ -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);
};
diff --git a/OptiScaler/low_latency/low_latency_tech/ll_antilag2.cpp b/OptiScaler/low_latency/low_latency_tech/ll_antilag2.cpp
index 2e167dfa..3df8f767 100644
--- a/OptiScaler/low_latency/low_latency_tech/ll_antilag2.cpp
+++ b/OptiScaler/low_latency/low_latency_tech/ll_antilag2.cpp
@@ -1,7 +1,7 @@
#include "pch.h"
#include "ll_antilag2.h"
-#include
#include
+#include
inline HRESULT AntiLag2::al2_sleep()
{
@@ -65,10 +65,10 @@ bool AntiLag2::init(IUnknown* pDevice)
HRESULT hr = pDevice->QueryInterface(__uuidof(ID3D12Device), reinterpret_cast(&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");
diff --git a/OptiScaler/nvapi/fakenvapi.cpp b/OptiScaler/nvapi/fakenvapi.cpp
index a60d714b..d22c3d12 100644
--- a/OptiScaler/nvapi/fakenvapi.cpp
+++ b/OptiScaler/nvapi/fakenvapi.cpp
@@ -6,7 +6,6 @@
#include "fakenvapi.h"
#include "NvApiTypes.h"
#include "fakenvapi/nvapi_calls.h"
-#include "fakenvapi/al2_proxy.h"
#include
#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()
diff --git a/OptiScaler/nvapi/fakenvapi/al2_proxy.cpp b/OptiScaler/nvapi/fakenvapi/al2_proxy.cpp
deleted file mode 100644
index 1fe6ea33..00000000
--- a/OptiScaler/nvapi/fakenvapi/al2_proxy.cpp
+++ /dev/null
@@ -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(
- (VOID*) GetProcAddress(hModule, "AmdExtD3DCreateInterface"));
-
- if (o_AmdExtD3DCreateInterface)
- {
- LOG_INFO("AmdExtD3DCreateInterface hooked");
-
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
-
- DetourAttach(&(PVOID&) o_AmdExtD3DCreateInterface, hkAmdExtD3DCreateInterface);
-
- DetourTransactionCommit();
- }
- }
-}
\ No newline at end of file
diff --git a/OptiScaler/nvapi/fakenvapi/al2_proxy.h b/OptiScaler/nvapi/fakenvapi/al2_proxy.h
deleted file mode 100644
index 793072a4..00000000
--- a/OptiScaler/nvapi/fakenvapi/al2_proxy.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-
-class AL2Proxy
-{
- public:
- static AMD::AntiLag2DX12::PFNAmdExtD3DCreateInterface o_AmdExtD3DCreateInterface;
- static bool disableAl2Kill;
-
- static HRESULT hkAmdExtD3DCreateInterface(IUnknown* pOuter, REFIID riid, void** ppvObject);
- static void hookAntiLag();
-};
\ No newline at end of file