mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-09-22 13:25:35 +00:00
Wait for sleep to finish before deiniting low latency tech
This commit is contained in:
@@ -17,6 +17,8 @@ void LowLatency::update_effective_fg_state()
|
||||
|
||||
void LowLatency::update_enabled_override()
|
||||
{
|
||||
std::scoped_lock lock(active_tech_mutex);
|
||||
|
||||
if (!currently_active_tech)
|
||||
return;
|
||||
|
||||
|
||||
@@ -208,6 +208,8 @@ NvAPI_Status LowLatency::Sleep(IUnknown* pDevice)
|
||||
if (!update_low_latency_tech(pDevice))
|
||||
return ERROR();
|
||||
|
||||
// Make deinit wait for sleep to finish
|
||||
std::scoped_lock lock(active_tech_mutex);
|
||||
currently_active_tech->sleep();
|
||||
|
||||
return OK();
|
||||
@@ -262,6 +264,10 @@ NvAPI_Status LowLatency::SetLatencyMarker(IUnknown* pDev, NV_LATENCY_MARKER_PARA
|
||||
marker_params.frame_id = pSetLatencyMarkerParams->frameID;
|
||||
marker_params.marker_type = (MarkerType) pSetLatencyMarkerParams->markerType; // requires enums to match
|
||||
|
||||
// We can't mutex using the same one here as for sleep
|
||||
// This would make for example Present markers unable to mark during sleep
|
||||
// std::scoped_lock lock(active_tech_mutex);
|
||||
|
||||
currently_active_tech->set_marker(pDev, &marker_params);
|
||||
|
||||
LOG_TRACE_FAKENVAPI("{}: {}", magic_enum::enum_name(marker_params.marker_type), marker_params.frame_id);
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
inline HRESULT AntiLag2::al2_sleep()
|
||||
{
|
||||
std::scoped_lock lock(sleep_mutex);
|
||||
|
||||
int max_fps = 0;
|
||||
|
||||
// TODO: test more, config for this?
|
||||
@@ -125,9 +123,6 @@ bool AntiLag2::init_using_ctx(void* context)
|
||||
|
||||
void AntiLag2::deinit()
|
||||
{
|
||||
// Wait for sleep to finish
|
||||
std::scoped_lock lock(sleep_mutex);
|
||||
|
||||
if (inited_using_context)
|
||||
{
|
||||
LOG_INFO("AntiLag 2 DX12 deinit called while inited using context, skipping deinitialization");
|
||||
|
||||
@@ -12,7 +12,6 @@ class AntiLag2 : public virtual LowLatencyTech
|
||||
AMD::AntiLag2DX11::Context dx11_ctx = {};
|
||||
|
||||
std::mutex amdxc64_load_mutex;
|
||||
std::mutex sleep_mutex;
|
||||
uint64_t amdxc64_load_times = 0;
|
||||
|
||||
uint32_t minimum_interval_us = 0;
|
||||
|
||||
@@ -163,6 +163,8 @@ NvAPI_Status LowLatency::Sleep(HANDLE vkDevice)
|
||||
if (!update_low_latency_tech(vkDevice))
|
||||
return ERROR();
|
||||
|
||||
// Make deinit wait for sleep to finish
|
||||
std::scoped_lock lock(active_tech_mutex);
|
||||
currently_active_tech->sleep();
|
||||
|
||||
return OK();
|
||||
@@ -215,6 +217,10 @@ NvAPI_Status LowLatency::SetLatencyMarker(HANDLE vkDevice, NV_VULKAN_LATENCY_MAR
|
||||
marker_params.frame_id = pSetLatencyMarkerParams->frameID;
|
||||
marker_params.marker_type = (MarkerType) pSetLatencyMarkerParams->markerType; // requires enums to match
|
||||
|
||||
// We can't mutex using the same one here as for sleep
|
||||
// This would make for example Present markers unable to mark during sleep
|
||||
// std::scoped_lock lock(active_tech_mutex);
|
||||
|
||||
// This cast is not ideal as it needs to be cast to VkDevice while knowing it's vulkan
|
||||
currently_active_tech->set_marker((IUnknown*) vkDevice, &marker_params);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user