mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-05-29 21:13:14 +00:00
improvements to dx11 w dx12. still shaky on arc
This commit is contained in:
@@ -82,7 +82,7 @@
|
||||
<IncludePath>$(SolutionDir)external\vulkan\include;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\simpleini;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\spdlog\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)CyberXess\cas\lib;$(SolutionDir)CyberXess\fsr2\lib;$(SolutionDir)CyberXess\fsr2_212\lib;$(SolutionDir)CyberXess\vulkan;$(SolutionDir)external\xess\lib;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>nvngx</TargetName>
|
||||
<OutDir>D:\code\CyberFSR-XeSS\DLSS_Sample_App\out\build\x64-Debug\ngx_dlss_demo</OutDir>
|
||||
<OutDir>E:\Games\God of War\</OutDir>
|
||||
<IntDir>.\x64\Debug</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
||||
@@ -214,6 +214,10 @@ bool FSR2FeatureDx11::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
return true;
|
||||
}
|
||||
|
||||
FSR2FeatureDx11::FSR2FeatureDx11(unsigned int InHandleId, const NVSDK_NGX_Parameter* InParameters) : FSR2Feature(InHandleId, InParameters), IFeature_Dx11(InHandleId, InParameters), IFeature(InHandleId, InParameters)
|
||||
{
|
||||
}
|
||||
|
||||
bool FSR2FeatureDx11::Evaluate(ID3D11DeviceContext* InContext, const NVSDK_NGX_Parameter* InParameters)
|
||||
{
|
||||
spdlog::debug("FSR2FeatureDx11::Evaluate");
|
||||
@@ -422,26 +426,38 @@ FSR2FeatureDx11::~FSR2FeatureDx11()
|
||||
{
|
||||
spdlog::debug("FSR2FeatureDx11::~FSR2FeatureDx11");
|
||||
|
||||
D3D11_QUERY_DESC pQueryDesc{};
|
||||
pQueryDesc.Query = D3D11_QUERY_EVENT;
|
||||
pQueryDesc.MiscFlags = 0;
|
||||
ID3D11Query* query = nullptr;
|
||||
auto result = Device->CreateQuery(&pQueryDesc, &query);
|
||||
|
||||
if (DeviceContext != nullptr && result != S_OK)
|
||||
if (Device)
|
||||
{
|
||||
DeviceContext->Begin(query);
|
||||
DeviceContext->End(query);
|
||||
DeviceContext->Flush();
|
||||
D3D11_QUERY_DESC pQueryDesc;
|
||||
pQueryDesc.Query = D3D11_QUERY_EVENT;
|
||||
pQueryDesc.MiscFlags = 0;
|
||||
|
||||
while (DeviceContext->GetData(query, nullptr, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_FALSE);
|
||||
ID3D11Query* query = nullptr;
|
||||
auto result = Device->CreateQuery(&pQueryDesc, &query);
|
||||
|
||||
query->Release();
|
||||
if (result == S_OK)
|
||||
{
|
||||
// Associate the query with the copy operation
|
||||
DeviceContext->Begin(query);
|
||||
|
||||
// Execute dx11 commands
|
||||
DeviceContext->End(query);
|
||||
DeviceContext->Flush();
|
||||
|
||||
// Wait for the query to be ready
|
||||
while (DeviceContext->GetData(query, NULL, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_FALSE)
|
||||
std::this_thread::yield();
|
||||
|
||||
// Release the query
|
||||
query->Release();
|
||||
}
|
||||
}
|
||||
|
||||
ReleaseResources();
|
||||
|
||||
if (Imgui)
|
||||
Imgui.reset();
|
||||
|
||||
DeviceContext->Flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,7 @@ protected:
|
||||
bool InitFSR2(const NVSDK_NGX_Parameter* InParameters) override;
|
||||
|
||||
public:
|
||||
FSR2FeatureDx11(unsigned int InHandleId, const NVSDK_NGX_Parameter* InParameters) : FSR2Feature(InHandleId, InParameters), IFeature_Dx11(InHandleId, InParameters), IFeature(InHandleId, InParameters)
|
||||
{
|
||||
}
|
||||
FSR2FeatureDx11(unsigned int InHandleId, const NVSDK_NGX_Parameter* InParameters);
|
||||
|
||||
|
||||
// Inherited via IFeature_Dx11
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <dxgi1_6.h>
|
||||
|
||||
|
||||
#define ASSIGN_DESC(dest, src) dest.Width = src.Width; dest.Height = src.Height; dest.Format = src.Format; dest.BindFlags = src.BindFlags;
|
||||
|
||||
#define SAFE_RELEASE(p) \
|
||||
@@ -368,7 +367,7 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N
|
||||
ID3D11Query* query0 = nullptr;
|
||||
|
||||
// 3 is query sync
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
fr = Dx11Device->CreateFence(0, D3D11_FENCE_FLAG_SHARED, IID_PPV_ARGS(&dx11fence_1));
|
||||
|
||||
@@ -518,13 +517,16 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N
|
||||
#pragma endregion
|
||||
|
||||
// 3 is query sync
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 1)
|
||||
Dx11DeviceContext->Flush();
|
||||
|
||||
Dx11DeviceContext->Signal(dx11fence_1, 10);
|
||||
Dx12CommandQueue->Wait(dx12fence_1, 10);
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0)
|
||||
{
|
||||
Dx11DeviceContext->Signal(dx11fence_1, 10);
|
||||
Dx12CommandQueue->Wait(dx12fence_1, 10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -721,7 +723,7 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N
|
||||
HANDLE dx12_sharedHandle;
|
||||
|
||||
// dispatch fences
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
fr = Dx12on11Device->CreateFence(0, D3D12_FENCE_FLAG_SHARED, IID_PPV_ARGS(&dx12fence_2));
|
||||
|
||||
@@ -754,15 +756,18 @@ bool FSR2FeatureDx11on12::Evaluate(ID3D11DeviceContext* InDeviceContext, const N
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
// fsr done
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
Dx12CommandQueue->Signal(dx12fence_2, 20);
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0)
|
||||
{
|
||||
Dx12CommandQueue->Signal(dx12fence_2, 20);
|
||||
|
||||
// wait for fsr on dx12
|
||||
Dx11DeviceContext->Wait(dx11fence_2, 20);
|
||||
// wait for fsr on dx12
|
||||
Dx11DeviceContext->Wait(dx11fence_2, 20);
|
||||
}
|
||||
|
||||
// copy back output
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 1)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 2)
|
||||
{
|
||||
ID3D11Query* query1 = nullptr;
|
||||
result = Dx11Device->CreateQuery(&pQueryDesc, &query1);
|
||||
@@ -869,15 +874,50 @@ FSR2FeatureDx11on12::~FSR2FeatureDx11on12()
|
||||
{
|
||||
spdlog::debug("FSR2FeatureDx11on12::~FSR2FeatureDx11on12");
|
||||
|
||||
if (Dx11Device)
|
||||
{
|
||||
D3D11_QUERY_DESC pQueryDesc;
|
||||
pQueryDesc.Query = D3D11_QUERY_EVENT;
|
||||
pQueryDesc.MiscFlags = 0;
|
||||
|
||||
ID3D11Query* query = nullptr;
|
||||
auto result = Dx11Device->CreateQuery(&pQueryDesc, &query);
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
// Associate the query with the copy operation
|
||||
DeviceContext->Begin(query);
|
||||
|
||||
//copy output back
|
||||
|
||||
// Execute dx11 commands
|
||||
DeviceContext->End(query);
|
||||
DeviceContext->Flush();
|
||||
|
||||
// Wait for the query to be ready
|
||||
while (DeviceContext->GetData(query, NULL, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_FALSE)
|
||||
std::this_thread::yield();
|
||||
|
||||
// Release the query
|
||||
query->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (Dx12on11Device && Dx12CommandQueue && Dx12CommandList)
|
||||
{
|
||||
auto errorCode = ffxFsr2ContextDestroy(&_context);
|
||||
|
||||
if (errorCode != FFX_OK)
|
||||
spdlog::error("FSR2Feature::~FSR2Feature ffxFsr2ContextDestroy error: {0:x}", errorCode);
|
||||
|
||||
free(_contextDesc.callbacks.scratchBuffer);
|
||||
|
||||
ID3D12Fence* d3d12Fence;
|
||||
Dx12on11Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&d3d12Fence));
|
||||
Dx12CommandQueue->Signal(d3d12Fence, 999);
|
||||
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
Dx12CommandQueue->Signal(d3d12Fence, 999);
|
||||
|
||||
auto fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
|
||||
@@ -901,6 +941,9 @@ FSR2FeatureDx11on12::~FSR2FeatureDx11on12()
|
||||
|
||||
if (Imgui)
|
||||
Imgui.reset();
|
||||
|
||||
DeviceContext->Flush();
|
||||
SetInit(false);
|
||||
}
|
||||
|
||||
bool FSR2FeatureDx11on12::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
|
||||
@@ -108,17 +108,17 @@ void FSR2FeatureDx11on12_212::ReleaseSharedResources()
|
||||
spdlog::debug("FSR2FeatureDx11on12::ReleaseSharedResources start!");
|
||||
|
||||
SAFE_RELEASE(dx11Color.SharedTexture)
|
||||
SAFE_RELEASE(dx11Mv.SharedTexture)
|
||||
SAFE_RELEASE(dx11Out.SharedTexture)
|
||||
SAFE_RELEASE(dx11Depth.SharedTexture)
|
||||
SAFE_RELEASE(dx11Tm.SharedTexture)
|
||||
SAFE_RELEASE(dx11Exp.SharedTexture)
|
||||
SAFE_RELEASE(dx11Color.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Mv.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Out.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Depth.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Tm.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Exp.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Mv.SharedTexture)
|
||||
SAFE_RELEASE(dx11Out.SharedTexture)
|
||||
SAFE_RELEASE(dx11Depth.SharedTexture)
|
||||
SAFE_RELEASE(dx11Tm.SharedTexture)
|
||||
SAFE_RELEASE(dx11Exp.SharedTexture)
|
||||
SAFE_RELEASE(dx11Color.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Mv.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Out.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Depth.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Tm.Dx12Resource)
|
||||
SAFE_RELEASE(dx11Exp.Dx12Resource)
|
||||
}
|
||||
|
||||
void FSR2FeatureDx11on12_212::GetHardwareAdapter(IDXGIFactory1* InFactory, IDXGIAdapter** InAdapter, D3D_FEATURE_LEVEL InFeatureLevel, bool InRequestHighPerformanceAdapter)
|
||||
@@ -367,7 +367,7 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
ID3D11Query* query0 = nullptr;
|
||||
|
||||
// 3 is query sync
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
fr = Dx11Device->CreateFence(0, D3D11_FENCE_FLAG_SHARED, IID_PPV_ARGS(&dx11fence_1));
|
||||
|
||||
@@ -415,7 +415,6 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
DeviceContext->Begin(query0);
|
||||
}
|
||||
|
||||
|
||||
#pragma region Texture copies
|
||||
|
||||
|
||||
@@ -517,13 +516,16 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
#pragma endregion
|
||||
|
||||
// 3 is query sync
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 1)
|
||||
Dx11DeviceContext->Flush();
|
||||
|
||||
Dx11DeviceContext->Signal(dx11fence_1, 10);
|
||||
Dx12CommandQueue->Wait(dx12fence_1, 10);
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0)
|
||||
{
|
||||
Dx11DeviceContext->Signal(dx11fence_1, 10);
|
||||
Dx12CommandQueue->Wait(dx12fence_1, 10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -720,7 +722,7 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
HANDLE dx12_sharedHandle;
|
||||
|
||||
// dispatch fences
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
fr = Dx12on11Device->CreateFence(0, D3D12_FENCE_FLAG_SHARED, IID_PPV_ARGS(&dx12fence_2));
|
||||
|
||||
@@ -753,15 +755,18 @@ bool FSR2FeatureDx11on12_212::Evaluate(ID3D11DeviceContext* InDeviceContext, con
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
// fsr done
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
Dx12CommandQueue->Signal(dx12fence_2, 20);
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0)
|
||||
{
|
||||
Dx12CommandQueue->Signal(dx12fence_2, 20);
|
||||
|
||||
// wait for fsr on dx12
|
||||
Dx11DeviceContext->Wait(dx11fence_2, 20);
|
||||
// wait for fsr on dx12
|
||||
Dx11DeviceContext->Wait(dx11fence_2, 20);
|
||||
}
|
||||
|
||||
// copy back output
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 1)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 2)
|
||||
{
|
||||
ID3D11Query* query1 = nullptr;
|
||||
result = Dx11Device->CreateQuery(&pQueryDesc, &query1);
|
||||
@@ -868,15 +873,50 @@ FSR2FeatureDx11on12_212::~FSR2FeatureDx11on12_212()
|
||||
{
|
||||
spdlog::debug("FSR2FeatureDx11on12::~FSR2FeatureDx11on12");
|
||||
|
||||
if (Dx11Device)
|
||||
{
|
||||
D3D11_QUERY_DESC pQueryDesc;
|
||||
pQueryDesc.Query = D3D11_QUERY_EVENT;
|
||||
pQueryDesc.MiscFlags = 0;
|
||||
|
||||
ID3D11Query* query = nullptr;
|
||||
auto result = Dx11Device->CreateQuery(&pQueryDesc, &query);
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
// Associate the query with the copy operation
|
||||
DeviceContext->Begin(query);
|
||||
|
||||
//copy output back
|
||||
|
||||
// Execute dx11 commands
|
||||
DeviceContext->End(query);
|
||||
DeviceContext->Flush();
|
||||
|
||||
// Wait for the query to be ready
|
||||
while (DeviceContext->GetData(query, NULL, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_FALSE)
|
||||
std::this_thread::yield();
|
||||
|
||||
// Release the query
|
||||
query->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (Dx12on11Device && Dx12CommandQueue && Dx12CommandList)
|
||||
{
|
||||
auto errorCode = Fsr212::ffxFsr2ContextDestroy212(&_context);
|
||||
|
||||
if (errorCode != Fsr212::FFX_OK)
|
||||
spdlog::error("FSR2Feature::~FSR2Feature ffxFsr2ContextDestroy error: {0:x}", errorCode);
|
||||
|
||||
free(_contextDesc.callbacks.scratchBuffer);
|
||||
|
||||
ID3D12Fence* d3d12Fence;
|
||||
Dx12on11Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&d3d12Fence));
|
||||
Dx12CommandQueue->Signal(d3d12Fence, 999);
|
||||
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
Dx12CommandQueue->Signal(d3d12Fence, 999);
|
||||
|
||||
auto fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
|
||||
@@ -900,6 +940,9 @@ FSR2FeatureDx11on12_212::~FSR2FeatureDx11on12_212()
|
||||
|
||||
if (Imgui)
|
||||
Imgui.reset();
|
||||
|
||||
DeviceContext->Flush();
|
||||
SetInit(false);
|
||||
}
|
||||
|
||||
bool FSR2FeatureDx11on12_212::InitFSR2(const NVSDK_NGX_Parameter* InParameters)
|
||||
|
||||
@@ -259,6 +259,10 @@ HRESULT XeSSFeatureDx11::CreateDx12Device(D3D_FEATURE_LEVEL InFeatureLevel)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
XeSSFeatureDx11::XeSSFeatureDx11(unsigned int InHandleId, const NVSDK_NGX_Parameter* InParameters) : XeSSFeature(InHandleId, InParameters), IFeature_Dx11(InHandleId, InParameters), IFeature(InHandleId, InParameters)
|
||||
{
|
||||
}
|
||||
|
||||
bool XeSSFeatureDx11::Init(ID3D11Device* InDevice, ID3D11DeviceContext* InContext, const NVSDK_NGX_Parameter* InParameters)
|
||||
{
|
||||
spdlog::debug("XeSSFeatureDx11::Init!");
|
||||
@@ -368,7 +372,7 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK
|
||||
ID3D11Query* query0 = nullptr;
|
||||
|
||||
// 3 is query sync
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
fr = Dx11Device->CreateFence(0, D3D11_FENCE_FLAG_SHARED, IID_PPV_ARGS(&dx11fence_1));
|
||||
|
||||
@@ -416,7 +420,6 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK
|
||||
DeviceContext->Begin(query0);
|
||||
}
|
||||
|
||||
|
||||
#pragma region Texture copies
|
||||
|
||||
ID3D11Resource* paramColor;
|
||||
@@ -518,13 +521,16 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK
|
||||
#pragma endregion
|
||||
|
||||
// 3 is query sync
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 1)
|
||||
Dx11DeviceContext->Flush();
|
||||
|
||||
Dx11DeviceContext->Signal(dx11fence_1, 10);
|
||||
Dx12CommandQueue->Wait(dx12fence_1, 10);
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0)
|
||||
{
|
||||
Dx11DeviceContext->Signal(dx11fence_1, 10);
|
||||
Dx12CommandQueue->Wait(dx12fence_1, 10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -697,7 +703,7 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK
|
||||
HANDLE dx12_sharedHandle;
|
||||
|
||||
// dispatch fences
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
fr = Dx12on11Device->CreateFence(0, D3D12_FENCE_FLAG_SHARED, IID_PPV_ARGS(&dx12fence_2));
|
||||
|
||||
@@ -730,15 +736,18 @@ bool XeSSFeatureDx11::Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
|
||||
// xess done
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 3)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) < 4)
|
||||
{
|
||||
Dx12CommandQueue->Signal(dx12fence_2, 20);
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 0)
|
||||
{
|
||||
Dx12CommandQueue->Signal(dx12fence_2, 20);
|
||||
|
||||
// wait for fsr on dx12
|
||||
Dx11DeviceContext->Wait(dx11fence_2, 20);
|
||||
// wait for fsr on dx12
|
||||
Dx11DeviceContext->Wait(dx11fence_2, 20);
|
||||
}
|
||||
|
||||
// copy back output
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 1)
|
||||
if (Config::Instance()->UseSafeSyncQueries.value_or(0) > 2)
|
||||
{
|
||||
ID3D11Query* query1 = nullptr;
|
||||
result = Dx11Device->CreateQuery(&pQueryDesc, &query1);
|
||||
@@ -845,15 +854,43 @@ XeSSFeatureDx11::~XeSSFeatureDx11()
|
||||
{
|
||||
spdlog::debug("XeSSFeatureDx11::XeSSFeatureDx11");
|
||||
|
||||
if (Dx11Device)
|
||||
{
|
||||
D3D11_QUERY_DESC pQueryDesc;
|
||||
pQueryDesc.Query = D3D11_QUERY_EVENT;
|
||||
pQueryDesc.MiscFlags = 0;
|
||||
|
||||
ID3D11Query* query = nullptr;
|
||||
auto result = Dx11Device->CreateQuery(&pQueryDesc, &query);
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
// Associate the query with the copy operation
|
||||
DeviceContext->Begin(query);
|
||||
|
||||
//copy output back
|
||||
|
||||
// Execute dx11 commands
|
||||
DeviceContext->End(query);
|
||||
DeviceContext->Flush();
|
||||
|
||||
// Wait for the query to be ready
|
||||
while (DeviceContext->GetData(query, NULL, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_FALSE)
|
||||
std::this_thread::yield();
|
||||
|
||||
// Release the query
|
||||
query->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (Dx12on11Device && Dx12CommandQueue && Dx12CommandList)
|
||||
{
|
||||
ID3D12Fence* d3d12Fence;
|
||||
Dx12on11Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&d3d12Fence));
|
||||
Dx12CommandQueue->Signal(d3d12Fence, 999);
|
||||
|
||||
Dx12CommandList->Close();
|
||||
ID3D12CommandList* ppCommandLists[] = { Dx12CommandList };
|
||||
Dx12CommandQueue->ExecuteCommandLists(1, ppCommandLists);
|
||||
Dx12CommandQueue->Signal(d3d12Fence, 999);
|
||||
|
||||
auto fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
|
||||
@@ -867,6 +904,17 @@ XeSSFeatureDx11::~XeSSFeatureDx11()
|
||||
|
||||
d3d12Fence->Release();
|
||||
|
||||
auto result = xessDestroyContext(_xessContext);
|
||||
_xessContext = nullptr;
|
||||
|
||||
if (result != XESS_RESULT_SUCCESS)
|
||||
spdlog::error("XeSSFeature::Destroy xessDestroyContext error: {0}", ResultToString(result));
|
||||
|
||||
DestroyCasContext();
|
||||
|
||||
if (casBuffer != nullptr)
|
||||
casBuffer->Release();
|
||||
|
||||
SAFE_RELEASE(Dx12CommandList);
|
||||
SAFE_RELEASE(Dx12CommandQueue);
|
||||
SAFE_RELEASE(Dx12CommandAllocator);
|
||||
@@ -875,7 +923,11 @@ XeSSFeatureDx11::~XeSSFeatureDx11()
|
||||
|
||||
ReleaseSharedResources();
|
||||
|
||||
if(Imgui)
|
||||
if (Imgui)
|
||||
Imgui.reset();
|
||||
|
||||
DeviceContext->Flush();
|
||||
|
||||
SetInit(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,9 +50,7 @@ private:
|
||||
protected:
|
||||
|
||||
public:
|
||||
XeSSFeatureDx11(unsigned int InHandleId, const NVSDK_NGX_Parameter* InParameters) : XeSSFeature(InHandleId, InParameters), IFeature_Dx11(InHandleId, InParameters), IFeature(InHandleId, InParameters)
|
||||
{
|
||||
}
|
||||
XeSSFeatureDx11(unsigned int InHandleId, const NVSDK_NGX_Parameter* InParameters);
|
||||
|
||||
bool Init(ID3D11Device* InDevice, ID3D11DeviceContext* InContext, const NVSDK_NGX_Parameter* InParameters) override;
|
||||
bool Evaluate(ID3D11DeviceContext* InDeviceContext, const NVSDK_NGX_Parameter* InParameters) override;
|
||||
|
||||
@@ -253,6 +253,26 @@ bool XeSSFeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, const N
|
||||
|
||||
XeSSFeatureDx12::~XeSSFeatureDx12()
|
||||
{
|
||||
if (Device)
|
||||
{
|
||||
ID3D12Fence* d3d12Fence;
|
||||
Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&d3d12Fence));
|
||||
|
||||
d3d12Fence->Signal(999);
|
||||
|
||||
auto fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
|
||||
if (d3d12Fence->SetEventOnCompletion(999, fenceEvent) == S_OK)
|
||||
{
|
||||
WaitForSingleObject(fenceEvent, INFINITE);
|
||||
CloseHandle(fenceEvent);
|
||||
}
|
||||
else
|
||||
spdlog::warn("XeSSFeatureDx12::~XeSSFeatureDx12 can't get fenceEvent handle");
|
||||
|
||||
d3d12Fence->Release();
|
||||
}
|
||||
|
||||
if (Imgui)
|
||||
Imgui.reset();
|
||||
}
|
||||
|
||||
@@ -425,6 +425,26 @@ void Imgui_Base::RenderMenu()
|
||||
if (ImGui::Button("Revert"))
|
||||
Config::Instance()->newBackend = "";
|
||||
|
||||
// Dx11
|
||||
ImGui::BeginDisabled(Config::Instance()->Api != NVNGX_DX11);
|
||||
|
||||
const char* sync[] = { "No Syncing", "Shared Fences", "Shared Fences + Flush", "Shared Fences + Query", "Mostly Queries" };
|
||||
|
||||
const char* selectedSync = sync[Config::Instance()->UseSafeSyncQueries.value_or(0)];
|
||||
|
||||
if (ImGui::BeginCombo("Dx12wDx11 Sync", selectedSync))
|
||||
{
|
||||
for (int n = 0; n < 5; n++)
|
||||
{
|
||||
if (ImGui::Selectable(sync[n], (Config::Instance()->UseSafeSyncQueries.value_or(0) == n)))
|
||||
Config::Instance()->UseSafeSyncQueries = n;
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
ImGui::EndDisabled();
|
||||
|
||||
// UPSCALER SPECIFIC -----------------------------
|
||||
// XeSS
|
||||
ImGui::BeginDisabled(currentBackend != "xess");
|
||||
@@ -522,26 +542,6 @@ void Imgui_Base::RenderMenu()
|
||||
Config::Instance()->FsrHorizontalFov = fov;
|
||||
}
|
||||
|
||||
// Dx11
|
||||
ImGui::BeginDisabled((currentBackend != "fsr21_12") && (currentBackend != "fsr22_12"));
|
||||
|
||||
const char* sync[] = { "Shared Fences", "Shared Fences + Flush", "Shared Fences + Query", "Only Queries" };
|
||||
|
||||
const char* selectedSync = sync[Config::Instance()->UseSafeSyncQueries.value_or(0)];
|
||||
|
||||
if (ImGui::BeginCombo("Sync", selectedSync))
|
||||
{
|
||||
for (int n = 0; n < 4; n++)
|
||||
{
|
||||
if (ImGui::Selectable(sync[n], (Config::Instance()->UseSafeSyncQueries.value_or(0) == n)))
|
||||
Config::Instance()->UseSafeSyncQueries = n;
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::EndDisabled();
|
||||
|
||||
// SHARPNESS -----------------------------
|
||||
|
||||
@@ -17,9 +17,10 @@ VulkanUpscaler=auto
|
||||
;
|
||||
; Valid values are;
|
||||
; 0 - Safe syncing is off (fastest)
|
||||
; 1 - Flush after Dx11 texture copies
|
||||
; 2 - Sync after output copy
|
||||
; 3 - No fences, all sync done with queries (slowest)
|
||||
; 1 - Only Fences
|
||||
; 2 - Fences + Flush after Dx11 texture copies
|
||||
; 3 - Sync after output copy
|
||||
; 4 - No fences, all sync done with queries (slowest)
|
||||
;
|
||||
; 0 is fastest, 3 is slowest
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user