From c1f56fcdfbf3bd6eac36a09b2f23450ed9dd0ab2 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Wed, 13 Mar 2024 16:59:32 +0300 Subject: [PATCH] better ini option --- CyberXeSS/Config.cpp | 2 +- CyberXeSS/Config.h | 2 +- CyberXeSS/backends/fsr2/FSR2Feature_Dx11On12.cpp | 6 ++++-- CyberXeSS/backends/xess/XeSSFeature_Dx11.cpp | 7 +++++-- nvngx.ini | 16 ++++++++++++---- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CyberXeSS/Config.cpp b/CyberXeSS/Config.cpp index 9d2b2ba8..efb40404 100644 --- a/CyberXeSS/Config.cpp +++ b/CyberXeSS/Config.cpp @@ -98,7 +98,7 @@ void Config::Reload() FsrVerticalFov = readFloat("FSR", "VerticalFov"); - UseSyncQueries = readBool("Dx11withDx12", "UseSyncQueries"); + UseSafeSyncQueries = readInt("Dx11withDx12", "UseSafeSyncQueries"); } } diff --git a/CyberXeSS/Config.h b/CyberXeSS/Config.h index 5f39692d..bc006352 100644 --- a/CyberXeSS/Config.h +++ b/CyberXeSS/Config.h @@ -86,7 +86,7 @@ public: std::optional FsrVerticalFov; // dx11wdx12 - std::optional UseSyncQueries; + std::optional UseSafeSyncQueries; // Engine Info diff --git a/CyberXeSS/backends/fsr2/FSR2Feature_Dx11On12.cpp b/CyberXeSS/backends/fsr2/FSR2Feature_Dx11On12.cpp index fc1cef73..075641f1 100644 --- a/CyberXeSS/backends/fsr2/FSR2Feature_Dx11On12.cpp +++ b/CyberXeSS/backends/fsr2/FSR2Feature_Dx11On12.cpp @@ -484,8 +484,10 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N spdlog::warn("FSR2FeatureDx11on12::Evaluate bias mask not exist and its enabled in config, it may cause problems!!"); } - Dx11DeviceContext->Signal(dx11fence_1, 10); + if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0) + Dx11DeviceContext->Flush(); + Dx11DeviceContext->Signal(dx11fence_1, 10); Dx12CommandQueue->Wait(dx12fence_1, 10); if (paramColor) @@ -701,7 +703,7 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N Dx11DeviceContext->Wait(dx11fence_2, 20); // copy back output - if (Config::Instance()->UseSyncQueries.value_or(false)) + if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 1) { // intel arc fix D3D11_QUERY_DESC pQueryDesc{}; diff --git a/CyberXeSS/backends/xess/XeSSFeature_Dx11.cpp b/CyberXeSS/backends/xess/XeSSFeature_Dx11.cpp index 785c43e8..f3628670 100644 --- a/CyberXeSS/backends/xess/XeSSFeature_Dx11.cpp +++ b/CyberXeSS/backends/xess/XeSSFeature_Dx11.cpp @@ -494,6 +494,9 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK spdlog::warn("XeSSFeatureDx11::Evaluate bias mask not exist and its enabled in config, it may cause problems!!"); } + if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0) + Dx11DeviceContext->Flush(); + Dx11DeviceContext->Signal(dx11fence_1, 10); Dx12CommandQueue->Wait(dx12fence_1, 10); @@ -674,7 +677,7 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK // copy back output - if (Config::Instance()->UseSyncQueries.value_or(false)) + if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 1) { D3D11_QUERY_DESC pQueryDesc{}; pQueryDesc.Query = D3D11_QUERY_EVENT; @@ -696,7 +699,7 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK Dx11DeviceContext->End(query1); // Execute dx11 commands - //Dx11DeviceContext->Flush(); + Dx11DeviceContext->Flush(); // wait for completion while (Dx11DeviceContext->GetData(query1, nullptr, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_FALSE); diff --git a/nvngx.ini b/nvngx.ini index 1fa8a4b2..49f15bb7 100644 --- a/nvngx.ini +++ b/nvngx.ini @@ -10,10 +10,18 @@ Dx11Upscaler=auto Dx12Upscaler=auto [Dx11withDx12] -; Use a DX11 Query to ensure copyback operation for output texture is finished -; Needed for Intel Arc cards :/ -; true or false - Default (auto) is false -Dx11withDx12=auto +; Safe syncing measures for Dx11 with Dx12 +; Might be needed for Intel Arc cards or different Dx11 drivers +; +; Valid values are; +; 0 - Safe syncing is off +; 1 - Flush after Dx11 texture copies +; 2 - Sync after output copy +; +; 0 is fastest, 2 is slowest +; +; 0 - 2 - Default (auto) is 0 +UseSafeSyncQueries=auto [XeSS] ; Building pipeline for XeSS before init