diff --git a/OptiScaler/framegen/dlssg/DLSSG_Dx12.h b/OptiScaler/framegen/dlssg/DLSSG_Dx12.h index 9133f95d..d182bf29 100644 --- a/OptiScaler/framegen/dlssg/DLSSG_Dx12.h +++ b/OptiScaler/framegen/dlssg/DLSSG_Dx12.h @@ -13,7 +13,7 @@ class DLSSG_Dx12 : public virtual IFGFeature_Dx12 std::optional _haveHudless = std::nullopt; sl::ViewportHandle viewport { 0 }; - sl::FrameToken* frameToken; + sl::FrameToken* frameToken = nullptr; ID3D12Fence* dlssgFence[BUFFER_COUNT] = {}; UINT64 lastOptionFrame = 0; diff --git a/OptiScaler/hooks/FG_Hooks.cpp b/OptiScaler/hooks/FG_Hooks.cpp index 7ef0cc15..0f414b58 100644 --- a/OptiScaler/hooks/FG_Hooks.cpp +++ b/OptiScaler/hooks/FG_Hooks.cpp @@ -1074,18 +1074,19 @@ HRESULT FGHooks::FGPresent(IDXGISwapChain* This, UINT SyncInterval, UINT Flags, LOG_TRACE("Accuired FG->Mutex: {}", fg->Mutex.getOwner()); } - sl::FrameToken* frameToken = nullptr; + sl::FrameToken* localToken = nullptr; + sl::Result tokenResult = sl::Result::eErrorReflexAPI; if (willPresent && State::Instance().activeFgOutput == FGOutput::DLSSG) { ((IDXGISwapChain4*) This)->GetCurrentBackBufferIndex(); const uint32_t frameId = State::Instance().currentFG->FrameCount(); - auto tokenResult = StreamlineProxy::GetNewFrameToken()(frameToken, &frameId); + tokenResult = StreamlineProxy::GetNewFrameToken()(localToken, &frameId); - if (!ReflexHooks::gameIsSendingMarkers() || + if (tokenResult == sl::Result::eOk && !ReflexHooks::gameIsSendingMarkers() || !Config::Instance()->FGDLSSGUseGamesReflexMarkers.value_or_default()) { - StreamlineProxy::PCLSetMarker()(sl::PCLMarker::ePresentStart, *frameToken); + StreamlineProxy::PCLSetMarker()(sl::PCLMarker::ePresentStart, *localToken); } } @@ -1159,22 +1160,13 @@ HRESULT FGHooks::FGPresent(IDXGISwapChain* This, UINT SyncInterval, UINT Flags, Util::GetDeviceRemovedReason(State::Instance().currentD3D12Device); } - if (result == S_OK) - { - LOG_DEBUG("Result: {:X}", result); - } - else - { - if (result == DXGI_ERROR_DEVICE_REMOVED && State::Instance().currentD3D12Device != nullptr) - Util::GetDeviceRemovedReason(State::Instance().currentD3D12Device); - } - - if ((!ReflexHooks::gameIsSendingMarkers() || + if (tokenResult == sl::Result::eOk && localToken != nullptr && + (!ReflexHooks::gameIsSendingMarkers() || !Config::Instance()->FGDLSSGUseGamesReflexMarkers.value_or_default()) && - willPresent && State::Instance().activeFgOutput == FGOutput::DLSSG && frameToken != nullptr) + willPresent && State::Instance().activeFgOutput == FGOutput::DLSSG) { - StreamlineProxy::PCLSetMarker()(sl::PCLMarker::ePresentEnd, *frameToken); - StreamlineProxy::ReflexSleep()(*frameToken); + StreamlineProxy::PCLSetMarker()(sl::PCLMarker::ePresentEnd, *localToken); + StreamlineProxy::ReflexSleep()(*localToken); } Hudfix_Dx12::PresentEnd(); diff --git a/OptiScaler/hooks/Streamline_Hooks.cpp b/OptiScaler/hooks/Streamline_Hooks.cpp index 7babdb16..4f8d009d 100644 --- a/OptiScaler/hooks/Streamline_Hooks.cpp +++ b/OptiScaler/hooks/Streamline_Hooks.cpp @@ -322,6 +322,9 @@ sl::Result StreamlineHooks::hkslSetD3DDevice(void* d3dDevice) void StreamlineHooks::streamlineLogCallback_sl1(sl1::LogType type, const char* msg) { + if (msg == nullptr) + return; + char* trimmed_msg = trimStreamlineLog(msg); switch (type) diff --git a/OptiScaler/proxies/Streamline_Proxy.h b/OptiScaler/proxies/Streamline_Proxy.h index 07c97cfd..2b8c9e96 100644 --- a/OptiScaler/proxies/Streamline_Proxy.h +++ b/OptiScaler/proxies/Streamline_Proxy.h @@ -217,7 +217,7 @@ class StreamlineProxy static bool HookStreamlinePCL() { // if already hooked - if (_slReflexGetState != nullptr) + if (_slPCLSetMarker != nullptr) return true; spdlog::info(""); @@ -331,7 +331,7 @@ class StreamlineProxy StreamlineProxy::HookStreamlineReflex(); StreamlineProxy::HookStreamlineDLSSG(); - State::Instance().optiSlInterposer = KernelBaseProxy::GetModuleHandleW_()(L"sl.inderposer.dll"); + State::Instance().optiSlInterposer = KernelBaseProxy::GetModuleHandleW_()(L"sl.interposer.dll"); State::Instance().optiSlCommon = KernelBaseProxy::GetModuleHandleW_()(L"sl.common.dll"); State::Instance().optiSlDLSSG = KernelBaseProxy::GetModuleHandleW_()(L"sl.dlss_g.dll"); State::Instance().optiSlReflex = KernelBaseProxy::GetModuleHandleW_()(L"sl.reflex.dll");