Move Low Latency vulkan hooks and logs

This commit is contained in:
FakeMichau
2026-05-15 18:18:49 +02:00
parent 766fd58943
commit b6f3086d2b
13 changed files with 46 additions and 44 deletions
+2 -2
View File
@@ -337,7 +337,7 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
<ClInclude Include="hooks\Xell_Hooks.h" />
<ClInclude Include="nvapi\fakenvapi\al2_proxy.h" />
<ClInclude Include="low_latency\ll_util.h" />
<ClInclude Include="nvapi\fakenvapi\fn_vulkan_hooks.h" />
<ClInclude Include="low_latency\ll_vulkan_hooks.h" />
<ClInclude Include="nvapi\fakenvapi\log.h" />
<ClInclude Include="nvapi\fakenvapi\low_latency.h" />
<ClInclude Include="low_latency\low_latency_tech\ll_antilag2.h" />
@@ -592,7 +592,7 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
<ClCompile Include="inputs\XeSS_Dx11.cpp" />
<ClCompile Include="nvapi\fakenvapi\al2_proxy.cpp" />
<ClCompile Include="low_latency\ll_util.cpp" />
<ClCompile Include="nvapi\fakenvapi\fn_vulkan_hooks.cpp" />
<ClCompile Include="low_latency\ll_vulkan_hooks.cpp" />
<ClCompile Include="nvapi\fakenvapi\log.cpp" />
<ClCompile Include="nvapi\fakenvapi\low_latency.cpp" />
<ClCompile Include="nvapi\fakenvapi\low_latency_d3d.cpp" />
+2 -2
View File
@@ -782,7 +782,7 @@
<ClInclude Include="low_latency\ll_util.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nvapi\fakenvapi\fn_vulkan_hooks.h">
<ClInclude Include="low_latency\ll_vulkan_hooks.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="hooks\Xell_Hooks.h">
@@ -1286,7 +1286,7 @@
<ClCompile Include="low_latency\ll_util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nvapi\fakenvapi\fn_vulkan_hooks.cpp">
<ClCompile Include="low_latency\ll_vulkan_hooks.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="hooks\Xell_Hooks.cpp">
+10
View File
@@ -6,6 +6,16 @@
#include <map>
#include <cstdint>
// #define LOWLATENCY_TRACE_LOGGING
#ifdef LOWLATENCY_TRACE_LOGGING
#define LOG_TRACE_LOWLATENCY(msg, ...) LOG_TRACE(msg, ##__VA_ARGS__)
#else
#define LOG_TRACE_LOWLATENCY(msg, ...) \
{ \
}
#endif
enum class LowLatencyMode
{
None,
@@ -1,18 +1,18 @@
#include "pch.h"
#include "fn_vulkan_hooks.h"
#include "ll_vulkan_hooks.h"
#include <detours/detours.h>
#include <vulkan/vulkan_core.h>
#include <vector>
PFN_vkCreateDevice FnVulkanHooks::o_vkCreateDevice = nullptr;
PFN_vkGetPhysicalDeviceFeatures2 FnVulkanHooks::o_vkGetPhysicalDeviceFeatures2 = nullptr;
PFN_vkGetDeviceProcAddr FnVulkanHooks::o_vkGetDeviceProcAddr = nullptr;
PFN_vkCreateSemaphore FnVulkanHooks::o_vkCreateSemaphore = nullptr;
PFN_vkSignalSemaphore FnVulkanHooks::o_vkSignalSemaphore = nullptr;
PFN_vkAntiLagUpdateAMD FnVulkanHooks::o_vkAntiLagUpdateAMD = nullptr;
PFN_vkCreateDevice LLVulkanHooks::o_vkCreateDevice = nullptr;
PFN_vkGetPhysicalDeviceFeatures2 LLVulkanHooks::o_vkGetPhysicalDeviceFeatures2 = nullptr;
PFN_vkGetDeviceProcAddr LLVulkanHooks::o_vkGetDeviceProcAddr = nullptr;
PFN_vkCreateSemaphore LLVulkanHooks::o_vkCreateSemaphore = nullptr;
PFN_vkSignalSemaphore LLVulkanHooks::o_vkSignalSemaphore = nullptr;
PFN_vkAntiLagUpdateAMD LLVulkanHooks::o_vkAntiLagUpdateAMD = nullptr;
VkResult FnVulkanHooks::hkvkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCreateInfo* pCreateInfo,
VkResult LLVulkanHooks::hkvkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator, VkDevice* pDevice)
{
LOG_DEBUG("hkvkCreateDevice");
@@ -66,7 +66,7 @@ VkResult FnVulkanHooks::hkvkCreateDevice(VkPhysicalDevice physicalDevice, VkDevi
return result;
}
void FnVulkanHooks::hook_vulkan(HMODULE vulkanModule)
void LLVulkanHooks::hook_vulkan(HMODULE vulkanModule)
{
LOG_DEBUG("Trying to hook Vulkan");
@@ -1,12 +1,10 @@
#pragma once
#include "log.h"
#include <detours/detours.h>
#include <vulkan/vulkan_core.h>
#include <vector>
class FnVulkanHooks
class LLVulkanHooks
{
private:
static PFN_vkCreateDevice o_vkCreateDevice;
@@ -34,8 +34,8 @@ inline HRESULT AntiLag2::al2_sleep()
// log_event("al2_sleep", "{}", get_timestamp() - pre_sleep);
LOG_TRACE_FAKENVAPI("FSR Latency Reduction 2.0 Call Spot: {}",
current_call_spot == CallSpot::SimulationStart ? "SimulationStart" : "SleepCall");
LOG_TRACE_LOWLATENCY("FSR Latency Reduction 2.0 Call Spot: {}",
current_call_spot == CallSpot::SimulationStart ? "SimulationStart" : "SleepCall");
return result;
}
@@ -1,8 +1,8 @@
#include "pch.h"
#include "ll_antilag_vk.h"
#include <nvapi/fakenvapi/fn_vulkan_hooks.h>
#include "low_latency/ll_vulkan_hooks.h"
bool AntiLagVk::init(IUnknown* pDevice) { return FnVulkanHooks::o_vkAntiLagUpdateAMD != nullptr; }
bool AntiLagVk::init(IUnknown* pDevice) { return LLVulkanHooks::o_vkAntiLagUpdateAMD != nullptr; }
// Unsupported
bool AntiLagVk::init_using_ctx(void* context)
@@ -79,11 +79,11 @@ void AntiLagVk::set_marker(IUnknown* pDevice, MarkerParams* marker_params)
antiLagDataInput.pPresentationInfo = &inputInfo;
antiLagDataInput.maxFPS = max_fps;
if (FnVulkanHooks::o_vkAntiLagUpdateAMD)
if (LLVulkanHooks::o_vkAntiLagUpdateAMD)
{
LOG_TRACE_FAKENVAPI("AntiLag Input: {}, status: {}", marker_params->frame_id, is_enabled());
LOG_TRACE_LOWLATENCY("AntiLag Input: {}, status: {}", marker_params->frame_id, is_enabled());
FnVulkanHooks::o_vkAntiLagUpdateAMD((VkDevice) pDevice, &antiLagDataInput);
LLVulkanHooks::o_vkAntiLagUpdateAMD((VkDevice) pDevice, &antiLagDataInput);
}
}
@@ -102,11 +102,11 @@ void AntiLagVk::set_marker(IUnknown* pDevice, MarkerParams* marker_params)
antiLagDataPresent.pPresentationInfo = &presentInfo;
antiLagDataPresent.maxFPS = max_fps;
if (FnVulkanHooks::o_vkAntiLagUpdateAMD)
if (LLVulkanHooks::o_vkAntiLagUpdateAMD)
{
LOG_TRACE_FAKENVAPI("AntiLag Present: {}, status: {}", marker_params->frame_id, is_enabled());
LOG_TRACE_LOWLATENCY("AntiLag Present: {}, status: {}", marker_params->frame_id, is_enabled());
FnVulkanHooks::o_vkAntiLagUpdateAMD((VkDevice) pDevice, &antiLagDataPresent);
LLVulkanHooks::o_vkAntiLagUpdateAMD((VkDevice) pDevice, &antiLagDataPresent);
}
}
}
@@ -70,8 +70,8 @@ void LatencyFlex::lfx_sleep(uint64_t reflex_frame_id)
timestamp = current_timestamp;
}
LOG_TRACE_FAKENVAPI("LatencyFlex Call Spot: {}",
current_call_spot == CallSpot::SimulationStart ? "SimulationStart" : "SleepCall");
LOG_TRACE_LOWLATENCY("LatencyFlex Call Spot: {}",
current_call_spot == CallSpot::SimulationStart ? "SimulationStart" : "SleepCall");
mutex.lock();
this->frame_id++;
@@ -94,8 +94,8 @@ void LatencyFlex::lfx_end_frame(uint64_t reflex_frame_id)
if (ctx)
ctx->EndFrame(frame_id, current_timestamp, &latency, &frame_time);
mutex.unlock();
LOG_TRACE_FAKENVAPI("LFX latency: {}, frame_time: {}, current_timestamp: {}", latency, frame_time,
current_timestamp);
LOG_TRACE_LOWLATENCY("LFX latency: {}, frame_time: {}, current_timestamp: {}", latency, frame_time,
current_timestamp);
}
bool LatencyFlex::init(IUnknown* pDevice)
@@ -12,7 +12,7 @@ void XeLL::xell_sleep(uint32_t frame_id)
// Don't call XeLL when trying to disable XeLL with XeFG active
if (!inited_using_context || is_enabled())
{
LOG_TRACE_FAKENVAPI("Sleeping with frame_id: {}", frame_id);
LOG_TRACE_LOWLATENCY("Sleeping with frame_id: {}", frame_id);
XeLLProxy::Sleep()(XeLLProxy::Context(), frame_id);
}
}
+2 -2
View File
@@ -7,7 +7,7 @@
#include "NvApiTypes.h"
#include "fakenvapi/nvapi_calls.h"
#include "fakenvapi/al2_proxy.h"
#include "fakenvapi/fn_vulkan_hooks.h"
#include <low_latency/ll_vulkan_hooks.h>
#define nvapi_interface_table nvapi_interface_table_extern
#include <nvapi_interface.h>
@@ -44,7 +44,7 @@ void fakenvapi::init(bool onlyContext)
}
}
FnVulkanHooks::hook_vulkan(vulkan_module);
LLVulkanHooks::hook_vulkan(vulkan_module);
AL2Proxy::hookAntiLag();
}
-6
View File
@@ -27,9 +27,3 @@
NvAPI_Status Ok(const char* function_name);
NvAPI_Status Error(const char* function_name, NvAPI_Status status = NVAPI_ERROR);
template <typename... _Args>
void log_event(const char* event_name, std::format_string<_Args...> __fmt, _Args&&... __args)
{
LOG_TRACE_FAKENVAPI("EVENT,{},{},{}", event_name, get_timestamp(),
std::vformat(__fmt.get(), std::make_format_args(__args...)));
}
+4 -4
View File
@@ -628,8 +628,8 @@ NvAPI_Status __cdecl NvAPI_Vulkan_InitLowLatencyDevice(HANDLE vkDevice, HANDLE*
VkResult res = VK_ERROR_UNKNOWN;
if (FnVulkanHooks::o_vkCreateSemaphore && low_latency_semaphore == VK_NULL_HANDLE)
res = FnVulkanHooks::o_vkCreateSemaphore(device, &createInfo, nullptr, &low_latency_semaphore);
if (LLVulkanHooks::o_vkCreateSemaphore && low_latency_semaphore == VK_NULL_HANDLE)
res = LLVulkanHooks::o_vkCreateSemaphore(device, &createInfo, nullptr, &low_latency_semaphore);
if (res != VK_SUCCESS)
return NVAPI_ERROR;
@@ -676,8 +676,8 @@ NvAPI_Status __cdecl NvAPI_Vulkan_Sleep(HANDLE vkDevice, NvU64 signalValue)
VkDevice device = reinterpret_cast<VkDevice>(vkDevice);
if (FnVulkanHooks::o_vkSignalSemaphore)
FnVulkanHooks::o_vkSignalSemaphore(device, &signalInfo);
if (LLVulkanHooks::o_vkSignalSemaphore)
LLVulkanHooks::o_vkSignalSemaphore(device, &signalInfo);
return LowLatencyCtx::get()->Sleep(vkDevice);
}
+1 -1
View File
@@ -7,8 +7,8 @@
#include "low_latency.h"
#include "low_latency/ll_util.h"
#include "low_latency/ll_vulkan_hooks.h"
#include "log.h"
#include "fn_vulkan_hooks.h"
namespace nvapi_calls
{