diff --git a/OptiScaler/framegen/IFGFeature_Dx12.cpp b/OptiScaler/framegen/IFGFeature_Dx12.cpp index 239a2b51..8ce9b528 100644 --- a/OptiScaler/framegen/IFGFeature_Dx12.cpp +++ b/OptiScaler/framegen/IFGFeature_Dx12.cpp @@ -162,7 +162,8 @@ void IFGFeature_Dx12::FlipResource(Dx12Resource* resource) if (flip->get()->IsInit()) { - auto result = flip->get()->Dispatch(_device, (ID3D12GraphicsCommandList*) resource->cmdList, resource->resource, + auto cmdList = (resource->cmdList != nullptr) ? resource->cmdList : GetUICommandList(fIndex); + auto result = flip->get()->Dispatch(_device, (ID3D12GraphicsCommandList*) cmdList, resource->resource, flipOutput, resource->width, resource->height, true); if (result) diff --git a/OptiScaler/framegen/xefg/XeFG_Dx12.cpp b/OptiScaler/framegen/xefg/XeFG_Dx12.cpp index e71d570e..d1d870f9 100644 --- a/OptiScaler/framegen/xefg/XeFG_Dx12.cpp +++ b/OptiScaler/framegen/xefg/XeFG_Dx12.cpp @@ -244,9 +244,9 @@ bool XeFG_Dx12::CreateSwapchain(IDXGIFactory* factory, ID3D12CommandQueue* cmdQu params.initFlags = XEFG_SWAPCHAIN_INIT_FLAG_NONE; - if (State::Instance().activeFgInput != FGInput::Upscaler && - Config::Instance()->FGXeFGDepthInverted.value_or_default()) - params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_INVERTED_DEPTH; + // if (State::Instance().activeFgInput != FGInput::Upscaler && + // Config::Instance()->FGXeFGDepthInverted.value_or_default()) + // params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_INVERTED_DEPTH; if (Config::Instance()->FGXeFGJitteredMV.value_or_default()) params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_JITTERED_MV; @@ -336,9 +336,9 @@ bool XeFG_Dx12::CreateSwapchain1(IDXGIFactory* factory, ID3D12CommandQueue* cmdQ params.initFlags = XEFG_SWAPCHAIN_INIT_FLAG_NONE; - if (State::Instance().activeFgInput != FGInput::Upscaler && - Config::Instance()->FGXeFGDepthInverted.value_or_default()) - params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_INVERTED_DEPTH; + // if (State::Instance().activeFgInput != FGInput::Upscaler && + // Config::Instance()->FGXeFGDepthInverted.value_or_default()) + // params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_INVERTED_DEPTH; if (Config::Instance()->FGXeFGJitteredMV.value_or_default()) params.initFlags |= XEFG_SWAPCHAIN_INIT_FLAG_JITTERED_MV; @@ -869,6 +869,32 @@ void XeFG_Dx12::SetResource(Dx12Resource* inputResource) FlipResource(fResource); } + if (type == FG_ResourceType::Depth && !Config::Instance()->FGXeFGDepthInverted.value_or_default()) + { + if (_depthInvert.get() == nullptr) + { + _depthInvert = std::make_unique("DepthInvert", _device); + } + else if (_depthInvert->IsInit()) + { + if (_depthInvert->CreateBufferResource(_device, fResource->GetResource(), fResource->width, + fResource->height, fResource->state) && + _depthInvert->Buffer() != nullptr) + { + auto cmdList = (fResource->cmdList != nullptr) ? fResource->cmdList : GetUICommandList(fIndex); + + _depthInvert->SetBufferState(cmdList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + + if (_depthInvert->Dispatch(_device, cmdList, fResource->GetResource(), _depthInvert->Buffer())) + { + fResource->copy = _depthInvert->Buffer(); + } + + _depthInvert->SetBufferState(cmdList, fResource->state); + } + } + } + // We usually don't copy any resources for XeFG, the ones with this tag are the exception if (inputResource->cmdList != nullptr && fResource->validity == FG_ResourceValidity::ValidButMakeCopy) { diff --git a/OptiScaler/framegen/xefg/XeFG_Dx12.h b/OptiScaler/framegen/xefg/XeFG_Dx12.h index dd7e8958..ce57fbbd 100644 --- a/OptiScaler/framegen/xefg/XeFG_Dx12.h +++ b/OptiScaler/framegen/xefg/XeFG_Dx12.h @@ -5,6 +5,8 @@ #include #include +#include "shaders/depth_invert/DI_Dx12.h" + #include #include #include @@ -22,6 +24,8 @@ class XeFG_Dx12 : public virtual IFGFeature_Dx12 bool _infiniteDepth = false; UINT64 _reEnableTargetFrame = 0; + std::unique_ptr _depthInvert; + static void xefgLogCallback(const char* message, xefg_swapchain_logging_level_t level, void* userData); bool CreateSwapchainContext(ID3D12Device* device); diff --git a/OptiScaler/inputs/FG/Upscaler_Inputs_Dx12.cpp b/OptiScaler/inputs/FG/Upscaler_Inputs_Dx12.cpp index 1eebd8f4..03c6bcc2 100644 --- a/OptiScaler/inputs/FG/Upscaler_Inputs_Dx12.cpp +++ b/OptiScaler/inputs/FG/Upscaler_Inputs_Dx12.cpp @@ -4,10 +4,8 @@ #include #include "shaders/depth_scale/DS_Dx12.h" -#include "shaders/depth_invert/DI_Dx12.h" static DS_Dx12* DepthScale = nullptr; -static DI_Dx12* DepthInvert = nullptr; void UpscalerInputsDx12::Init(ID3D12Device* device) { @@ -214,36 +212,6 @@ void UpscalerInputsDx12::UpscaleStart(ID3D12GraphicsCommandList* InCmdList, NVSD } } } - else if (State::Instance().activeFgOutput == FGOutput::XeFG && - !Config::Instance()->FGXeFGDepthInverted.value_or_default()) - { - if (DepthInvert == nullptr) - DepthInvert = new DI_Dx12("Depth Invert", _device); - - if (DepthInvert->CreateBufferResource(_device, paramDepth, feature->DisplayWidth(), - feature->DisplayHeight(), - D3D12_RESOURCE_STATE_UNORDERED_ACCESS) && - DepthInvert->Buffer() != nullptr) - { - DepthInvert->SetBufferState(InCmdList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - if (DepthInvert->Dispatch(_device, InCmdList, paramDepth, DepthInvert->Buffer())) - { - Dx12Resource setResource {}; - setResource.type = FG_ResourceType::Depth; - setResource.cmdList = commandList; - setResource.resource = DepthInvert->Buffer(); - setResource.width = feature->RenderWidth(); - setResource.height = feature->RenderHeight(); - setResource.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; - setResource.validity = FG_ResourceValidity::JustTrackCmdlist; - - fg->SetResource(&setResource); - - done = true; - } - } - } if (!done) {