diff --git a/bindings/cs/bgfx.cs b/bindings/cs/bgfx.cs index 1b752f99d..458e180e3 100644 --- a/bindings/cs/bgfx.cs +++ b/bindings/cs/bgfx.cs @@ -2056,8 +2056,10 @@ public static partial class bgfx { public fixed byte name[256]; public ushort view; - public long cpuTimeElapsed; - public long gpuTimeElapsed; + public long cpuTimeBegin; + public long cpuTimeEnd; + public long gpuTimeBegin; + public long gpuTimeEnd; } public unsafe struct EncoderStats diff --git a/bindings/d/types.d b/bindings/d/types.d index fe718a50a..442a2a2c8 100644 --- a/bindings/d/types.d +++ b/bindings/d/types.d @@ -924,8 +924,10 @@ struct bgfx_view_stats_t { char[256] name; /// View name. bgfx_view_id_t view; /// View id. - long cpuTimeElapsed; /// CPU (submit) time elapsed. - long gpuTimeElapsed; /// GPU time elapsed. + long cpuTimeBegin; /// CPU (submit) begin time. + long cpuTimeEnd; /// CPU (submit) end time. + long gpuTimeBegin; /// GPU begin time. + long gpuTimeEnd; /// GPU end time. } /// Encoder stats. diff --git a/examples/common/example-glue.cpp b/examples/common/example-glue.cpp index 0c4f84f93..ad4507c4f 100644 --- a/examples/common/example-glue.cpp +++ b/examples/common/example-glue.cpp @@ -438,8 +438,10 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText) ImGui::Text("%3d %3d %s", pos, viewStats.view, viewStats.name); const float maxWidth = 30.0f*scale; - const float cpuWidth = bx::clamp(float(viewStats.cpuTimeElapsed*toCpuMs)*scale, 1.0f, maxWidth); - const float gpuWidth = bx::clamp(float(viewStats.gpuTimeElapsed*toGpuMs)*scale, 1.0f, maxWidth); + const float cpuTimeElapsed = float((viewStats.cpuTimeEnd - viewStats.cpuTimeBegin) * toCpuMs); + const float gpuTimeElapsed = float((viewStats.gpuTimeEnd - viewStats.gpuTimeBegin) * toGpuMs); + const float cpuWidth = bx::clamp(cpuTimeElapsed*scale, 1.0f, maxWidth); + const float gpuWidth = bx::clamp(gpuTimeElapsed*scale, 1.0f, maxWidth); ImGui::SameLine(64.0f); @@ -448,7 +450,7 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText) ImGui::SetTooltip("View %d \"%s\", CPU: %f [ms]" , pos , viewStats.name - , viewStats.cpuTimeElapsed*toCpuMs + , cpuTimeElapsed ); } @@ -458,7 +460,7 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText) ImGui::SetTooltip("View: %d \"%s\", GPU: %f [ms]" , pos , viewStats.name - , viewStats.gpuTimeElapsed*toGpuMs + , gpuTimeElapsed ); } } diff --git a/include/bgfx/bgfx.h b/include/bgfx/bgfx.h index e34aaf406..98c26d450 100644 --- a/include/bgfx/bgfx.h +++ b/include/bgfx/bgfx.h @@ -911,8 +911,10 @@ namespace bgfx { char name[256]; //!< View name. ViewId view; //!< View id. - int64_t cpuTimeElapsed; //!< CPU (submit) time elapsed. - int64_t gpuTimeElapsed; //!< GPU time elapsed. + int64_t cpuTimeBegin; //!< CPU (submit) begin time. + int64_t cpuTimeEnd; //!< CPU (submit) end time. + int64_t gpuTimeBegin; //!< GPU begin time. + int64_t gpuTimeEnd; //!< GPU end time. }; /// Encoder stats. diff --git a/include/bgfx/c99/bgfx.h b/include/bgfx/c99/bgfx.h index 861c24367..2a9fe94c4 100644 --- a/include/bgfx/c99/bgfx.h +++ b/include/bgfx/c99/bgfx.h @@ -783,8 +783,10 @@ typedef struct bgfx_view_stats_s { char name[256]; /** View name. */ bgfx_view_id_t view; /** View id. */ - int64_t cpuTimeElapsed; /** CPU (submit) time elapsed. */ - int64_t gpuTimeElapsed; /** GPU time elapsed. */ + int64_t cpuTimeBegin; /** CPU (submit) begin time. */ + int64_t cpuTimeEnd; /** CPU (submit) end time. */ + int64_t gpuTimeBegin; /** GPU begin time. */ + int64_t gpuTimeEnd; /** GPU end time. */ } bgfx_view_stats_t; diff --git a/scripts/bgfx.idl b/scripts/bgfx.idl index 77d730996..0d98de255 100644 --- a/scripts/bgfx.idl +++ b/scripts/bgfx.idl @@ -860,8 +860,10 @@ struct.Transform struct.ViewStats .name "char[256]" --- View name. .view "ViewId" --- View id. - .cpuTimeElapsed "int64_t" --- CPU (submit) time elapsed. - .gpuTimeElapsed "int64_t" --- GPU time elapsed. + .cpuTimeBegin "int64_t" --- CPU (submit) begin time. + .cpuTimeEnd "int64_t" --- CPU (submit) end time. + .gpuTimeBegin "int64_t" --- GPU begin time. + .gpuTimeEnd "int64_t" --- GPU end time. --- Encoder stats. struct.EncoderStats diff --git a/src/renderer.h b/src/renderer.h index 025c6f7e9..ff298d80c 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -499,7 +499,7 @@ namespace bgfx if (m_enabled) { ViewStats& viewStats = m_frame->m_perfStats.viewStats[m_numViews]; - viewStats.cpuTimeElapsed = -bx::getHPCounter(); + viewStats.cpuTimeBegin = bx::getHPCounter(); m_queryIdx = m_gpuTimer.begin(_view); @@ -521,8 +521,9 @@ namespace bgfx ViewStats& viewStats = m_frame->m_perfStats.viewStats[m_numViews]; const typename Ty::Result& result = m_gpuTimer.m_result[viewStats.view]; - viewStats.cpuTimeElapsed += bx::getHPCounter(); - viewStats.gpuTimeElapsed = result.m_end - result.m_begin; + viewStats.cpuTimeEnd = bx::getHPCounter(); + viewStats.gpuTimeBegin = result.m_begin; + viewStats.gpuTimeEnd = result.m_end; ++m_numViews; m_queryIdx = UINT32_MAX;