diff --git a/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp b/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp index f2ff15a16..f92a9a860 100644 --- a/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp +++ b/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp @@ -16,6 +16,7 @@ #include "SphereMesh.h" #include "ppx/graphics_util.h" +#include "ppx/timer.h" using namespace ppx; @@ -885,7 +886,21 @@ void GraphicsBenchmarkApp::Render() } submitInfo.pFence = frame.renderCompleteFence; + Timer timerSubmit; + PPX_ASSERT_MSG(timerSubmit.Start() == TIMER_RESULT_SUCCESS, "Error starting the Timer"); PPX_CHECKED_CALL(GetGraphicsQueue()->Submit(&submitInfo)); + double t = timerSubmit.MillisSinceStart(); + + uint64_t frameCount = GetFrameCount(); + mSubmissionTime.average = (mSubmissionTime.average * frameCount + t) / (frameCount + 1); + if (frameCount == 0) { + mSubmissionTime.min = t; + mSubmissionTime.max = t; + } + else { + mSubmissionTime.min = std::min(mSubmissionTime.min, t); + mSubmissionTime.max = std::max(mSubmissionTime.max, t); + } #if defined(PPX_BUILD_XR) // No need to present when XR is enabled. @@ -937,6 +952,22 @@ void GraphicsBenchmarkApp::DrawExtraInfo() uint64_t frequency = 0; GetGraphicsQueue()->GetTimestampFrequency(&frequency); + ImGui::Columns(2); + ImGui::Text("CPU Average Submission Time"); + ImGui::NextColumn(); + ImGui::Text("%.2f ms ", mSubmissionTime.average); + ImGui::NextColumn(); + + ImGui::Text("CPU Min Submission Time"); + ImGui::NextColumn(); + ImGui::Text("%.2f ms ", mSubmissionTime.min); + ImGui::NextColumn(); + + ImGui::Text("CPU Max Submission Time"); + ImGui::NextColumn(); + ImGui::Text("%.2f ms ", mSubmissionTime.max); + ImGui::NextColumn(); + ImGui::Columns(2); const float gpuWorkDurationInSec = static_cast(mGpuWorkDuration / static_cast(frequency)); const float gpuWorkDurationInMs = gpuWorkDurationInSec * 1000.0f; diff --git a/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h b/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h index 56f798b2f..bd6dbef29 100644 --- a/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h +++ b/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h @@ -207,6 +207,13 @@ class GraphicsBenchmarkApp }; }; + struct SubmissionTime + { + double min; + double max; + double average; + }; + private: using SpherePipelineMap = std::unordered_map; @@ -218,6 +225,7 @@ class GraphicsBenchmarkApp uint64_t mGpuWorkDuration; grfx::SamplerPtr mLinearSampler; grfx::DescriptorPoolPtr mDescriptorPool; + SubmissionTime mSubmissionTime; // SkyBox resources Entity mSkyBox;