mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-08-25 15:46:45 +00:00
implemented ss
This commit is contained in:
@@ -33,6 +33,8 @@ bool FSR2FeatureDx11on12::Init(ID3D11Device* InDevice, ID3D11DeviceContext* InCo
|
||||
|
||||
if (Imgui == nullptr || Imgui.get() == nullptr)
|
||||
Imgui = std::make_unique<Imgui_Dx11>(GetForegroundWindow(), Device);
|
||||
|
||||
OUT_DS = std::make_unique<DS_Dx12>("Output Downsample", Dx12on11Device);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -73,6 +75,10 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N
|
||||
|
||||
GetRenderResolution(InParameters, ¶ms.renderSize.width, ¶ms.renderSize.height);
|
||||
|
||||
bool useSS = Config::Instance()->SuperSamplingEnabled.value_or(false) &&
|
||||
!Config::Instance()->DisplayResolution.value_or(false) &&
|
||||
((float)DisplayWidth() / (float)params.renderSize.width) < Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
|
||||
spdlog::debug("FSR2FeatureDx11on12::Evaluate Input Resolution: {0}x{1}", params.renderSize.width, params.renderSize.height);
|
||||
|
||||
params.commandList = ffxGetCommandListDX12(Dx12CommandList);
|
||||
@@ -85,11 +91,25 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N
|
||||
|
||||
params.color = ffxGetResourceDX12(&_context, dx11Color.Dx12Resource, (wchar_t*)L"FSR2_Color", FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
params.motionVectors = ffxGetResourceDX12(&_context, dx11Mv.Dx12Resource, (wchar_t*)L"FSR2_Motion", FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
params.output = ffxGetResourceDX12(&_context, dx11Out.Dx12Resource, (wchar_t*)L"FSR2_Out", FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
params.depth = ffxGetResourceDX12(&_context, dx11Depth.Dx12Resource, (wchar_t*)L"FSR2_Depth", FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
params.exposure = ffxGetResourceDX12(&_context, dx11Exp.Dx12Resource, (wchar_t*)L"FSR2_Exp", FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
params.reactive = ffxGetResourceDX12(&_context, dx11Tm.Dx12Resource, (wchar_t*)L"FSR2_Reactive", FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
|
||||
if (useSS)
|
||||
{
|
||||
OUT_DS->Scale = (float)TargetWidth() / (float)DisplayWidth();
|
||||
|
||||
if (OUT_DS->CreateBufferResource(Dx12on11Device, dx11Out.Dx12Resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS))
|
||||
{
|
||||
OUT_DS->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
params.output = ffxGetResourceDX12(&_context, OUT_DS->Buffer(), (wchar_t*)L"FSR2_Out", FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
params.output = ffxGetResourceDX12(&_context, dx11Out.Dx12Resource, (wchar_t*)L"FSR2_Out", FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
params.output = ffxGetResourceDX12(&_context, dx11Out.Dx12Resource, (wchar_t*)L"FSR2_Out", FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
|
||||
_hasColor = params.color.resource != nullptr;
|
||||
_hasDepth = params.depth.resource != nullptr;
|
||||
_hasMV = params.motionVectors.resource != nullptr;
|
||||
@@ -172,15 +192,35 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N
|
||||
return false;
|
||||
}
|
||||
|
||||
// Execute dx12 commands to process fsr
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
if (useSS)
|
||||
{
|
||||
spdlog::debug("XeSSFeatureDx11::Evaluate downscaling output...");
|
||||
OUT_DS->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
if (!OUT_DS->Dispatch(Dx12on11Device, Dx12CommandList, OUT_DS->Buffer(), dx11Out.Dx12Resource, 16, 16))
|
||||
{
|
||||
Config::Instance()->SuperSamplingEnabled = false;
|
||||
Config::Instance()->changeBackend = true;
|
||||
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// fsr done
|
||||
if (!CopyBackOutput())
|
||||
{
|
||||
spdlog::error("FSR2FeatureDx11on12::Evaluate Can't copy output texture back!");
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -203,11 +243,16 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N
|
||||
}
|
||||
}
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
// Execute dx12 commands to process fsr
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
_frameCount++;
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -242,10 +287,6 @@ bool FSR2FeatureDx11on12::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
}
|
||||
|
||||
_contextDesc.device = ffxGetDeviceDX12(Dx12on11Device);
|
||||
_contextDesc.maxRenderSize.width = DisplayWidth();
|
||||
_contextDesc.maxRenderSize.height = DisplayHeight();
|
||||
_contextDesc.displaySize.width = DisplayWidth();
|
||||
_contextDesc.displaySize.height = DisplayHeight();
|
||||
|
||||
_contextDesc.flags = 0;
|
||||
|
||||
@@ -316,6 +357,22 @@ bool FSR2FeatureDx11on12::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
spdlog::info("FSR2FeatureDx11on12::InitFSR2 xessParams.initFlags (LowResMV) {0:b}", _contextDesc.flags);
|
||||
}
|
||||
|
||||
if (Config::Instance()->SuperSamplingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false))
|
||||
{
|
||||
_targetWidth = RenderWidth() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
_targetHeight = RenderHeight() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetWidth = DisplayWidth();
|
||||
_targetHeight = DisplayHeight();
|
||||
}
|
||||
|
||||
_contextDesc.maxRenderSize.width = TargetWidth();
|
||||
_contextDesc.maxRenderSize.height = TargetHeight();
|
||||
_contextDesc.displaySize.width = TargetWidth();
|
||||
_contextDesc.displaySize.height = TargetHeight();
|
||||
|
||||
#if _DEBUG
|
||||
_contextDesc.flags |= FFX_FSR2_ENABLE_DEBUG_CHECKING;
|
||||
_contextDesc.fpMessage = FfxLogCallback;
|
||||
|
||||
@@ -18,6 +18,8 @@ bool FSR2FeatureDx12::Init(ID3D12Device* InDevice, const NVSDK_NGX_Parameter* In
|
||||
if (Imgui == nullptr || Imgui.get() == nullptr)
|
||||
Imgui = std::make_unique<Imgui_Dx12>(GetForegroundWindow(), Device);
|
||||
|
||||
OUT_DS = std::make_unique<DS_Dx12>("Output Downsample", InDevice);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,6 +44,10 @@ bool FSR2FeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
|
||||
GetRenderResolution(InParameters, ¶ms.renderSize.width, ¶ms.renderSize.height);
|
||||
|
||||
bool useSS = Config::Instance()->SuperSamplingEnabled.value_or(false) &&
|
||||
!Config::Instance()->DisplayResolution.value_or(false) &&
|
||||
((float)DisplayWidth() / (float)params.renderSize.width) < Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
|
||||
spdlog::debug("FSR2FeatureDx12::Evaluate Input Resolution: {0}x{1}", params.renderSize.width, params.renderSize.height);
|
||||
|
||||
params.commandList = ffxGetCommandListDX12(InCommandList);
|
||||
@@ -111,7 +117,20 @@ bool FSR2FeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
(D3D12_RESOURCE_STATES)Config::Instance()->OutputResourceBarrier.value(),
|
||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
|
||||
params.output = ffxGetResourceDX12(&_context, paramOutput, (wchar_t*)L"FSR2_Output", FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
if (useSS)
|
||||
{
|
||||
OUT_DS->Scale = (float)TargetWidth() / (float)DisplayWidth();
|
||||
|
||||
if (OUT_DS->CreateBufferResource(Device, paramOutput, D3D12_RESOURCE_STATE_UNORDERED_ACCESS))
|
||||
{
|
||||
OUT_DS->SetBufferState(InCommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
params.output = ffxGetResourceDX12(&_context, OUT_DS->Buffer(), (wchar_t*)L"FSR2_Output", FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
params.output = ffxGetResourceDX12(&_context, paramOutput, (wchar_t*)L"FSR2_Output", FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
params.output = ffxGetResourceDX12(&_context, paramOutput, (wchar_t*)L"FSR2_Output", FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -267,6 +286,19 @@ bool FSR2FeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
return false;
|
||||
}
|
||||
|
||||
if (useSS)
|
||||
{
|
||||
spdlog::debug("FSR2FeatureDx12_212::Evaluate downscaling output...");
|
||||
OUT_DS->SetBufferState(InCommandList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
if (!OUT_DS->Dispatch(Device, InCommandList, OUT_DS->Buffer(), paramOutput, 16, 16))
|
||||
{
|
||||
Config::Instance()->SuperSamplingEnabled = false;
|
||||
Config::Instance()->changeBackend = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// imgui
|
||||
if (_frameCount > 20)
|
||||
{
|
||||
@@ -352,10 +384,6 @@ bool FSR2FeatureDx12::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
}
|
||||
|
||||
_contextDesc.device = ffxGetDeviceDX12(Device);
|
||||
_contextDesc.maxRenderSize.width = DisplayWidth();
|
||||
_contextDesc.maxRenderSize.height = DisplayHeight();
|
||||
_contextDesc.displaySize.width = DisplayWidth();
|
||||
_contextDesc.displaySize.height = DisplayHeight();
|
||||
|
||||
_contextDesc.flags = 0;
|
||||
|
||||
@@ -424,7 +452,23 @@ bool FSR2FeatureDx12::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
{
|
||||
Config::Instance()->DisplayResolution = false;
|
||||
spdlog::info("FSR2FeatureDx12::InitFSR2 xessParams.initFlags (LowResMV) {0:b}", _contextDesc.flags);
|
||||
}
|
||||
}
|
||||
|
||||
if (Config::Instance()->SuperSamplingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false))
|
||||
{
|
||||
_targetWidth = RenderWidth() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
_targetHeight = RenderHeight() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetWidth = DisplayWidth();
|
||||
_targetHeight = DisplayHeight();
|
||||
}
|
||||
|
||||
_contextDesc.maxRenderSize.width = TargetWidth();
|
||||
_contextDesc.maxRenderSize.height = TargetHeight();
|
||||
_contextDesc.displaySize.width = TargetWidth();
|
||||
_contextDesc.displaySize.height = TargetHeight();
|
||||
|
||||
#if _DEBUG
|
||||
_contextDesc.flags |= FFX_FSR2_ENABLE_DEBUG_CHECKING;
|
||||
|
||||
@@ -34,6 +34,8 @@ bool FSR2FeatureDx11on12_212::Init(ID3D11Device* InDevice, ID3D11DeviceContext*
|
||||
if (Imgui == nullptr || Imgui.get() == nullptr)
|
||||
Imgui = std::make_unique<Imgui_Dx11>(GetForegroundWindow(), Device);
|
||||
|
||||
OUT_DS = std::make_unique<DS_Dx12>("Output Downsample", Dx12on11Device);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,12 +46,6 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
if (!IsInited())
|
||||
return false;
|
||||
|
||||
if (_frameCount == 1)
|
||||
{
|
||||
spdlog::trace("FSR2FeatureDx11on12_212::Evaluate sleeping before 2nd frame for 500ms");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
|
||||
ID3D11DeviceContext4* dc;
|
||||
auto result = InDeviceContext->QueryInterface(IID_PPV_ARGS(&dc));
|
||||
|
||||
@@ -77,6 +73,10 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
|
||||
GetRenderResolution(InParameters, ¶ms.renderSize.width, ¶ms.renderSize.height);
|
||||
|
||||
bool useSS = Config::Instance()->SuperSamplingEnabled.value_or(false) &&
|
||||
!Config::Instance()->DisplayResolution.value_or(false) &&
|
||||
((float)DisplayWidth() / (float)params.renderSize.width) < Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
|
||||
spdlog::debug("FSR2FeatureDx11on12_212::Evaluate Input Resolution: {0}x{1}", params.renderSize.width, params.renderSize.height);
|
||||
|
||||
params.commandList = Fsr212::ffxGetCommandListDX12_212(Dx12CommandList);
|
||||
@@ -89,11 +89,25 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
|
||||
params.color = Fsr212::ffxGetResourceDX12_212(&_context, dx11Color.Dx12Resource, (wchar_t*)L"FSR2_Color", Fsr212::FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
params.motionVectors = Fsr212::ffxGetResourceDX12_212(&_context, dx11Mv.Dx12Resource, (wchar_t*)L"FSR2_Motion", Fsr212::FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
params.output = Fsr212::ffxGetResourceDX12_212(&_context, dx11Out.Dx12Resource, (wchar_t*)L"FSR2_Out", Fsr212::FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
params.depth = Fsr212::ffxGetResourceDX12_212(&_context, dx11Depth.Dx12Resource, (wchar_t*)L"FSR2_Depth", Fsr212::FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
params.exposure = Fsr212::ffxGetResourceDX12_212(&_context, dx11Exp.Dx12Resource, (wchar_t*)L"FSR2_Exp", Fsr212::FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
params.reactive = Fsr212::ffxGetResourceDX12_212(&_context, dx11Tm.Dx12Resource, (wchar_t*)L"FSR2_Reactive", Fsr212::FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
|
||||
if (useSS)
|
||||
{
|
||||
OUT_DS->Scale = (float)TargetWidth() / (float)DisplayWidth();
|
||||
|
||||
if (OUT_DS->CreateBufferResource(Dx12on11Device, dx11Out.Dx12Resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS))
|
||||
{
|
||||
OUT_DS->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
params.output = Fsr212::ffxGetResourceDX12_212(&_context, OUT_DS->Buffer(), (wchar_t*)L"FSR2_Out", Fsr212::FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
params.output = Fsr212::ffxGetResourceDX12_212(&_context, dx11Out.Dx12Resource, (wchar_t*)L"FSR2_Out", Fsr212::FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
params.output = Fsr212::ffxGetResourceDX12_212(&_context, dx11Out.Dx12Resource, (wchar_t*)L"FSR2_Out", Fsr212::FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
|
||||
_hasColor = params.color.resource != nullptr;
|
||||
_hasDepth = params.depth.resource != nullptr;
|
||||
_hasMV = params.motionVectors.resource != nullptr;
|
||||
@@ -176,10 +190,26 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
return false;
|
||||
}
|
||||
|
||||
// Execute dx12 commands to process fsr
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
if (useSS)
|
||||
{
|
||||
spdlog::debug("XeSSFeatureDx11::Evaluate downscaling output...");
|
||||
OUT_DS->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
if (!OUT_DS->Dispatch(Dx12on11Device, Dx12CommandList, OUT_DS->Buffer(), dx11Out.Dx12Resource, 16, 16))
|
||||
{
|
||||
Config::Instance()->SuperSamplingEnabled = false;
|
||||
Config::Instance()->changeBackend = true;
|
||||
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// fsr done
|
||||
if (!CopyBackOutput())
|
||||
@@ -210,11 +240,16 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
}
|
||||
}
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
// Execute dx12 commands to process fsr
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
_frameCount++;
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -248,10 +283,6 @@ bool FSR2FeatureDx11on12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
}
|
||||
|
||||
_contextDesc.device = Fsr212::ffxGetDeviceDX12_212(Dx12on11Device);
|
||||
_contextDesc.maxRenderSize.width = DisplayWidth();
|
||||
_contextDesc.maxRenderSize.height = DisplayHeight();
|
||||
_contextDesc.displaySize.width = DisplayWidth();
|
||||
_contextDesc.displaySize.height = DisplayHeight();
|
||||
|
||||
_contextDesc.flags = 0;
|
||||
|
||||
@@ -322,6 +353,22 @@ bool FSR2FeatureDx11on12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
spdlog::info("FSR2FeatureDx11on12_212::InitFSR2 xessParams.initFlags (LowResMV) {0:b}", _contextDesc.flags);
|
||||
}
|
||||
|
||||
if (Config::Instance()->SuperSamplingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false))
|
||||
{
|
||||
_targetWidth = RenderWidth() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
_targetHeight = RenderHeight() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetWidth = DisplayWidth();
|
||||
_targetHeight = DisplayHeight();
|
||||
}
|
||||
|
||||
_contextDesc.maxRenderSize.width = TargetWidth();
|
||||
_contextDesc.maxRenderSize.height = TargetHeight();
|
||||
_contextDesc.displaySize.width = TargetWidth();
|
||||
_contextDesc.displaySize.height = TargetHeight();
|
||||
|
||||
spdlog::debug("FSR2FeatureDx11on12_212::InitFSR2 ffxFsr2ContextCreate!");
|
||||
|
||||
auto ret = Fsr212::ffxFsr2ContextCreate212(&_context, &_contextDesc);
|
||||
|
||||
@@ -18,6 +18,8 @@ bool FSR2FeatureDx12_212::Init(ID3D12Device* InDevice, const NVSDK_NGX_Parameter
|
||||
if (Imgui == nullptr || Imgui.get() == nullptr)
|
||||
Imgui = std::make_unique<Imgui_Dx12>(GetForegroundWindow(), Device);
|
||||
|
||||
OUT_DS = std::make_unique<DS_Dx12>("Output Downsample", InDevice);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,6 +46,10 @@ bool FSR2FeatureDx12_212::Evaluate(ID3D12GraphicsCommandList* InCommandList, con
|
||||
|
||||
GetRenderResolution(InParameters, ¶ms.renderSize.width, ¶ms.renderSize.height);
|
||||
|
||||
bool useSS = Config::Instance()->SuperSamplingEnabled.value_or(false) &&
|
||||
!Config::Instance()->DisplayResolution.value_or(false) &&
|
||||
((float)DisplayWidth() / (float)params.renderSize.width) < Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
|
||||
spdlog::debug("FSR2FeatureDx12_212::Evaluate Input Resolution: {0}x{1}", params.renderSize.width, params.renderSize.height);
|
||||
|
||||
params.commandList = Fsr212::ffxGetCommandListDX12_212(InCommandList);
|
||||
@@ -113,7 +119,20 @@ bool FSR2FeatureDx12_212::Evaluate(ID3D12GraphicsCommandList* InCommandList, con
|
||||
(D3D12_RESOURCE_STATES)Config::Instance()->OutputResourceBarrier.value(),
|
||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
|
||||
params.output = Fsr212::ffxGetResourceDX12_212(&_context, paramOutput, (wchar_t*)L"FSR2_Output", Fsr212::FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
if (useSS)
|
||||
{
|
||||
OUT_DS->Scale = (float)TargetWidth() / (float)DisplayWidth();
|
||||
|
||||
if (OUT_DS->CreateBufferResource(Device, paramOutput, D3D12_RESOURCE_STATE_UNORDERED_ACCESS))
|
||||
{
|
||||
OUT_DS->SetBufferState(InCommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
params.output = Fsr212::ffxGetResourceDX12_212(&_context, OUT_DS->Buffer(), (wchar_t*)L"FSR2_Output", Fsr212::FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
params.output = Fsr212::ffxGetResourceDX12_212(&_context, paramOutput, (wchar_t*)L"FSR2_Output", Fsr212::FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
params.output = Fsr212::ffxGetResourceDX12_212(&_context, paramOutput, (wchar_t*)L"FSR2_Output", Fsr212::FFX_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -275,6 +294,19 @@ bool FSR2FeatureDx12_212::Evaluate(ID3D12GraphicsCommandList* InCommandList, con
|
||||
return false;
|
||||
}
|
||||
|
||||
if (useSS)
|
||||
{
|
||||
spdlog::debug("FSR2FeatureDx12_212::Evaluate downscaling output...");
|
||||
OUT_DS->SetBufferState(InCommandList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
if (!OUT_DS->Dispatch(Device, InCommandList, OUT_DS->Buffer(), paramOutput, 16, 16))
|
||||
{
|
||||
Config::Instance()->SuperSamplingEnabled = false;
|
||||
Config::Instance()->changeBackend = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// imgui
|
||||
if (_frameCount > 20)
|
||||
{
|
||||
@@ -360,10 +392,6 @@ bool FSR2FeatureDx12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
}
|
||||
|
||||
_contextDesc.device = Fsr212::ffxGetDeviceDX12_212(Device);
|
||||
_contextDesc.maxRenderSize.width = DisplayWidth();
|
||||
_contextDesc.maxRenderSize.height = DisplayHeight();
|
||||
_contextDesc.displaySize.width = DisplayWidth();
|
||||
_contextDesc.displaySize.height = DisplayHeight();
|
||||
|
||||
_contextDesc.flags = 0;
|
||||
|
||||
@@ -434,6 +462,22 @@ bool FSR2FeatureDx12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
spdlog::info("FSR2FeatureDx12_212::InitFSR2 xessParams.initFlags (LowResMV) {0:b}", _contextDesc.flags);
|
||||
}
|
||||
|
||||
if (Config::Instance()->SuperSamplingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false))
|
||||
{
|
||||
_targetWidth = RenderWidth() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
_targetHeight = RenderHeight() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetWidth = DisplayWidth();
|
||||
_targetHeight = DisplayHeight();
|
||||
}
|
||||
|
||||
_contextDesc.maxRenderSize.width = TargetWidth();
|
||||
_contextDesc.maxRenderSize.height = TargetHeight();
|
||||
_contextDesc.displaySize.width = TargetWidth();
|
||||
_contextDesc.displaySize.height = TargetHeight();
|
||||
|
||||
spdlog::debug("FSR2FeatureDx12_212::InitFSR2 ffxFsr2ContextCreate!");
|
||||
|
||||
auto ret = Fsr212::ffxFsr2ContextCreate212(&_context, &_contextDesc);
|
||||
|
||||
@@ -49,52 +49,6 @@ bool XeSSFeature::InitXeSS(ID3D12Device* device, const NVSDK_NGX_Parameter* InPa
|
||||
|
||||
xess_d3d12_init_params_t xessParams{};
|
||||
|
||||
if (Config::Instance()->SuperSamplingEnabled.value_or(true))
|
||||
{
|
||||
_targetWidth = RenderWidth() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
_targetHeight = RenderHeight() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_ULTRA_PERFORMANCE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetWidth == DisplayWidth();
|
||||
_targetHeight = DisplayHeight();
|
||||
|
||||
switch (PerfQualityValue())
|
||||
{
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraPerformance:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_ULTRA_PERFORMANCE;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxPerf:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_PERFORMANCE;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_Balanced:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_BALANCED;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxQuality:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_QUALITY;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraQuality:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_ULTRA_QUALITY;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_DLAA:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_AA;
|
||||
break;
|
||||
|
||||
default:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_BALANCED; //Set out-of-range value for non-existing XESS_QUALITY_SETTING_BALANCED mode
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
xessParams.outputResolution.x = TargetWidth();
|
||||
xessParams.outputResolution.y = TargetHeight();
|
||||
|
||||
xessParams.initFlags = XESS_INIT_FLAG_NONE;
|
||||
|
||||
int featureFlags;
|
||||
@@ -167,6 +121,51 @@ bool XeSSFeature::InitXeSS(ID3D12Device* device, const NVSDK_NGX_Parameter* InPa
|
||||
spdlog::info("XeSSFeature::InitXeSS xessParams.initFlags (ReactiveMaskActive) {0:b}", xessParams.initFlags);
|
||||
}
|
||||
|
||||
switch (PerfQualityValue())
|
||||
{
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraPerformance:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_ULTRA_PERFORMANCE;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxPerf:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_PERFORMANCE;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_Balanced:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_BALANCED;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxQuality:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_QUALITY;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraQuality:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_ULTRA_QUALITY;
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_DLAA:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_AA;
|
||||
break;
|
||||
|
||||
default:
|
||||
xessParams.qualitySetting = XESS_QUALITY_SETTING_BALANCED; //Set out-of-range value for non-existing XESS_QUALITY_SETTING_BALANCED mode
|
||||
break;
|
||||
}
|
||||
|
||||
if (Config::Instance()->SuperSamplingEnabled.value_or(false) && !Config::Instance()->DisplayResolution.value_or(false))
|
||||
{
|
||||
_targetWidth = RenderWidth() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
_targetHeight = RenderHeight() * Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetWidth = DisplayWidth();
|
||||
_targetHeight = DisplayHeight();
|
||||
}
|
||||
|
||||
xessParams.outputResolution.x = TargetWidth();
|
||||
xessParams.outputResolution.y = TargetHeight();
|
||||
|
||||
if (Config::Instance()->BuildPipelines.value_or(true))
|
||||
{
|
||||
spdlog::debug("XeSSFeature::InitXeSS xessD3D12BuildPipelines!");
|
||||
@@ -197,7 +196,7 @@ bool XeSSFeature::InitXeSS(ID3D12Device* device, const NVSDK_NGX_Parameter* InPa
|
||||
}
|
||||
|
||||
CAS = std::make_unique<CAS_Dx12>(device, TargetWidth(), TargetHeight(), Config::Instance()->CasColorSpaceConversion.value_or(0));
|
||||
|
||||
|
||||
SetInit(true);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -125,6 +125,10 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK
|
||||
|
||||
auto sharpness = GetSharpness(InParameters);
|
||||
|
||||
bool useSS = Config::Instance()->SuperSamplingEnabled.value_or(false) &&
|
||||
!Config::Instance()->DisplayResolution.value_or(false) &&
|
||||
((float)DisplayWidth() / (float)params.inputWidth) < Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
|
||||
spdlog::debug("XeSSFeatureDx11::Evaluate Input Resolution: {0}x{1}", params.inputWidth, params.inputHeight);
|
||||
|
||||
if (!ProcessDx11Textures(InParameters))
|
||||
@@ -149,22 +153,25 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK
|
||||
params.pVelocityTexture = dx11Mv.Dx12Resource;
|
||||
_hasMV = params.pVelocityTexture != nullptr;
|
||||
|
||||
if (!Config::Instance()->changeCAS && Config::Instance()->CasEnabled.value_or(true) && sharpness > 0.0f)
|
||||
if (useSS)
|
||||
{
|
||||
if (!CAS->CreateBufferResource(Dx12on11Device, dx11Out.Dx12Resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS))
|
||||
OUT_DS->Scale = (float)TargetWidth() / (float)DisplayWidth();
|
||||
|
||||
if (OUT_DS->CreateBufferResource(Dx12on11Device, dx11Out.Dx12Resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS))
|
||||
{
|
||||
spdlog::error("XeSSFeatureDx11::Evaluate Can't create cas buffer!");
|
||||
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
|
||||
return false;
|
||||
OUT_DS->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
params.pOutputTexture = OUT_DS->Buffer();
|
||||
}
|
||||
else
|
||||
params.pOutputTexture = dx11Out.Dx12Resource;
|
||||
}
|
||||
else
|
||||
params.pOutputTexture = dx11Out.Dx12Resource;
|
||||
|
||||
if (!Config::Instance()->changeCAS && Config::Instance()->CasEnabled.value_or(true) && sharpness > 0.0f &&
|
||||
CAS->CreateBufferResource(Dx12on11Device, params.pOutputTexture, D3D12_RESOURCE_STATE_UNORDERED_ACCESS))
|
||||
{
|
||||
CAS->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
params.pOutputTexture = CAS->Buffer();
|
||||
}
|
||||
else
|
||||
@@ -224,9 +231,49 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK
|
||||
ResourceBarrier(Dx12CommandList, params.pOutputTexture, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
CAS->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
if (!CAS->Dispatch(Dx12CommandList, sharpness, CAS->Buffer(), dx11Out.Dx12Resource))
|
||||
if (useSS)
|
||||
{
|
||||
Config::Instance()->CasEnabled = false;
|
||||
if (!CAS->Dispatch(Dx12CommandList, sharpness, params.pOutputTexture, OUT_DS->Buffer()))
|
||||
{
|
||||
Config::Instance()->CasEnabled = false;
|
||||
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CAS->Dispatch(Dx12CommandList, sharpness, params.pOutputTexture, dx11Out.Dx12Resource))
|
||||
{
|
||||
Config::Instance()->CasEnabled = false;
|
||||
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
Dx12CommandAllocator->Reset();
|
||||
Dx12CommandList->Reset(Dx12CommandAllocator, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useSS)
|
||||
{
|
||||
spdlog::debug("XeSSFeatureDx11::Evaluate downscaling output...");
|
||||
OUT_DS->SetBufferState(Dx12CommandList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
if (!OUT_DS->Dispatch(Dx12on11Device, Dx12CommandList, OUT_DS->Buffer(), dx11Out.Dx12Resource, 16, 16))
|
||||
{
|
||||
Config::Instance()->SuperSamplingEnabled = false;
|
||||
Config::Instance()->changeBackend = true;
|
||||
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
|
||||
@@ -19,7 +19,6 @@ bool XeSSFeatureDx12::Init(ID3D12Device* InDevice, const NVSDK_NGX_Parameter* In
|
||||
Imgui = std::make_unique<Imgui_Dx12>(GetForegroundWindow(), Device);
|
||||
|
||||
OUT_DS = std::make_unique<DS_Dx12>("Output Downsample", InDevice);
|
||||
MV_US = std::make_unique<DS_Dx12>("MV Upsample", InDevice);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -68,7 +67,6 @@ bool XeSSFeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
CAS = std::make_unique<CAS_Dx12>(Device, DisplayWidth(), DisplayHeight(), Config::Instance()->CasColorSpaceConversion.value_or(0));
|
||||
}
|
||||
}
|
||||
|
||||
xess_result_t xessResult;
|
||||
xess_d3d12_execute_params_t params{};
|
||||
|
||||
@@ -84,6 +82,10 @@ bool XeSSFeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
|
||||
auto sharpness = GetSharpness(InParameters);
|
||||
|
||||
bool useSS = Config::Instance()->SuperSamplingEnabled.value_or(false) &&
|
||||
!Config::Instance()->DisplayResolution.value_or(false) &&
|
||||
((float)DisplayWidth() / (float)params.inputWidth) < Config::Instance()->SuperSamplingMultiplier.value_or(3.0f);
|
||||
|
||||
spdlog::debug("XeSSFeatureDx12::Evaluate Input Resolution: {0}x{1}", params.inputWidth, params.inputHeight);
|
||||
|
||||
ID3D12Resource* paramColor;
|
||||
@@ -138,19 +140,6 @@ bool XeSSFeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
|
||||
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
}
|
||||
|
||||
if (Config::Instance()->DisplayResolution.value_or(false) && Config::Instance()->SuperSamplingEnabled.value_or(true))
|
||||
{
|
||||
spdlog::debug("XeSSFeatureDx12::Evaluate upscaling MotionVectors...");
|
||||
|
||||
MV_US->Scale = (float)TargetWidth() / (float)DisplayWidth();
|
||||
|
||||
if (MV_US->CreateBufferResource(Device, params.pVelocityTexture, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE) &&
|
||||
MV_US->Dispatch(Device, InCommandList, params.pVelocityTexture, MV_US->Buffer(), 8, 8))
|
||||
{
|
||||
params.pVelocityTexture = MV_US->Buffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -173,7 +162,7 @@ bool XeSSFeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
ResourceBarrier(InCommandList, paramOutput, (D3D12_RESOURCE_STATES)Config::Instance()->OutputResourceBarrier.value(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
}
|
||||
|
||||
if (Config::Instance()->SuperSamplingEnabled.value_or(true))
|
||||
if (useSS)
|
||||
{
|
||||
OUT_DS->Scale = (float)TargetWidth() / (float)DisplayWidth();
|
||||
|
||||
@@ -304,7 +293,7 @@ bool XeSSFeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
|
||||
CAS->SetBufferState(InCommandList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
if (Config::Instance()->SuperSamplingEnabled.value_or(true))
|
||||
if (useSS)
|
||||
{
|
||||
if (!CAS->Dispatch(InCommandList, sharpness, params.pOutputTexture, OUT_DS->Buffer()))
|
||||
{
|
||||
@@ -322,12 +311,12 @@ bool XeSSFeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
}
|
||||
}
|
||||
|
||||
if (Config::Instance()->SuperSamplingEnabled.value_or(true))
|
||||
if (useSS)
|
||||
{
|
||||
spdlog::debug("XeSSFeatureDx12::Evaluate downscaling output...");
|
||||
OUT_DS->SetBufferState(InCommandList, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||
|
||||
if (!OUT_DS->Dispatch(Device, InCommandList, OUT_DS->Buffer(), paramOutput, 8, 8))
|
||||
if (!OUT_DS->Dispatch(Device, InCommandList, OUT_DS->Buffer(), paramOutput, 16, 16))
|
||||
{
|
||||
Config::Instance()->SuperSamplingEnabled = false;
|
||||
Config::Instance()->changeBackend = true;
|
||||
|
||||
Reference in New Issue
Block a user