diff --git a/OptiScaler/Config.h b/OptiScaler/Config.h index 5f3075ad..40d6d76a 100644 --- a/OptiScaler/Config.h +++ b/OptiScaler/Config.h @@ -379,11 +379,6 @@ class Config // OptiFG CustomOptional FGEnabled { false }; - CustomOptional FGDebugView { false }; - CustomOptional FGDebugResetLines { false }; - CustomOptional FGDebugTearLines { false }; - CustomOptional FGDebugPacingLines { false }; - CustomOptional FGAsync { false }; CustomOptional FGUseMutexForSwapchain { true }; CustomOptional FGMakeMVCopy { true }; CustomOptional FGMakeDepthCopy { true }; @@ -411,7 +406,12 @@ class Config CustomOptional FGEnableDepthScale { false }; CustomOptional FGDepthScaleMax { 10000.0f }; - // OptiFG - FSR-FG FPT + // FSR-FG + CustomOptional FGDebugView { false }; + CustomOptional FGDebugResetLines { false }; + CustomOptional FGDebugTearLines { false }; + CustomOptional FGDebugPacingLines { false }; + CustomOptional FGAsync { false }; CustomOptional FGFramePacingTuning { true }; CustomOptional FGFPTSafetyMarginInMs { 0.01f }; CustomOptional FGFPTVarianceFactor { 0.3f }; diff --git a/OptiScaler/framegen/IFGFeature_Dx12.cpp b/OptiScaler/framegen/IFGFeature_Dx12.cpp index 5b499634..239a2b51 100644 --- a/OptiScaler/framegen/IFGFeature_Dx12.cpp +++ b/OptiScaler/framegen/IFGFeature_Dx12.cpp @@ -38,6 +38,59 @@ bool IFGFeature_Dx12::GetResourceCopy(FG_ResourceType type, D3D12_RESOURCE_STATE ID3D12CommandQueue* IFGFeature_Dx12::GetCommandQueue() { return _gameCommandQueue; } +ID3D12GraphicsCommandList* IFGFeature_Dx12::GetUICommandList(int index) +{ + if (index < 0) + index = GetIndex(); + + LOG_DEBUG("index: {}", index); + + if (_uiCommandAllocator[0] == nullptr) + { + if (_device != nullptr) + CreateObjects(_device); + else if (State::Instance().currentD3D12Device != nullptr) + CreateObjects(State::Instance().currentD3D12Device); + else + return nullptr; + } + + for (size_t i = 0; i < BUFFER_COUNT; i++) + { + if (i != index && _uiCommandListResetted[i]) + { + LOG_DEBUG("Executing _uiCommandList[{}]: {:X}", i, (size_t) _uiCommandList[i]); + auto closeResult = _uiCommandList[i]->Close(); + + if (closeResult != S_OK) + LOG_ERROR("_uiCommandList[{}]->Close() error: {:X}", i, (UINT) closeResult); + + _uiCommandListResetted[i] = false; + } + } + + if (!_uiCommandListResetted[index]) + { + auto result = _uiCommandAllocator[index]->Reset(); + + if (result == S_OK) + { + result = _uiCommandList[index]->Reset(_uiCommandAllocator[index], nullptr); + + if (result == S_OK) + _uiCommandListResetted[index] = true; + else + LOG_ERROR("_uiCommandList[{}]->Reset() error: {:X}", index, (UINT) result); + } + else + { + LOG_ERROR("_uiCommandAllocator[{}]->Reset() error: {:X}", index, (UINT) result); + } + } + + return _uiCommandList[index]; +} + Dx12Resource* IFGFeature_Dx12::GetResource(FG_ResourceType type, int index) { std::lock_guard lock(_frMutex); diff --git a/OptiScaler/framegen/IFGFeature_Dx12.h b/OptiScaler/framegen/IFGFeature_Dx12.h index 665963e1..cb8d6d4a 100644 --- a/OptiScaler/framegen/IFGFeature_Dx12.h +++ b/OptiScaler/framegen/IFGFeature_Dx12.h @@ -90,7 +90,8 @@ class IFGFeature_Dx12 : public virtual IFGFeature virtual void SetResource(Dx12Resource* inputResource) = 0; virtual void SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue) = 0; - virtual ID3D12GraphicsCommandList* GetUICommandList(int index = -1) = 0; + + ID3D12GraphicsCommandList* GetUICommandList(int index = -1); Dx12Resource* GetResource(FG_ResourceType type, int index = -1); bool GetResourceCopy(FG_ResourceType type, D3D12_RESOURCE_STATES bufferState, ID3D12Resource* output); diff --git a/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp b/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp index 5ca5a37f..1db5a3a1 100644 --- a/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp +++ b/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp @@ -916,66 +916,6 @@ void FSRFG_Dx12::SetResourceReady(FG_ResourceType type) { _resourceReady[GetInde void FSRFG_Dx12::SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue) { _gameCommandQueue = queue; } -ID3D12GraphicsCommandList* FSRFG_Dx12::GetUICommandList(int index) -{ - if (index < 0) - index = GetIndex(); - - LOG_DEBUG("index: {}", index); - - if (_uiCommandAllocator[0] == nullptr) - { - if (_device != nullptr) - CreateObjects(_device); - else if (State::Instance().currentD3D12Device != nullptr) - CreateObjects(State::Instance().currentD3D12Device); - else - return nullptr; - } - - if (Config::Instance()->FGEnabled.value_or_default()) - { - for (size_t i = 0; i < BUFFER_COUNT; i++) - { - if (i != index && _uiCommandListResetted[i]) - { - LOG_DEBUG("Executing _uiCommandList[{}]: {:X}", i, (size_t) _uiCommandList[i]); - auto closeResult = _uiCommandList[i]->Close(); - - if (closeResult == S_OK) - _gameCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &_uiCommandList[i]); - else - LOG_ERROR("_uiCommandList[{}]->Close() error: {:X}", i, (UINT) closeResult); - - _uiCommandListResetted[i] = false; - } - } - - if (!_uiCommandListResetted[index]) - { - _uiCommandListResetted[index] = true; - - auto result = _uiCommandAllocator[index]->Reset(); - - if (result == S_OK) - { - result = _uiCommandList[index]->Reset(_uiCommandAllocator[index], nullptr); - - if (result != S_OK) - LOG_ERROR("_uiCommandList[{}]->Reset() error: {:X}", index, (UINT) result); - } - else - { - LOG_ERROR("_uiCommandAllocator[{}]->Reset() error: {:X}", index, (UINT) result); - } - - LOG_DEBUG("_uiCommandList[{}]->Reset()", index); - } - } - - return _uiCommandList[index]; -} - void FSRFG_Dx12::CreateObjects(ID3D12Device* InDevice) { _device = InDevice; @@ -1081,21 +1021,18 @@ bool FSRFG_Dx12::Present() } } - if (Config::Instance()->FGEnabled.value_or_default()) + auto fIndex = GetIndex(); + if (_uiCommandListResetted[fIndex]) { - auto fIndex = GetIndex(); - if (_uiCommandListResetted[fIndex]) - { - LOG_DEBUG("Executing _uiCommandList[fIndex][{}]: {:X}", fIndex, (size_t) _uiCommandList[fIndex]); - auto closeResult = _uiCommandList[fIndex]->Close(); + LOG_DEBUG("Executing _uiCommandList[fIndex][{}]: {:X}", fIndex, (size_t) _uiCommandList[fIndex]); + auto closeResult = _uiCommandList[fIndex]->Close(); - if (closeResult == S_OK) - _gameCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &_uiCommandList[fIndex]); - else - LOG_ERROR("_uiCommandList[{}]->Close() error: {:X}", fIndex, (UINT) closeResult); + if (closeResult == S_OK) + _gameCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &_uiCommandList[fIndex]); + else + LOG_ERROR("_uiCommandList[{}]->Close() error: {:X}", fIndex, (UINT) closeResult); - _uiCommandListResetted[fIndex] = false; - } + _uiCommandListResetted[fIndex] = false; } if (_lastDispatchedFrame == _frameCount) diff --git a/OptiScaler/framegen/ffx/FSRFG_Dx12.h b/OptiScaler/framegen/ffx/FSRFG_Dx12.h index f122562f..fe6ec056 100644 --- a/OptiScaler/framegen/ffx/FSRFG_Dx12.h +++ b/OptiScaler/framegen/ffx/FSRFG_Dx12.h @@ -90,8 +90,6 @@ class FSRFG_Dx12 : public virtual IFGFeature_Dx12 void SetResourceReady(FG_ResourceType type) override final; void SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue) override final; - ID3D12GraphicsCommandList* GetUICommandList(int index = -1) override final; - ffxReturnCode_t DispatchCallback(ffxDispatchDescFrameGeneration* params); FSRFG_Dx12() : IFGFeature_Dx12(), IFGFeature() { diff --git a/OptiScaler/framegen/xefg/XeFG_Dx12.cpp b/OptiScaler/framegen/xefg/XeFG_Dx12.cpp index 0686723d..97126180 100644 --- a/OptiScaler/framegen/xefg/XeFG_Dx12.cpp +++ b/OptiScaler/framegen/xefg/XeFG_Dx12.cpp @@ -649,6 +649,7 @@ void XeFG_Dx12::EvaluateState(ID3D12Device* device, FG_Constants& fgConstants) // If there is a change deactivate it else if (State::Instance().FGchanged) { + LOG_DEBUG("FGChanged"); Deactivate(); // Pause for 10 frames @@ -664,6 +665,7 @@ void XeFG_Dx12::EvaluateState(ID3D12Device* device, FG_Constants& fgConstants) } else { + LOG_DEBUG("!FGEnabled"); Deactivate(); State::Instance().ClearCapturedHudlesses = true; @@ -768,22 +770,18 @@ bool XeFG_Dx12::Present() } } - if (Config::Instance()->FGEnabled.value_or_default()) + auto fIndex = GetIndex(); + if (_uiCommandListResetted[fIndex]) { - auto fIndex = GetIndex(); - if (_uiCommandListResetted[fIndex]) - { + LOG_DEBUG("Executing _uiCommandList[{}]: {:X}", fIndex, (size_t) _uiCommandList[fIndex]); + auto closeResult = _uiCommandList[fIndex]->Close(); - LOG_DEBUG("Executing _uiCommandList[{}]: {:X}", fIndex, (size_t) _uiCommandList[fIndex]); - auto closeResult = _uiCommandList[fIndex]->Close(); + if (closeResult == S_OK) + _gameCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &_uiCommandList[fIndex]); + else + LOG_ERROR("_uiCommandList[{}]->Close() error: {:X}", fIndex, (UINT) closeResult); - if (closeResult != S_OK) - _gameCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &_uiCommandList[fIndex]); - else - LOG_ERROR("_uiCommandList[{}]->Close() error: {:X}", fIndex, (UINT) closeResult); - - _uiCommandListResetted[fIndex] = false; - } + _uiCommandListResetted[fIndex] = false; } if (_lastDispatchedFrame == _frameCount) @@ -955,64 +953,6 @@ void XeFG_Dx12::SetResourceReady(FG_ResourceType type) { _resourceReady[GetIndex void XeFG_Dx12::SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue) { _gameCommandQueue = queue; } -ID3D12GraphicsCommandList* XeFG_Dx12::GetUICommandList(int index) -{ - if (index < 0) - index = GetIndex(); - - LOG_DEBUG("index: {}", index); - - if (_uiCommandAllocator[0] == nullptr) - { - if (_device != nullptr) - CreateObjects(_device); - else if (State::Instance().currentD3D12Device != nullptr) - CreateObjects(State::Instance().currentD3D12Device); - else - return nullptr; - } - - if (Config::Instance()->FGEnabled.value_or_default()) - { - for (size_t i = 0; i < BUFFER_COUNT; i++) - { - if (i != index && _uiCommandListResetted[i]) - { - LOG_DEBUG("Executing _uiCommandList[{}]: {:X}", i, (size_t) _uiCommandList[i]); - auto closeResult = _uiCommandList[i]->Close(); - - if (closeResult == S_OK) - _gameCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList**) &_uiCommandList[i]); - else - LOG_ERROR("_uiCommandList[{}]->Close() error: {:X}", i, (UINT) closeResult); - - _uiCommandListResetted[i] = false; - } - } - - if (!_uiCommandListResetted[index]) - { - _uiCommandListResetted[index] = true; - - auto result = _uiCommandAllocator[index]->Reset(); - - if (result == S_OK) - { - result = _uiCommandList[index]->Reset(_uiCommandAllocator[index], nullptr); - - if (result != S_OK) - LOG_ERROR("_uiCommandList[{}]->Reset() error: {:X}", index, (UINT) result); - } - else - { - LOG_ERROR("_uiCommandAllocator[{}]->Reset() error: {:X}", index, (UINT) result); - } - } - } - - return _uiCommandList[index]; -} - bool XeFG_Dx12::ReleaseSwapchain(HWND hwnd) { if (hwnd != _hwnd || _hwnd == NULL) diff --git a/OptiScaler/framegen/xefg/XeFG_Dx12.h b/OptiScaler/framegen/xefg/XeFG_Dx12.h index 59845a97..9bc85c5a 100644 --- a/OptiScaler/framegen/xefg/XeFG_Dx12.h +++ b/OptiScaler/framegen/xefg/XeFG_Dx12.h @@ -63,8 +63,6 @@ class XeFG_Dx12 : public virtual IFGFeature_Dx12 void SetResourceReady(FG_ResourceType type) override final; void SetCommandQueue(FG_ResourceType type, ID3D12CommandQueue* queue) override final; - ID3D12GraphicsCommandList* GetUICommandList(int index = -1) override final; - void* FrameGenerationContext() override final; void* SwapchainContext() override final;