NVIDIA Reflex integration. (#4029)

* Integrated NVIDIA Reflex.

* Generated bindings and replaced bools with enum.

* Merged upstream master.

* Addressed review feedback.
This commit is contained in:
Matthew
2026-10-08 18:44:43 -07:00
committed by GitHub
parent 8a4df55ac0
commit 06b2c3a4b3
21 changed files with 1247 additions and 118 deletions
+39
View File
@@ -2065,6 +2065,16 @@ namespace bgfx { namespace d3d12
}
}
// Reflex paces the main swap chain only.
if (0 != (_init.capabilities & BGFX_CAPS_LOW_LATENCY)
&& mainFrameBuffer().isSwapChain()
&& m_nvapi.initReflex(m_device) )
{
g_caps.supported |= BGFX_CAPS_LOW_LATENCY;
m_nvapi.setSleepMode(getLatencyMode(m_reset) );
}
if (m_nvapi.isInitialized() )
{
finish();
@@ -2120,6 +2130,8 @@ namespace bgfx { namespace d3d12
finishAll(true);
m_batch.destroy();
m_nvapi.shutdownReflex();
DX_RELEASE(m_zeroInitBuffer, 0);
preReset();
@@ -3034,6 +3046,16 @@ namespace bgfx { namespace d3d12
}
}
void latencySleep() override
{
m_nvapi.sleep();
}
void setLatencyMarker(LatencyMarker::Enum _marker, uint64_t _frameId) override
{
m_nvapi.setLatencyMarker(_marker, _frameId);
}
virtual void setName(Handle _handle, const char* _name, uint16_t _len) override
{
switch (_handle.type)
@@ -3258,10 +3280,21 @@ namespace bgfx { namespace d3d12
else
m_reset &= ~BGFX_RESET_VSYNC;
if (0 != ( (m_reset ^ _reset) & BGFX_RESET_LOW_LATENCY_MASK) )
{
m_reset = 0
| (m_reset & ~BGFX_RESET_LOW_LATENCY_MASK)
| ( _reset & BGFX_RESET_LOW_LATENCY_MASK)
;
m_nvapi.setSleepMode(getLatencyMode(m_reset) );
}
const uint32_t maskFlags = ~(0
| BGFX_RESET_MAXANISOTROPY
| BGFX_RESET_SUSPEND
| BGFX_RESET_VSYNC
| BGFX_RESET_LOW_LATENCY_MASK
);
if (m_mainSwapChain.width != _swapChain.width
@@ -10543,6 +10576,12 @@ namespace bgfx { namespace d3d12
perfStats.gpuMemoryUsed = int64_t(vmi[0].CurrentUsage);
#endif // BX_PLATFORM_WINDOWS
LatencyReport latencyReport;
if (m_nvapi.getLatencyReport(latencyReport) )
{
setLatencyStats(perfStats, latencyReport);
}
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
{
BGFX_D3D12_PROFILER_BEGIN_LITERAL("debugstats", kColorFrame);