mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-10-08 21:11:39 +00:00
Move global fake frame counts to IFGFeature
This commit is contained in:
1 parent
c64533a267
commit
8fb29f0fe8
6 files changed
+44
-52
No files matched your search
@@ -215,12 +215,9 @@ class State
|
||||
float lastMipBias = 100.0f;
|
||||
float lastMipBiasMax = -100.0f;
|
||||
|
||||
int xefgMaxInterpolationCount = 1;
|
||||
bool WAR_xefgRequestFGToggle = false;
|
||||
|
||||
int dlssgMaxInterpolationCount = 1;
|
||||
bool dlssgGameDMFGSupported = false;
|
||||
bool dlssgOptiDMFGSupported = false;
|
||||
sl::DLSSGMode dlssgLastSetMode = sl::DLSSGMode::eOff;
|
||||
int dlssgDetectedInterpolationCount = 0;
|
||||
|
||||
|
||||
@@ -322,4 +322,8 @@ void IFGFeature::SetResourceReady(FG_ResourceType type, int index)
|
||||
_resourceFrame[type] = _frameCount;
|
||||
}
|
||||
|
||||
UINT IFGFeature::GetInterpolatedFrameCount() { return _framesToInterpolate < 0 ? 1 : _framesToInterpolate; }
|
||||
UINT IFGFeature::GetInterpolatedFrameCount() const { return _framesToInterpolate < 0 ? 1 : _framesToInterpolate; }
|
||||
|
||||
int IFGFeature::GetMaxInterpolationCount() const { return _maxInterpolationCount; }
|
||||
|
||||
bool IFGFeature::GetDMFGSupport() const { return _supportsDMFG; }
|
||||
@@ -72,6 +72,8 @@ class IFGFeature
|
||||
UINT64 _lastFGFrame = 0;
|
||||
bool _waitingNewFrameData = false;
|
||||
int _framesToInterpolate = -1;
|
||||
int _maxInterpolationCount = 1;
|
||||
bool _supportsDMFG = false;
|
||||
|
||||
bool _isActive = false;
|
||||
UINT64 _targetFrame = 0;
|
||||
@@ -145,7 +147,9 @@ class IFGFeature
|
||||
void SetInterpolationPos(UINT left, UINT top, int index = -1);
|
||||
void GetInterpolationPos(UINT& left, UINT& top, int index = -1);
|
||||
void SetResourceReady(FG_ResourceType type, int index = -1);
|
||||
UINT GetInterpolatedFrameCount();
|
||||
UINT GetInterpolatedFrameCount() const;
|
||||
int GetMaxInterpolationCount() const;
|
||||
bool GetDMFGSupport() const;
|
||||
|
||||
void ResetCounters();
|
||||
void UpdateTarget();
|
||||
|
||||
@@ -119,15 +119,10 @@ bool DLSSG_Dx12::CreateSwapchain(IDXGIFactory* factory, ID3D12CommandQueue* cmdQ
|
||||
sl::DLSSGOptions dlssgOptions {};
|
||||
if (StreamlineProxy::DLSSGGetState()(viewport, dlssgState, &dlssgOptions) == sl::Result::eOk)
|
||||
{
|
||||
State::Instance().dlssgMaxInterpolationCount = dlssgState.numFramesToGenerateMax;
|
||||
_maxInterpolationCount = dlssgState.numFramesToGenerateMax;
|
||||
LOG_INFO("Max supported interpolations: {}", dlssgState.numFramesToGenerateMax);
|
||||
|
||||
int maxCount = State::Instance().dlssgMaxInterpolationCount;
|
||||
|
||||
if (_framesToInterpolate > State::Instance().dlssgMaxInterpolationCount)
|
||||
_framesToInterpolate = maxCount;
|
||||
|
||||
State::Instance().dlssgOptiDMFGSupported = dlssgState.bIsDynamicMFGSupported == sl::Boolean::eTrue;
|
||||
_supportsDMFG = dlssgState.bIsDynamicMFGSupported == sl::Boolean::eTrue;
|
||||
}
|
||||
|
||||
_gameCommandQueue = cmdQueue;
|
||||
@@ -233,15 +228,10 @@ bool DLSSG_Dx12::CreateSwapchain1(IDXGIFactory* factory, ID3D12CommandQueue* cmd
|
||||
sl::DLSSGOptions dlssgOptions {};
|
||||
if (StreamlineProxy::DLSSGGetState()(viewport, dlssgState, &dlssgOptions) == sl::Result::eOk)
|
||||
{
|
||||
State::Instance().dlssgMaxInterpolationCount = dlssgState.numFramesToGenerateMax;
|
||||
_maxInterpolationCount = dlssgState.numFramesToGenerateMax;
|
||||
LOG_INFO("Max supported interpolations: {}", dlssgState.numFramesToGenerateMax);
|
||||
|
||||
int maxCount = State::Instance().dlssgMaxInterpolationCount;
|
||||
|
||||
if (_framesToInterpolate > State::Instance().dlssgMaxInterpolationCount)
|
||||
_framesToInterpolate = maxCount;
|
||||
|
||||
State::Instance().dlssgOptiDMFGSupported = dlssgState.bIsDynamicMFGSupported == sl::Boolean::eTrue;
|
||||
_supportsDMFG = dlssgState.bIsDynamicMFGSupported == sl::Boolean::eTrue;
|
||||
}
|
||||
|
||||
_gameCommandQueue = cmdQueue;
|
||||
@@ -345,11 +335,11 @@ bool DLSSG_Dx12::Dispatch()
|
||||
|
||||
auto& state = State::Instance();
|
||||
|
||||
if (Config::Instance()->FGDLSSGInterpolationCount.value_or_default() > State::Instance().dlssgMaxInterpolationCount)
|
||||
if (Config::Instance()->FGDLSSGInterpolationCount.value_or_default() > _maxInterpolationCount)
|
||||
{
|
||||
Config::Instance()->FGDLSSGInterpolationCount = State::Instance().dlssgMaxInterpolationCount;
|
||||
Config::Instance()->FGDLSSGInterpolationCount = _maxInterpolationCount;
|
||||
LOG_WARN("Requested interpolation count is higher than max supported, setting to max: {}",
|
||||
State::Instance().dlssgMaxInterpolationCount);
|
||||
_maxInterpolationCount);
|
||||
}
|
||||
|
||||
if (_framesToInterpolate != Config::Instance()->FGDLSSGInterpolationCount.value_or_default())
|
||||
|
||||
@@ -136,7 +136,7 @@ const char* XeFG_Dx12::Name()
|
||||
{
|
||||
static std::string nameBuffer;
|
||||
|
||||
if (State::Instance().xefgMaxInterpolationCount == 1 || _framesToInterpolate < 0)
|
||||
if (_maxInterpolationCount == 1 || _framesToInterpolate < 0)
|
||||
{
|
||||
nameBuffer = "XeFG";
|
||||
}
|
||||
@@ -301,7 +301,7 @@ bool XeFG_Dx12::CreateSwapchain(IDXGIFactory* factory, ID3D12CommandQueue* cmdQu
|
||||
auto result = XeFGProxy::GetProperties()(_swapChainContext, &props);
|
||||
if (result == XEFG_SWAPCHAIN_RESULT_SUCCESS)
|
||||
{
|
||||
State::Instance().xefgMaxInterpolationCount = props.maxSupportedInterpolations;
|
||||
_maxInterpolationCount = props.maxSupportedInterpolations;
|
||||
LOG_INFO("Max supported interpolations: {}", props.maxSupportedInterpolations);
|
||||
}
|
||||
else
|
||||
@@ -363,16 +363,15 @@ bool XeFG_Dx12::CreateSwapchain(IDXGIFactory* factory, ID3D12CommandQueue* cmdQu
|
||||
|
||||
xefg_swapchain_d3d12_init_params_t params {};
|
||||
|
||||
int intTarget = State::Instance().xefgMaxInterpolationCount;
|
||||
int intTarget = _maxInterpolationCount;
|
||||
|
||||
// For old libxess_fg versions we use max to control interpolation count
|
||||
if (XeFGProxy::SetNumInterpolatedFrames() == nullptr)
|
||||
intTarget = Config::Instance()->FGXeFGInterpolationCount.value_or_default();
|
||||
|
||||
if (intTarget < 1 || intTarget > State::Instance().xefgMaxInterpolationCount)
|
||||
if (intTarget < 1 || intTarget > _maxInterpolationCount)
|
||||
{
|
||||
LOG_WARN("Invalid XeFG interpolation count: {}, max count: {}", intTarget,
|
||||
State::Instance().xefgMaxInterpolationCount);
|
||||
LOG_WARN("Invalid XeFG interpolation count: {}, max count: {}", intTarget, _maxInterpolationCount);
|
||||
|
||||
intTarget = 1;
|
||||
}
|
||||
@@ -505,7 +504,7 @@ bool XeFG_Dx12::CreateSwapchain1(IDXGIFactory* factory, ID3D12CommandQueue* cmdQ
|
||||
auto result = XeFGProxy::GetProperties()(_swapChainContext, &props);
|
||||
if (result == XEFG_SWAPCHAIN_RESULT_SUCCESS)
|
||||
{
|
||||
State::Instance().xefgMaxInterpolationCount = props.maxSupportedInterpolations;
|
||||
_maxInterpolationCount = props.maxSupportedInterpolations;
|
||||
LOG_INFO("Max supported interpolations: {}", props.maxSupportedInterpolations);
|
||||
}
|
||||
else
|
||||
@@ -531,16 +530,15 @@ bool XeFG_Dx12::CreateSwapchain1(IDXGIFactory* factory, ID3D12CommandQueue* cmdQ
|
||||
|
||||
xefg_swapchain_d3d12_init_params_t params {};
|
||||
|
||||
int intTarget = State::Instance().xefgMaxInterpolationCount;
|
||||
int intTarget = _maxInterpolationCount;
|
||||
|
||||
// For old libxess_fg versions we use max to control interpolation count
|
||||
if (XeFGProxy::SetNumInterpolatedFrames() == nullptr)
|
||||
intTarget = Config::Instance()->FGXeFGInterpolationCount.value_or_default();
|
||||
|
||||
if (intTarget < 1 || intTarget > State::Instance().xefgMaxInterpolationCount)
|
||||
if (intTarget < 1 || intTarget > _maxInterpolationCount)
|
||||
{
|
||||
LOG_WARN("Invalid XeFG interpolation count: {}, max count: {}", intTarget,
|
||||
State::Instance().xefgMaxInterpolationCount);
|
||||
LOG_WARN("Invalid XeFG interpolation count: {}, max count: {}", intTarget, _maxInterpolationCount);
|
||||
|
||||
intTarget = 1;
|
||||
}
|
||||
@@ -780,12 +778,11 @@ bool XeFG_Dx12::Dispatch()
|
||||
|
||||
if (XeFGProxy::SetNumInterpolatedFrames() != nullptr)
|
||||
{
|
||||
if (Config::Instance()->FGXeFGInterpolationCount.value_or_default() >
|
||||
State::Instance().xefgMaxInterpolationCount)
|
||||
if (Config::Instance()->FGXeFGInterpolationCount.value_or_default() > _maxInterpolationCount)
|
||||
{
|
||||
Config::Instance()->FGXeFGInterpolationCount = State::Instance().xefgMaxInterpolationCount;
|
||||
Config::Instance()->FGXeFGInterpolationCount = _maxInterpolationCount;
|
||||
LOG_WARN("Requested interpolation count is higher than max supported, setting to max: {}",
|
||||
State::Instance().xefgMaxInterpolationCount);
|
||||
_maxInterpolationCount);
|
||||
}
|
||||
|
||||
if (_framesToInterpolate != Config::Instance()->FGXeFGInterpolationCount.value_or_default())
|
||||
|
||||
@@ -1782,9 +1782,9 @@ void MenuCommon::RenderPerformanceOverlay(RenderMenuContext& ctx)
|
||||
{
|
||||
fgText = formatFg("Combo", Nvngx_FG::getMaxFakeFramesCount());
|
||||
}
|
||||
else if (state.activeFgOutput == FGOutput::DLSSG)
|
||||
else if (state.activeFgOutput == FGOutput::DLSSG && fg)
|
||||
{
|
||||
fgText = formatFg("DLSSG", state.dlssgMaxInterpolationCount);
|
||||
fgText = formatFg("DLSSG", fg->GetMaxInterpolationCount());
|
||||
}
|
||||
|
||||
const auto overlayType = config->FpsOverlayType.value_or_default();
|
||||
@@ -3514,6 +3514,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
auto& currentFeature = ctx.currentFeature;
|
||||
auto& menuResScale = ctx.menuResScale;
|
||||
auto& primaryGpu = *ctx.primaryGpu;
|
||||
auto fgOutput = state.currentFG;
|
||||
|
||||
// FSR FG controls
|
||||
if (state.activeFgOutput == FGOutput::FSRFG && state.activeFgInput != FGInput::NoFG &&
|
||||
@@ -3769,7 +3770,8 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
|
||||
// XeFG controls
|
||||
if (state.activeFgOutput == FGOutput::XeFG && state.activeFgInput != FGInput::NoFG &&
|
||||
state.activeFgInput != FGInput::ForceXeLL && state.currentFGSwapchain != nullptr && XeFGProxy::InitXeFG())
|
||||
state.activeFgInput != FGInput::ForceXeLL && state.currentFGSwapchain != nullptr && XeFGProxy::InitXeFG() &&
|
||||
fgOutput)
|
||||
{
|
||||
ImGui::SeparatorText("Frame Generation (XeFG)");
|
||||
|
||||
@@ -3779,8 +3781,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
if (state.activeFgInput == FGInput::Upscaler && currentFeature != nullptr)
|
||||
nativeAA = currentFeature->RenderWidth() == currentFeature->DisplayWidth();
|
||||
|
||||
auto fgOutput = reinterpret_cast<IFGFeature_Dx12*>(state.currentFG);
|
||||
const bool correctMVs = fgOutput && fgOutput->IsLowResMV() || nativeAA ||
|
||||
const bool correctMVs = fgOutput->IsLowResMV() || nativeAA ||
|
||||
(State::Instance().gameQuirks & GameQuirk::ForceFGRenderSizeMVs) || ignoreChecks;
|
||||
|
||||
if (!correctMVs || state.realExclusiveFullscreen)
|
||||
@@ -3789,10 +3790,9 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
config->FGXeFGDebugView.reset();
|
||||
}
|
||||
|
||||
const bool restartNeeded =
|
||||
fgOutput && (config->FGXeFGDepthInverted.value_or_default() != fgOutput->IsInvertedDepth() ||
|
||||
config->FGXeFGJitteredMV.value_or_default() != fgOutput->IsJitteredMVs() ||
|
||||
config->FGXeFGHighResMV.value_or_default() == fgOutput->IsLowResMV());
|
||||
const bool restartNeeded = config->FGXeFGDepthInverted.value_or_default() != fgOutput->IsInvertedDepth() ||
|
||||
config->FGXeFGJitteredMV.value_or_default() != fgOutput->IsJitteredMVs() ||
|
||||
config->FGXeFGHighResMV.value_or_default() == fgOutput->IsLowResMV();
|
||||
|
||||
bool cantActivate = false;
|
||||
if (restartNeeded)
|
||||
@@ -3847,14 +3847,14 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
|
||||
ShowHelpMarker("Enable Frame Generation");
|
||||
|
||||
auto maxInterpolationCount = state.xefgMaxInterpolationCount;
|
||||
auto maxInterpolationCount = fgOutput->GetMaxInterpolationCount();
|
||||
|
||||
if (maxInterpolationCount > 1)
|
||||
{
|
||||
ImGui::SameLine(0.0f, 16.0f);
|
||||
|
||||
const char* intModes[] = { "2X", "3X", "4X", "5X", "6X" };
|
||||
auto currentSet = config->FGXeFGInterpolationCount.value_or_default() - 1;
|
||||
auto currentSet = fgOutput->GetInterpolatedFrameCount() - 1;
|
||||
auto currentIntCount = intModes[currentSet];
|
||||
|
||||
ImGui::PushItemWidth(95.0f * menuResScale);
|
||||
@@ -3973,7 +3973,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
|
||||
// DLSSG controls
|
||||
if (state.activeFgOutput == FGOutput::DLSSG && state.activeFgInput != FGInput::NoFG &&
|
||||
state.currentFGSwapchain != nullptr && StreamlineProxy::LoadStreamline())
|
||||
state.currentFGSwapchain != nullptr && StreamlineProxy::LoadStreamline() && fgOutput)
|
||||
{
|
||||
ImGui::SeparatorText("Frame Generation (DLSSG)");
|
||||
|
||||
@@ -4009,7 +4009,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
|
||||
ShowHelpMarker("Enable Frame Generation");
|
||||
|
||||
auto maxInterpolationCount = state.dlssgMaxInterpolationCount;
|
||||
auto maxInterpolationCount = fgOutput->GetMaxInterpolationCount();
|
||||
|
||||
if (maxInterpolationCount > 1)
|
||||
{
|
||||
@@ -4018,7 +4018,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
ImGui::BeginDisabled(config->FGDLSSGForceDMFG.value_or_default());
|
||||
|
||||
const char* intModes[] = { "2X", "3X", "4X", "5X", "6X" };
|
||||
auto currentSet = config->FGDLSSGInterpolationCount.value_or_default() - 1;
|
||||
auto currentSet = fgOutput->GetInterpolatedFrameCount() - 1;
|
||||
auto currentIntCount = intModes[currentSet];
|
||||
|
||||
ImGui::PushItemWidth(95.0f * menuResScale);
|
||||
@@ -4043,7 +4043,7 @@ void MenuCommon::RenderFrameGenerationRuntimeSettings(RenderMenuContext& ctx)
|
||||
|
||||
ImGui::EndDisabled();
|
||||
|
||||
if (state.dlssgOptiDMFGSupported)
|
||||
if (fgOutput->GetDMFGSupport())
|
||||
{
|
||||
ImGui::SameLine(0.0f, 16.0f);
|
||||
|
||||
|
||||
Reference in new issue
Block a user