Render thread and "draw" measuring

We noticed that in some scenarios “stat unit” and it’s “Draw” field doesn’t show correct results (e.g. “0.2ms” instead of “8ms”). Looking into the code it seems that when there is more than 1 item in WindowElementLists during iteration in FSlateRHIRenderer::DrawWindows_Private, - it could schedule DrawWindow_RenderThread more than 1 time per render frame. It causes wrong calculation of draw time as many variables are globals (like GRenderThreadIdle, GRenderThreadTime, etc), and LastTimestamp calculation logic assumes it is called one time per frame.

To fix that, the whole block of calculation of these metrics can be moved in EndFrameRenderThread. Alternatively, calculation logic can be adjusted considering DrawWindow_RenderThread can be called multiple times. Does it makes sense?

Steps to Reproduce

Hello,

Thank you for reaching out.

I’ve been assigned this issue, and we will be looking into the incorrect measurement of the Draw stat for you.

Can you please send us a minimal test project that demonstrates one of these scenarios where Draw is measured incorrectly?

The guide for test projects:

[Content removed]