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
@@ -1656,6 +1656,16 @@ namespace bgfx { namespace d3d11
postReset();
}
// 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) );
}
m_nvapi.initAftermath(m_device, m_deviceCtx);
g_internalData.context = m_device;
@@ -1719,6 +1729,8 @@ namespace bgfx { namespace d3d11
{
preReset();
m_nvapi.shutdownReflex();
if (NULL != m_ags)
{
agsDeInit(m_ags);
@@ -2224,6 +2236,16 @@ namespace bgfx { namespace d3d11
}
}
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)
@@ -2535,10 +2557,21 @@ namespace bgfx { namespace d3d11
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
@@ -7925,6 +7958,12 @@ namespace bgfx { namespace d3d11
bx::memCopy(perfStats.numPrims, statsNumPrimsRendered, sizeof(perfStats.numPrims) );
m_nvapi.getMemoryInfo(perfStats.gpuMemoryUsed, perfStats.gpuMemoryMax);
LatencyReport latencyReport;
if (m_nvapi.getLatencyReport(latencyReport) )
{
setLatencyStats(perfStats, latencyReport);
}
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
{
BGFX_D3D11_PROFILER_BEGIN_LITERAL("debugstats", kColorFrame);