added fixes for frame timing

disabled extra queues when not using hudfix
This commit is contained in:
cdozdil
2024-11-05 15:59:49 +03:00
parent 4aab4febf8
commit ff615888d2
5 changed files with 24 additions and 46 deletions
+4 -11
View File
@@ -26,14 +26,12 @@
//#define USE_COPY_QUEUE_FOR_FG
// Use a dedicated Queue + CommandList for FG
#define USE_QUEUE_FOR_FG
//#define USE_QUEUE_FOR_FG
#ifndef USE_QUEUE_FOR_FG
// Do not make copies of Depth + Velocity for FG
//#define DONT_USE_DEPTH_MV_COPIES
#endif
#ifndef USE_MUTEX_FOR_FFX
#ifndef USE_PRESENT_FOR_FT
static UINT64 fgLastFrameTime = 0;
#endif
static UINT64 fgLastFGFrame = 0;
@@ -1343,7 +1341,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
{
FrameGen_Dx12::upscaleRan = true;
#ifndef USE_MUTEX_FOR_FFX
#ifndef USE_PRESENT_FOR_FT
float msDelta = 0.0;
auto now = Util::MillisecondsNow();
@@ -1353,8 +1351,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
LOG_DEBUG("(FG) msDelta: {0}", msDelta);
}
FrameGen_Dx12::fgFrameTime = msDelta;
fgLastFrameTime = now;
FrameGen_Dx12::fgFrameTime = msDelta;
#endif
if (Config::Instance()->FGHUDFix.value_or(false))
@@ -1549,12 +1547,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
dfgPrepare.cameraFovAngleVertical = 1.0471975511966f;
dfgPrepare.viewSpaceToMetersFactor = 1.0;
#ifndef USE_MUTEX_FOR_FFX
dfgPrepare.frameTimeDelta = msDelta;
#else
dfgPrepare.frameTimeDelta = FrameGen_Dx12::fgFrameTime;
#endif
#ifdef USE_MUTEX_FOR_FFX
FrameGen_Dx12::ffxMutex.lock();
+13 -32
View File
@@ -1507,26 +1507,33 @@ static void hkDispatch(ID3D12GraphicsCommandList* This, UINT ThreadGroupCountX,
#ifdef USE_MUTEX_FOR_FFX
static HRESULT hkFGPresent(void* This, UINT SyncInterval, UINT Flags)
{
FrameGen_Dx12::upscaleRan = false;
// Skip calculations etc
if (Flags & DXGI_PRESENT_TEST)
return o_FGSCPresent(This, SyncInterval, Flags);
FrameGen_Dx12::ffxMutex.lock();
auto result = o_FGSCPresent(This, SyncInterval, Flags);
#ifdef USE_PRESENT_FOR_FT
float msDelta = 0.0;
auto now = Util::MillisecondsNow();
if (fgLastFrameTime != 0)
{
msDelta = now - fgLastFrameTime;
LOG_DEBUG("(FG) msDelta: {0}", msDelta);
LOG_DEBUG("Frametime: {0}", msDelta);
}
FrameGen_Dx12::fgFrameTime = msDelta;
fgLastFrameTime = now;
FrameGen_Dx12::fgFrameTime = msDelta;
#else
LOG_DEBUG("");
#endif
LOG_DEBUG("");
auto result = o_FGSCPresent(This, SyncInterval, Flags);
FrameGen_Dx12::upscaleRan = false;
FrameGen_Dx12::ffxMutex.unlock();
return result;
}
#endif
@@ -1561,9 +1568,6 @@ static HRESULT Present(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags
FrameGen_Dx12::gameCommandQueue = swInfo->gameCommandQueue;
}
//if (Config::Instance()->CurrentFeature != nullptr)
// LOG_DEBUG("FrameCount: {}, fgHudlessFrame: {}", Config::Instance()->CurrentFeature->FrameCount(), fgHudlessFrame);
ID3D12CommandQueue* cq = nullptr;
ID3D11Device* device = nullptr;
ID3D12Device* device12 = nullptr;
@@ -1622,17 +1626,6 @@ static HRESULT Present(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags
fgStopAfterNextPresent = false;
}
#ifndef USE_MUTEX_FOR_FFX
auto now = Util::MillisecondsNow();
if (fgLastFrameTime != 0)
{
fgLastDeltaTime = now - fgLastFrameTime;
LOG_DEBUG("fgLastDeltaTime: {0:.2f}, frameCounter: {1}", fgLastDeltaTime, frameCounter);
}
fgLastFrameTime = now;
#endif
return presentResult;
}
@@ -1727,18 +1720,6 @@ static HRESULT Present(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags
if (device12 != nullptr)
device12->Release();
#ifndef USE_MUTEX_FOR_FFX
auto now = Util::MillisecondsNow();
if (fgLastFrameTime != 0)
{
fgLastDeltaTime = now - fgLastFrameTime;
LOG_DEBUG("fgLastDeltaTime: {0:.2f}, frameCounter: {1}", fgLastDeltaTime, frameCounter);
}
fgLastFrameTime = now;
#endif
return presentResult;
}
+4
View File
@@ -12,6 +12,10 @@
// Will use mutex to prevent race condutions
#define USE_MUTEX_FOR_FFX
#ifdef USE_MUTEX_FOR_FFX
#define USE_PRESENT_FOR_FT
#endif
// Enable D3D12 Debug Layers
//#define ENABLE_DEBUG_LAYER
+2 -2
View File
@@ -233,7 +233,7 @@ HRESULT WrappedIDXGISwapChain4::Present(UINT SyncInterval, UINT Flags)
HRESULT result;
if (!(Flags & DXGI_PRESENT_TEST) && !(Flags & DXGI_PRESENT_RESTART) && RenderTrig != nullptr)
if (!(Flags & DXGI_PRESENT_TEST) && RenderTrig != nullptr)
result = RenderTrig(m_pReal, SyncInterval, Flags, nullptr, Device, Handle);
else
result = m_pReal->Present(SyncInterval, Flags);
@@ -248,7 +248,7 @@ HRESULT WrappedIDXGISwapChain4::Present1(UINT SyncInterval, UINT Flags, const DX
HRESULT result;
if (!(Flags & DXGI_PRESENT_TEST) && !(Flags & DXGI_PRESENT_RESTART) && RenderTrig != nullptr)
if (!(Flags & DXGI_PRESENT_TEST) && RenderTrig != nullptr)
result = RenderTrig(m_pReal1, SyncInterval, Flags, pPresentParameters, Device, Handle);
else
result = m_pReal1->Present1(SyncInterval, Flags, pPresentParameters);
+1 -1
View File
@@ -21,7 +21,7 @@
#define VER_MAJOR_VERSION 0
#define VER_MINOR_VERSION 7
#define VER_HOTFIX_VERSION 0
#define VER_BUILD_NUMBER 33
#define VER_BUILD_NUMBER 36
#define VER_PRE_RELEASE