mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-10-24 09:50:51 +00:00
Record frame num in view stats (#2908)
* Add 'frameNumber' to Frame struct Previously, the frame number returned from bgfx::frame() was tracked separately in the Context. Now, we store that information in the Frame. This will allow us to attach the frame number to ViewStats. * Add frame number to ViewStats When ViewStats are enabled, we tag each timer query with the current frame number, then include that information in the final results. In this way, clients can correlate specific work that they submitted to specific GPU timing information. NOTE: Some backends not implemented, yet. They will always have 0 for frame number. The ones which are implemented are: * OpenGL * Vulkan * D3D 9,11,12 * Noop
This commit is contained in:
@@ -5882,7 +5882,7 @@ namespace bgfx { namespace d3d12
|
||||
DX_RELEASE(m_readback, 0);
|
||||
}
|
||||
|
||||
uint32_t TimerQueryD3D12::begin(uint32_t _resultIdx)
|
||||
uint32_t TimerQueryD3D12::begin(uint32_t _resultIdx, uint32_t _frameNum)
|
||||
{
|
||||
while (0 == m_control.reserve(1) )
|
||||
{
|
||||
@@ -5896,6 +5896,7 @@ namespace bgfx { namespace d3d12
|
||||
Query& query = m_query[idx];
|
||||
query.m_resultIdx = _resultIdx;
|
||||
query.m_ready = false;
|
||||
query.m_frameNum = _frameNum;
|
||||
|
||||
ID3D12GraphicsCommandList* commandList = s_renderD3D12->m_commandList;
|
||||
|
||||
@@ -5957,6 +5958,7 @@ namespace bgfx { namespace d3d12
|
||||
|
||||
Result& result = m_result[query.m_resultIdx];
|
||||
--result.m_pending;
|
||||
result.m_frameNum = query.m_frameNum;
|
||||
|
||||
uint32_t offset = idx * 2;
|
||||
result.m_begin = m_queryResult[offset+0];
|
||||
@@ -6192,7 +6194,7 @@ namespace bgfx { namespace d3d12
|
||||
int64_t timeBegin = bx::getHPCounter();
|
||||
int64_t captureElapsed = 0;
|
||||
|
||||
uint32_t frameQueryIdx = m_gpuTimer.begin(BGFX_CONFIG_MAX_VIEWS);
|
||||
uint32_t frameQueryIdx = m_gpuTimer.begin(BGFX_CONFIG_MAX_VIEWS, _render->m_frameNum);
|
||||
|
||||
if (0 < _render->m_iboffset)
|
||||
{
|
||||
@@ -7066,6 +7068,7 @@ namespace bgfx { namespace d3d12
|
||||
perfStats.numCompute = statsKeyType[1];
|
||||
perfStats.numBlit = _render->m_numBlitItems;
|
||||
perfStats.maxGpuLatency = maxGpuLatency;
|
||||
perfStats.gpuFrameNum = result.m_frameNum;
|
||||
bx::memCopy(perfStats.numPrims, statsNumPrimsRendered, sizeof(perfStats.numPrims) );
|
||||
perfStats.gpuMemoryMax = -INT64_MAX;
|
||||
perfStats.gpuMemoryUsed = -INT64_MAX;
|
||||
|
||||
Reference in New Issue
Block a user