From 4a2768c19b525d8124b70570991561e64d94aa7b Mon Sep 17 00:00:00 2001 From: cdozdil Date: Sun, 14 Jul 2024 19:45:37 +0300 Subject: [PATCH] more pag stuff (not active yet) --- OptiScaler/Config.cpp | 2 ++ OptiScaler/Config.h | 1 + OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp | 15 +++++++++++++-- OptiScaler/backends/fsr2/FSR2Feature_Dx12.h | 2 ++ OptiScaler/imgui/imgui_common.h | 11 +++++++++-- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/OptiScaler/Config.cpp b/OptiScaler/Config.cpp index 1fe6ddd0..a80cef4c 100644 --- a/OptiScaler/Config.cpp +++ b/OptiScaler/Config.cpp @@ -50,6 +50,7 @@ bool Config::Reload(std::filesystem::path iniPath) FsrCameraFar = readFloat("FSR", "CameraFar"); FsrDebugView = readBool("FSR", "DebugView"); Fsr3xIndex = readInt("FSR", "UpscalerIndex"); + FsrUsePAG = readBool("FSR", "UsePAG"); } // XeSS @@ -418,6 +419,7 @@ bool Config::SaveIni() ini.SetValue("FSR", "CameraFar", GetFloatValue(Instance()->FsrCameraFar).c_str()); ini.SetValue("FSR", "DebugView", GetBoolValue(Instance()->FsrDebugView).c_str()); ini.SetValue("FSR", "UpscalerIndex", GetIntValue(Instance()->Fsr3xIndex).c_str()); + ini.SetValue("FSR", "UsePAG", GetBoolValue(Instance()->FsrUsePAG).c_str()); } // XeSS diff --git a/OptiScaler/Config.h b/OptiScaler/Config.h index ebc4a1db..484b6eff 100644 --- a/OptiScaler/Config.h +++ b/OptiScaler/Config.h @@ -125,6 +125,7 @@ public: std::optional FsrCameraFar; std::optional FsrDebugView; std::optional Fsr3xIndex; + std::optional FsrUsePAG; // dx11wdx12 std::optional TextureSyncMethod; diff --git a/OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp b/OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp index b9d42ec8..95b43c5f 100644 --- a/OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp +++ b/OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp @@ -20,6 +20,7 @@ bool FSR2FeatureDx12::Init(ID3D12Device* InDevice, ID3D12GraphicsCommandList* In OutputScaler = std::make_unique("Output Downsample", InDevice, (TargetWidth() < DisplayWidth())); RCAS = std::make_unique("RCAS", InDevice); + //PAG = std::make_unique("PAG", InDevice); return true; } @@ -238,8 +239,18 @@ bool FSR2FeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, NVSDK_N else spdlog::debug("FSR2FeatureDx12::Evaluate AutoExposure enabled!"); + bool pagOK = false; + //if (Config::Instance()->FsrUsePAG.value_or(false) && PAG != nullptr && PAG.get() != nullptr && PAG->IsInit() && + // PAG->Dispatch(Device, InCommandList, paramColor, paramDepth, paramVelocity, { params.jitterOffset.x, params.jitterOffset.y })) + //{ + // pagOK = true; + + // params.reactive = ffxGetResourceDX12(&_context, PAG->ReactiveMask(), (wchar_t*)L"FSR2_Reactive", FFX_RESOURCE_STATE_COMPUTE_READ); + // params.motionVectors = ffxGetResourceDX12(&_context, PAG->MotionVector(), (wchar_t*)L"FSR2_MotionVectors", FFX_RESOURCE_STATE_COMPUTE_READ); + //} + ID3D12Resource* paramMask = nullptr; - if (!Config::Instance()->DisableReactiveMask.value_or(true)) + if (!pagOK && !Config::Instance()->DisableReactiveMask.value_or(true)) { if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, ¶mMask) != NVSDK_NGX_Result_Success) InParameters->Get(NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, (void**)¶mMask); @@ -497,7 +508,7 @@ bool FSR2FeatureDx12::InitFSR2(const NVSDK_NGX_Parameter* InParameters) bool EnableSharpening = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_DoSharpening; bool DepthInverted = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_DepthInverted; bool JitterMotion = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_MVJittered; - bool LowRes = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_MVLowRes; + bool LowRes = Config::Instance()->FsrUsePAG.value_or(false) || (featureFlags & NVSDK_NGX_DLSS_Feature_Flags_MVLowRes); bool AutoExposure = featureFlags & NVSDK_NGX_DLSS_Feature_Flags_AutoExposure; if (Config::Instance()->DepthInverted.value_or(DepthInverted)) diff --git a/OptiScaler/backends/fsr2/FSR2Feature_Dx12.h b/OptiScaler/backends/fsr2/FSR2Feature_Dx12.h index aa353b60..fe38c453 100644 --- a/OptiScaler/backends/fsr2/FSR2Feature_Dx12.h +++ b/OptiScaler/backends/fsr2/FSR2Feature_Dx12.h @@ -1,6 +1,7 @@ #pragma once #include "FSR2Feature.h" #include "../IFeature_Dx12.h" +#include "../../pag/PAG_Dx12.h" #include "../../fsr2/include/ffx_fsr2.h" #include "../../fsr2/include/dx12/ffx_fsr2_dx12.h" @@ -8,6 +9,7 @@ class FSR2FeatureDx12 : public FSR2Feature, public IFeature_Dx12 { private: + //std::unique_ptr PAG = nullptr; protected: bool InitFSR2(const NVSDK_NGX_Parameter* InParameters); diff --git a/OptiScaler/imgui/imgui_common.h b/OptiScaler/imgui/imgui_common.h index 8f21504a..44d94bbd 100644 --- a/OptiScaler/imgui/imgui_common.h +++ b/OptiScaler/imgui/imgui_common.h @@ -370,14 +370,14 @@ private: // END - REINIT MENU - if (msg == WM_KEYDOWN && wParam == Config::Instance()->ResetKey.value_or(VK_END)) + if ((msg == WM_KEYDOWN && wParam == Config::Instance()->ResetKey.value_or(VK_END)) || vmInputReset) { _isResetRequested = true; return CallWindowProc(_oWndProc, hWnd, msg, wParam, lParam); } // INSERT - OPEN MENU - if (msg == WM_KEYDOWN && wParam == Config::Instance()->ShortcutKey.value_or(VK_INSERT)) + if ((msg == WM_KEYDOWN && wParam == Config::Instance()->ShortcutKey.value_or(VK_INSERT)) || vmInputMenu) { _isVisible = !_isVisible; @@ -1015,6 +1015,13 @@ public: } } + //if (bool enablePAG = Config::Instance()->FsrUsePAG.value_or(false); ImGui::Checkbox("Enable Potato Anti-Ghosting", &enablePAG)) + //{ + // Config::Instance()->FsrUsePAG = enablePAG; + // Config::Instance()->newBackend = currentBackend; + // Config::Instance()->changeBackend = true; + //} + bool useVFov = Config::Instance()->FsrVerticalFov.has_value() || !Config::Instance()->FsrHorizontalFov.has_value(); float vfov;