From 57b7482d6f8f74de6307100e25aaa4b02ad87f2d Mon Sep 17 00:00:00 2001 From: cdozdil Date: Wed, 31 Jul 2024 01:26:10 +0300 Subject: [PATCH] more scale < 1.0 fixes --- OptiScaler/backends/fsr2/FSR2Feature_Dx11On12.cpp | 6 ++++-- OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp | 14 +++++++------- .../backends/fsr2_212/FSR2Feature_Dx11On12_212.cpp | 11 +++++------ .../backends/fsr2_212/FSR2Feature_Dx12_212.cpp | 9 ++++----- .../backends/fsr31/FSR31Feature_Dx11On12.cpp | 9 ++++++--- OptiScaler/backends/fsr31/FSR31Feature_Dx12.cpp | 7 +++++-- OptiScaler/imgui/imgui_common.h | 4 +--- OptiScaler/output_scaling/OS_Dx12.cpp | 8 +++++--- 8 files changed, 37 insertions(+), 31 deletions(-) diff --git a/OptiScaler/backends/fsr2/FSR2Feature_Dx11On12.cpp b/OptiScaler/backends/fsr2/FSR2Feature_Dx11On12.cpp index a5d6dc60..ad705809 100644 --- a/OptiScaler/backends/fsr2/FSR2Feature_Dx11On12.cpp +++ b/OptiScaler/backends/fsr2/FSR2Feature_Dx11On12.cpp @@ -656,6 +656,8 @@ bool FSR2FeatureDx11on12::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.maxRenderSize.width = RenderWidth(); _contextDesc.maxRenderSize.height = RenderHeight(); + Config::Instance()->OutputScalingMultiplier = 1.0f; + // if output scaling active let it to handle downsampling if (Config::Instance()->OutputScalingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false)) { @@ -663,8 +665,8 @@ bool FSR2FeatureDx11on12::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.displaySize.height = _contextDesc.maxRenderSize.height; // update target res - _targetWidth = _contextDesc.displaySize.width; - _targetHeight = _contextDesc.displaySize.height; + _targetWidth = _contextDesc.maxRenderSize.width; + _targetHeight = _contextDesc.maxRenderSize.height; } else { diff --git a/OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp b/OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp index 5c7ec2bf..7d9535ae 100644 --- a/OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp +++ b/OptiScaler/backends/fsr2/FSR2Feature_Dx12.cpp @@ -27,7 +27,7 @@ bool FSR2FeatureDx12::Init(ID3D12Device* InDevice, ID3D12GraphicsCommandList* In return false; } - + bool FSR2FeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, NVSDK_NGX_Parameter* InParameters) { LOG_FUNC(); @@ -256,7 +256,7 @@ bool FSR2FeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, NVSDK_N if (Config::Instance()->FsrUseMaskForTransparency.value_or(true)) params.transparencyAndComposition = ffxGetResourceDX12(&_context, paramReactiveMask, (wchar_t*)L"FSR2_Transparency", FFX_RESOURCE_STATE_COMPUTE_READ); - if (Config::Instance()->DlssReactiveMaskBias.value_or(0.45f) > 0.0f && + if (Config::Instance()->DlssReactiveMaskBias.value_or(0.45f) > 0.0f && Bias->IsInit() && Bias->CreateBufferResource(Device, paramReactiveMask, D3D12_RESOURCE_STATE_UNORDERED_ACCESS) && Bias->CanRender()) { Bias->SetBufferState(InCommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); @@ -597,15 +597,18 @@ bool FSR2FeatureDx12::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.maxRenderSize.width = RenderWidth(); _contextDesc.maxRenderSize.height = RenderHeight(); + Config::Instance()->OutputScalingMultiplier = 1.0f; + // if output scaling active let it to handle downsampling if (Config::Instance()->OutputScalingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false)) { + _contextDesc.displaySize.width = _contextDesc.maxRenderSize.width; _contextDesc.displaySize.height = _contextDesc.maxRenderSize.height; // update target res - _targetWidth = _contextDesc.displaySize.width; - _targetHeight = _contextDesc.displaySize.height; + _targetWidth = _contextDesc.maxRenderSize.width; + _targetHeight = _contextDesc.maxRenderSize.height; } else { @@ -621,9 +624,6 @@ bool FSR2FeatureDx12::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.displaySize.height = TargetHeight(); } - _contextDesc.displaySize.width = TargetWidth(); - _contextDesc.displaySize.height = TargetHeight(); - #if _DEBUG _contextDesc.flags |= FFX_FSR2_ENABLE_DEBUG_CHECKING; _contextDesc.fpMessage = FfxLogCallback; diff --git a/OptiScaler/backends/fsr2_212/FSR2Feature_Dx11On12_212.cpp b/OptiScaler/backends/fsr2_212/FSR2Feature_Dx11On12_212.cpp index 033f8490..d166d3e0 100644 --- a/OptiScaler/backends/fsr2_212/FSR2Feature_Dx11On12_212.cpp +++ b/OptiScaler/backends/fsr2_212/FSR2Feature_Dx11On12_212.cpp @@ -231,7 +231,7 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, NVS { Bias->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - if (Config::Instance()->DlssReactiveMaskBias.value_or(0.45f) > 0.0f && + if (Config::Instance()->DlssReactiveMaskBias.value_or(0.45f) > 0.0f && Bias->Dispatch(Dx12Device, Dx12CommandList, dx11Reactive.Dx12Resource, Config::Instance()->DlssReactiveMaskBias.value_or(0.45f), Bias->Buffer())) { Bias->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); @@ -661,6 +661,8 @@ bool FSR2FeatureDx11on12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.maxRenderSize.width = RenderWidth(); _contextDesc.maxRenderSize.height = RenderHeight(); + Config::Instance()->OutputScalingMultiplier = 1.0f; + // if output scaling active let it to handle downsampling if (Config::Instance()->OutputScalingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false)) { @@ -668,8 +670,8 @@ bool FSR2FeatureDx11on12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.displaySize.height = _contextDesc.maxRenderSize.height; // update target res - _targetWidth = _contextDesc.displaySize.width; - _targetHeight = _contextDesc.displaySize.height; + _targetWidth = _contextDesc.maxRenderSize.width; + _targetHeight = _contextDesc.maxRenderSize.height; } else { @@ -685,9 +687,6 @@ bool FSR2FeatureDx11on12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.displaySize.height = TargetHeight(); } - _contextDesc.displaySize.width = TargetWidth(); - _contextDesc.displaySize.height = TargetHeight(); - LOG_DEBUG("ffxFsr2ContextCreate!"); auto ret = Fsr212::ffxFsr2ContextCreate212(&_context, &_contextDesc); diff --git a/OptiScaler/backends/fsr2_212/FSR2Feature_Dx12_212.cpp b/OptiScaler/backends/fsr2_212/FSR2Feature_Dx12_212.cpp index 1eac90f6..c2a66f8a 100644 --- a/OptiScaler/backends/fsr2_212/FSR2Feature_Dx12_212.cpp +++ b/OptiScaler/backends/fsr2_212/FSR2Feature_Dx12_212.cpp @@ -579,6 +579,8 @@ bool FSR2FeatureDx12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.maxRenderSize.width = RenderWidth(); _contextDesc.maxRenderSize.height = RenderHeight(); + Config::Instance()->OutputScalingMultiplier = 1.0f; + // if output scaling active let it to handle downsampling if (Config::Instance()->OutputScalingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false)) { @@ -586,8 +588,8 @@ bool FSR2FeatureDx12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.displaySize.height = _contextDesc.maxRenderSize.height; // update target res - _targetWidth = _contextDesc.displaySize.width; - _targetHeight = _contextDesc.displaySize.height; + _targetWidth = _contextDesc.maxRenderSize.width; + _targetHeight = _contextDesc.maxRenderSize.height; } else { @@ -603,9 +605,6 @@ bool FSR2FeatureDx12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters) _contextDesc.displaySize.height = TargetHeight(); } - _contextDesc.displaySize.width = TargetWidth(); - _contextDesc.displaySize.height = TargetHeight(); - LOG_DEBUG("ffxFsr2ContextCreate!"); auto ret = Fsr212::ffxFsr2ContextCreate212(&_context, &_contextDesc); diff --git a/OptiScaler/backends/fsr31/FSR31Feature_Dx11On12.cpp b/OptiScaler/backends/fsr31/FSR31Feature_Dx11On12.cpp index 695ca5a3..ecec4562 100644 --- a/OptiScaler/backends/fsr31/FSR31Feature_Dx11On12.cpp +++ b/OptiScaler/backends/fsr31/FSR31Feature_Dx11On12.cpp @@ -267,7 +267,7 @@ bool FSR31FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, NVSDK_ if (Config::Instance()->FsrUseMaskForTransparency.value_or(true)) params.transparencyAndComposition = ffxApiGetResourceDX12(dx11Reactive.Dx12Resource, FFX_API_RESOURCE_STATE_COMPUTE_READ); - if (Config::Instance()->DlssReactiveMaskBias.value_or(0.45f) > 0.0f && + if (Config::Instance()->DlssReactiveMaskBias.value_or(0.45f) > 0.0f && Bias->IsInit() && Bias->CreateBufferResource(Dx12Device, dx11Reactive.Dx12Resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS) && Bias->CanRender()) { Bias->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); @@ -712,6 +712,8 @@ bool FSR31FeatureDx11on12::InitFSR3(const NVSDK_NGX_Parameter* InParameters) _contextDesc.maxRenderSize.width = RenderWidth(); _contextDesc.maxRenderSize.height = RenderHeight(); + Config::Instance()->OutputScalingMultiplier = 1.0f; + // if output scaling active let it to handle downsampling if (Config::Instance()->OutputScalingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false)) { @@ -719,8 +721,9 @@ bool FSR31FeatureDx11on12::InitFSR3(const NVSDK_NGX_Parameter* InParameters) _contextDesc.maxUpscaleSize.height = _contextDesc.maxRenderSize.height; // update target res - _targetWidth = _contextDesc.maxUpscaleSize.width; - _targetHeight = _contextDesc.maxUpscaleSize.height; + _targetWidth = _contextDesc.maxRenderSize.width; + _targetHeight = _contextDesc.maxRenderSize.height; + } else { diff --git a/OptiScaler/backends/fsr31/FSR31Feature_Dx12.cpp b/OptiScaler/backends/fsr31/FSR31Feature_Dx12.cpp index aa2f751a..a000b4e4 100644 --- a/OptiScaler/backends/fsr31/FSR31Feature_Dx12.cpp +++ b/OptiScaler/backends/fsr31/FSR31Feature_Dx12.cpp @@ -631,6 +631,8 @@ bool FSR31FeatureDx12::InitFSR3(const NVSDK_NGX_Parameter* InParameters) _contextDesc.maxRenderSize.width = RenderWidth(); _contextDesc.maxRenderSize.height = RenderHeight(); + Config::Instance()->OutputScalingMultiplier = 1.0f; + // if output scaling active let it to handle downsampling if (Config::Instance()->OutputScalingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false)) { @@ -638,8 +640,9 @@ bool FSR31FeatureDx12::InitFSR3(const NVSDK_NGX_Parameter* InParameters) _contextDesc.maxUpscaleSize.height = _contextDesc.maxRenderSize.height; // update target res - _targetWidth = _contextDesc.maxUpscaleSize.width; - _targetHeight = _contextDesc.maxUpscaleSize.height; + _targetWidth = _contextDesc.maxRenderSize.width; + _targetHeight = _contextDesc.maxRenderSize.height; + } else { diff --git a/OptiScaler/imgui/imgui_common.h b/OptiScaler/imgui/imgui_common.h index 16febe30..57ec141f 100644 --- a/OptiScaler/imgui/imgui_common.h +++ b/OptiScaler/imgui/imgui_common.h @@ -1418,9 +1418,7 @@ public: } ImGui::EndDisabled(); - ImGui::BeginDisabled(!_ssEnabled || - ((currentBackend == "xess" || currentBackend == "dlss") && - Config::Instance()->CurrentFeature->RenderWidth() > Config::Instance()->CurrentFeature->DisplayWidth())); + ImGui::BeginDisabled(!_ssEnabled || Config::Instance()->CurrentFeature->RenderWidth() > Config::Instance()->CurrentFeature->DisplayWidth()); ImGui::SliderFloat("Ratio", &_ssRatio, 0.5f, 3.0f, "%.2f"); ImGui::EndDisabled(); diff --git a/OptiScaler/output_scaling/OS_Dx12.cpp b/OptiScaler/output_scaling/OS_Dx12.cpp index 881f68a5..8da1cc6b 100644 --- a/OptiScaler/output_scaling/OS_Dx12.cpp +++ b/OptiScaler/output_scaling/OS_Dx12.cpp @@ -193,7 +193,9 @@ bool OS_Dx12::Dispatch(ID3D12Device* InDevice, ID3D12GraphicsCommandList* InCmdL UpscaleShaderConstants constants{}; FsrEasuCon(constants.const0, constants.const1, constants.const2, constants.const3, - inDesc.Width, inDesc.Height, inDesc.Width, inDesc.Height, outDesc.Width, outDesc.Height); + inDesc.Width, inDesc.Height, + Config::Instance()->CurrentFeature->TargetWidth(), Config::Instance()->CurrentFeature->TargetHeight(), + Config::Instance()->CurrentFeature->DisplayWidth(), Config::Instance()->CurrentFeature->DisplayHeight()); // Copy the updated constant buffer data to the constant buffer resource UINT8* pCBDataBegin; @@ -210,8 +212,8 @@ bool OS_Dx12::Dispatch(ID3D12Device* InDevice, ID3D12GraphicsCommandList* InCmdL Constants constants{}; constants.srcWidth = static_cast(inDesc.Width); constants.srcHeight = inDesc.Height; - constants.destWidth = static_cast(outDesc.Width); - constants.destHeight = outDesc.Height; + constants.destWidth = Config::Instance()->CurrentFeature->DisplayWidth(); // static_cast(outDesc.Width); + constants.destHeight = Config::Instance()->CurrentFeature->DisplayHeight(); // outDesc.Height; // Copy the updated constant buffer data to the constant buffer resource UINT8* pCBDataBegin;