From e577ec705da97ad63c0f47dd2463f20dc19d2afa Mon Sep 17 00:00:00 2001 From: cdozdil Date: Fri, 11 Jul 2025 23:24:34 +0300 Subject: [PATCH] Added last generated frame id and renamed some methods --- OptiScaler/framegen/IFGFeature.cpp | 2 ++ OptiScaler/framegen/IFGFeature.h | 4 +++- OptiScaler/framegen/IFGFeature_Dx12.cpp | 19 +++++++++++-------- OptiScaler/framegen/IFGFeature_Dx12.h | 2 +- OptiScaler/framegen/ffx/FSRFG_Dx12.cpp | 4 ++++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/OptiScaler/framegen/IFGFeature.cpp b/OptiScaler/framegen/IFGFeature.cpp index 51284b06..0175ccec 100644 --- a/OptiScaler/framegen/IFGFeature.cpp +++ b/OptiScaler/framegen/IFGFeature.cpp @@ -66,4 +66,6 @@ void IFGFeature::UpdateTarget() UINT64 IFGFeature::FrameCount() { return _frameCount; } +UINT64 IFGFeature::LastDispatchedFrame() { return _lastDispatchedFrame; } + UINT64 IFGFeature::TargetFrame() { return _targetFrame; } diff --git a/OptiScaler/framegen/IFGFeature.h b/OptiScaler/framegen/IFGFeature.h index 8e3a10d6..c8800c89 100644 --- a/OptiScaler/framegen/IFGFeature.h +++ b/OptiScaler/framegen/IFGFeature.h @@ -20,6 +20,7 @@ class IFGFeature UINT _reset = 0; UINT64 _frameCount = 0; + UINT64 _lastDispatchedFrame = 0; UINT64 _lastUpscaledFrameId = 0; bool _isActive = false; @@ -39,7 +40,7 @@ class IFGFeature virtual void UpscaleEnd() = 0; virtual void Present() = 0; - virtual void SetVelocityAndDepthReady() = 0; + virtual void SetUpscaleInputsReady() = 0; virtual void SetHudlessReady() = 0; virtual void SetHudlessDispatchReady() = 0; @@ -64,6 +65,7 @@ class IFGFeature void UpdateTarget(); UINT64 FrameCount(); + UINT64 LastDispatchedFrame(); UINT64 TargetFrame(); IFGFeature() = default; diff --git a/OptiScaler/framegen/IFGFeature_Dx12.cpp b/OptiScaler/framegen/IFGFeature_Dx12.cpp index f99c24a1..09a1183a 100644 --- a/OptiScaler/framegen/IFGFeature_Dx12.cpp +++ b/OptiScaler/framegen/IFGFeature_Dx12.cpp @@ -90,7 +90,6 @@ void IFGFeature_Dx12::SetVelocity(ID3D12GraphicsCommandList* cmdList, ID3D12Reso D3D12_RESOURCE_STATES state) { auto index = GetIndex(); - LOG_TRACE("Setting velocity, index: {}", index); if (cmdList == nullptr) return; @@ -121,7 +120,10 @@ void IFGFeature_Dx12::SetVelocity(ID3D12GraphicsCommandList* cmdList, ID3D12Reso D3D12_RESOURCE_STATE_COPY_DEST); if (result) + { + LOG_TRACE("Setting velocity from flip, index: {}", index); _paramVelocity[index] = _paramVelocityCopy[index]; + } } return; @@ -130,6 +132,7 @@ void IFGFeature_Dx12::SetVelocity(ID3D12GraphicsCommandList* cmdList, ID3D12Reso if (Config::Instance()->FGMakeMVCopy.value_or_default() && CopyResource(cmdList, velocity, &_paramVelocityCopy[index], state)) { + LOG_TRACE("Setting velocity, index: {}", index); _paramVelocity[index] = _paramVelocityCopy[index]; return; } @@ -138,7 +141,6 @@ void IFGFeature_Dx12::SetVelocity(ID3D12GraphicsCommandList* cmdList, ID3D12Reso void IFGFeature_Dx12::SetDepth(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* depth, D3D12_RESOURCE_STATES state) { auto index = GetIndex(); - LOG_TRACE("Setting depth, index: {}", index); if (cmdList == nullptr) return; @@ -169,7 +171,10 @@ void IFGFeature_Dx12::SetDepth(ID3D12GraphicsCommandList* cmdList, ID3D12Resourc D3D12_RESOURCE_STATE_COPY_DEST); if (result) + { + LOG_TRACE("Setting depth from flip, index: {}", index); _paramDepth[index] = _paramDepthCopy[index]; + } } return; @@ -178,6 +183,7 @@ void IFGFeature_Dx12::SetDepth(ID3D12GraphicsCommandList* cmdList, ID3D12Resourc if (Config::Instance()->FGMakeDepthCopy.value_or_default() && CopyResource(cmdList, depth, &_paramDepthCopy[index], state)) { + LOG_TRACE("Setting depth, index: {}", index); _paramDepth[index] = _paramDepthCopy[index]; } } @@ -186,12 +192,11 @@ void IFGFeature_Dx12::SetHudless(ID3D12GraphicsCommandList* cmdList, ID3D12Resou D3D12_RESOURCE_STATES state, bool makeCopy) { auto index = GetIndex(); - LOG_TRACE("Setting hudless, index: {}, resource: {:X}", index, (size_t) hudless); + LOG_TRACE("Index: {}, Resource: {:X}, CmdList: {:X}", index, (size_t) hudless, (size_t) cmdList); - if (cmdList == nullptr && !makeCopy) + if (cmdList == nullptr || !makeCopy) { _paramHudless[index] = hudless; - SetHudlessReady(); return; } @@ -199,13 +204,11 @@ void IFGFeature_Dx12::SetHudless(ID3D12GraphicsCommandList* cmdList, ID3D12Resou _paramHudless[index] = _paramHudlessCopy[index]; else _paramHudless[index] = hudless; - - SetHudlessReady(); } void IFGFeature_Dx12::CreateObjects(ID3D12Device* InDevice) { - return; + return; // if (_commandAllocators[0] != nullptr) // return; diff --git a/OptiScaler/framegen/IFGFeature_Dx12.h b/OptiScaler/framegen/IFGFeature_Dx12.h index bb445b95..902016c1 100644 --- a/OptiScaler/framegen/IFGFeature_Dx12.h +++ b/OptiScaler/framegen/IFGFeature_Dx12.h @@ -74,7 +74,7 @@ class IFGFeature_Dx12 : public virtual IFGFeature IFGFeature_Dx12() = default; // Inherited via IFGFeature - void SetVelocityAndDepthReady() override; + void SetUpscaleInputsReady() override; void SetHudlessReady() override; void SetHudlessDispatchReady() override; void Present() override; diff --git a/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp b/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp index 6a13a9a1..c29220dd 100644 --- a/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp +++ b/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp @@ -96,6 +96,8 @@ bool FSRFG_Dx12::Dispatch(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* ou { LOG_DEBUG("(FG) running, frame: {0}", _frameCount); + _lastDispatchedFrame = _frameCount; + if (State::Instance().FSRFGFTPchanged) ConfigureFramePaceTuning(); @@ -264,6 +266,8 @@ bool FSRFG_Dx12::Dispatch(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* ou bool FSRFG_Dx12::DispatchHudless(ID3D12GraphicsCommandList* cmdList, bool useHudless, double frameTime) { + _lastDispatchedFrame = _frameCount; + LOG_DEBUG("useHudless: {}, frameTime: {}", useHudless, frameTime); if (State::Instance().FSRFGFTPchanged)