From d9f6be9acf9cd59c611edbbb1bb39d9daa668dfb Mon Sep 17 00:00:00 2001 From: FakeMichau <49685661+FakeMichau@users.noreply.github.com> Date: Tue, 16 Jun 2026 22:45:37 +0200 Subject: [PATCH] WIP: XeLL inputs to AL2 --- OptiScaler/hooks/Amdxc64_Hooks.cpp | 10 ++---- OptiScaler/low_latency/input/input_common.cpp | 32 +++++++++++++------ OptiScaler/low_latency/input/input_xell.cpp | 3 ++ OptiScaler/menu/menu_common.cpp | 1 + 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/OptiScaler/hooks/Amdxc64_Hooks.cpp b/OptiScaler/hooks/Amdxc64_Hooks.cpp index a9a83793..3e635646 100644 --- a/OptiScaler/hooks/Amdxc64_Hooks.cpp +++ b/OptiScaler/hooks/Amdxc64_Hooks.cpp @@ -148,7 +148,7 @@ HRESULT STDMETHODCALLTYPE Amdxc64Hooks::hkAmdExtD3DCreateInterface(IUnknown* pOu } #ifdef LOW_LATENCY_INPUTS - else if (riid == IID_IAmdExtAntiLagApi) + else if (riid == IID_IAmdExtAntiLagApi && disableAl2Kill) { if (amdExtAntiLagApi == nullptr) amdExtAntiLagApi = new AmdExtAntiLagApi(); @@ -156,15 +156,9 @@ HRESULT STDMETHODCALLTYPE Amdxc64Hooks::hkAmdExtD3DCreateInterface(IUnknown* pOu // Return custom one *ppvObject = amdExtAntiLagApi; - LOG_INFO("IAmdExtAntiLagApi queried, returning custom AmdExtAntiLagApi"); + LOG_INFO("Providing the game with AL2 proxy, AL2 inputs should be avaliable"); return S_OK; - - // if (!disableAl2Kill) - //{ - // LOG_INFO("Killing native AL2"); - // return E_NOINTERFACE; - // } } #endif diff --git a/OptiScaler/low_latency/input/input_common.cpp b/OptiScaler/low_latency/input/input_common.cpp index 00c0757d..47c6fb64 100644 --- a/OptiScaler/low_latency/input/input_common.cpp +++ b/OptiScaler/low_latency/input/input_common.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "input_common.h" #include +#include // private bool InputCommon::update_low_latency_tech(IUnknown* pDevice, std::optional mode) @@ -27,19 +28,20 @@ bool InputCommon::update_low_latency_tech(IUnknown* pDevice, std::optionalLowLatencyInput.set_volatile_value(LowLatencyInput::XeLL); activeInput = Config::Instance()->LowLatencyInput.value_or_default(); // TODO: for testing - Config::Instance()->LowLatencyOutput.set_volatile_value(LowLatencyMode::XeLL); + Config::Instance()->LowLatencyOutput.set_volatile_value(LowLatencyMode::AntiLag2); if (activeOutput == Config::Instance()->LowLatencyOutput.value_or_default()) return true; // TODO: init correct currently_active_tech, desiredMode == None -> Auto - auto new_tech_xell = std::make_shared(); + auto new_tech_xell = std::make_shared(); if (new_tech_xell->init(pDevice)) { - LOG_INFO("LowLatency algo: XeLL"); + LOG_INFO("LowLatency algo: AntiLag2"); currently_active_tech.store(std::move(new_tech_xell)); } @@ -212,7 +214,6 @@ InputResult InputCommon::set_async_marker(const InputContext& inputContext, ID3D return InputResult::Ok; } -// TODO: impl InputResult InputCommon::set_sleep_mode(const InputContext& inputContext, IUnknown* pDevice, SleepMode* sleep_mode) { if (!update_low_latency_tech(pDevice)) @@ -494,6 +495,9 @@ bool InputCommon::get_timing_data(TimingData& timingDataOut) xell_result_t InputCommon::pass_xellD3D12SetAppQueue(const InputContext& inputContext, ID3D12CommandQueue* appQueue) { + // TODO: XeLL seems to be sending this early, before any markers. Because of that activeOutput is likely still None + // and we dont grab the appQueue at all + if (inputContext.caller == LowLatencyInput::XeLL && activeOutput == LowLatencyMode::XeLL) { if (auto current_tech = currently_active_tech.load()) @@ -501,9 +505,11 @@ xell_result_t InputCommon::pass_xellD3D12SetAppQueue(const InputContext& inputCo auto xell_tech = std::static_pointer_cast(current_tech); return xell_tech->xellD3D12SetAppQueue(appQueue); } + + return XELL_RESULT_ERROR_UNKNOWN; } - return XELL_RESULT_ERROR_UNKNOWN; + return XELL_RESULT_SUCCESS; } xell_result_t InputCommon::pass_xellSetDisplayInfo(const InputContext& inputContext, void* displayInfo) @@ -515,9 +521,11 @@ xell_result_t InputCommon::pass_xellSetDisplayInfo(const InputContext& inputCont auto xell_tech = std::static_pointer_cast(current_tech); return xell_tech->xellSetDisplayInfo(displayInfo); } + + return XELL_RESULT_ERROR_UNKNOWN; } - return XELL_RESULT_ERROR_UNKNOWN; + return XELL_RESULT_SUCCESS; } xell_result_t InputCommon::pass_xellSetFgEnabled(const InputContext& inputContext, uint32_t param1, uint32_t param2) @@ -529,9 +537,11 @@ xell_result_t InputCommon::pass_xellSetFgEnabled(const InputContext& inputContex auto xell_tech = std::static_pointer_cast(current_tech); return xell_tech->xellSetFgEnabled(param1, param2); } + + return XELL_RESULT_ERROR_UNKNOWN; } - return XELL_RESULT_ERROR_UNKNOWN; + return XELL_RESULT_SUCCESS; } xell_result_t InputCommon::pass_xellSetGeneratedFramesCount(const InputContext& inputContext, uint32_t param1, @@ -544,9 +554,11 @@ xell_result_t InputCommon::pass_xellSetGeneratedFramesCount(const InputContext& auto xell_tech = std::static_pointer_cast(current_tech); return xell_tech->xellSetGeneratedFramesCount(param1, framesCount); } + + return XELL_RESULT_ERROR_UNKNOWN; } - return XELL_RESULT_ERROR_UNKNOWN; + return XELL_RESULT_SUCCESS; } xell_result_t InputCommon::pass_xellGetLastPresentStartFrameId(const InputContext& inputContext, uint32_t* p_frame_id) @@ -558,7 +570,9 @@ xell_result_t InputCommon::pass_xellGetLastPresentStartFrameId(const InputContex auto xell_tech = std::static_pointer_cast(current_tech); return xell_tech->xellGetLastPresentStartFrameId(p_frame_id); } + + return XELL_RESULT_ERROR_UNKNOWN; } - return XELL_RESULT_ERROR_UNKNOWN; + return XELL_RESULT_SUCCESS; } diff --git a/OptiScaler/low_latency/input/input_xell.cpp b/OptiScaler/low_latency/input/input_xell.cpp index b20a7c69..06fa9455 100644 --- a/OptiScaler/low_latency/input/input_xell.cpp +++ b/OptiScaler/low_latency/input/input_xell.cpp @@ -1,5 +1,6 @@ #include "pch.h" #include "input_xell.h" +#include // Common xell_result_t InputXeLL::DestroyContext(xell_input_handle_t context) @@ -182,6 +183,8 @@ xell_result_t InputXeLL::D3D12CreateContext(ID3D12Device* device, xell_input_han *out_context = newContext; + XellHooks::setOurContext((xell_context_handle_t) newContext); + return XELL_RESULT_SUCCESS; } diff --git a/OptiScaler/menu/menu_common.cpp b/OptiScaler/menu/menu_common.cpp index f4d25d5a..cbd9bcac 100644 --- a/OptiScaler/menu/menu_common.cpp +++ b/OptiScaler/menu/menu_common.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #define MARK_ALL_BACKENDS_CHANGED() \ for (auto& singleChangeBackend : State::Instance().changeBackend) \