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:
jwdevel
2022-09-18 19:09:48 -07:00
committed by GitHub
parent 6be057ba5c
commit f1f77a6cd3
25 changed files with 109 additions and 49 deletions

View File

@@ -3987,9 +3987,10 @@ namespace bgfx { namespace webgpu
{
}
uint32_t TimerQueryWgpu::begin(uint32_t _resultIdx)
uint32_t TimerQueryWgpu::begin(uint32_t _resultIdx, uint32_t _frameNum)
{
BX_UNUSED(_resultIdx);
BX_UNUSED(_frameNum);
return 0;
}
@@ -4847,6 +4848,7 @@ namespace bgfx { namespace webgpu
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;