Skip to content

Commit

Permalink
Update the knob such that we only show the min, max and average
Browse files Browse the repository at this point in the history
submission time
  • Loading branch information
elviscapiaq committed Nov 14, 2023
1 parent 7871c5e commit 715eeff
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 35 deletions.
77 changes: 45 additions & 32 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ void GraphicsBenchmarkApp::InitKnobs()
pDrawCallCount->SetFlagDescription("Select the number of draw calls to be used to draw the `sphere-count` spheres.");
pDrawCallCount->SetIndent(1);

pSubmissionCount = GetKnobManager().CreateKnob<ppx::KnobSlider<int>>("submission-count", /* defaultValue = */ 1, /* minValue = */ 1, kMaxSubmissionCount);
pSubmissionCount->SetDisplayName("Submission Count");
pSubmissionCount->SetFlagDescription("Select the number of submissions.");
pSubmissionCount->SetIndent(1);

pAlphaBlend = GetKnobManager().CreateKnob<ppx::KnobCheckbox>("alpha-blend", false);
pAlphaBlend->SetDisplayName("Alpha Blend");
pAlphaBlend->SetFlagDescription("Set blend mode of the spheres to alpha blending.");
Expand Down Expand Up @@ -836,34 +831,41 @@ void GraphicsBenchmarkApp::Render()

RecordCommandBuffer(frame, swapchain, imageIndex);

size_t submissionCount = pSubmissionCount->GetValue();
mSubmissionTimes.resize(submissionCount);
for (size_t i = 0; i < submissionCount; i++) {
grfx::SubmitInfo submitInfo = {};
submitInfo.commandBufferCount = 1;
submitInfo.ppCommandBuffers = &frame.cmd;
grfx::SubmitInfo submitInfo = {};
submitInfo.commandBufferCount = 1;
submitInfo.ppCommandBuffers = &frame.cmd;
#if defined(PPX_BUILD_XR)
// No need to use semaphore when XR is enabled.
if (IsXrEnabled()) {
submitInfo.waitSemaphoreCount = 0;
submitInfo.ppWaitSemaphores = nullptr;
submitInfo.signalSemaphoreCount = 0;
submitInfo.ppSignalSemaphores = nullptr;
}
else
// No need to use semaphore when XR is enabled.
if (IsXrEnabled()) {
submitInfo.waitSemaphoreCount = 0;
submitInfo.ppWaitSemaphores = nullptr;
submitInfo.signalSemaphoreCount = 0;
submitInfo.ppSignalSemaphores = nullptr;
}
else
#endif
{
submitInfo.waitSemaphoreCount = (i == 0);
submitInfo.ppWaitSemaphores = (i == 0 ? &frame.imageAcquiredSemaphore : nullptr);
submitInfo.signalSemaphoreCount = (i == (submissionCount - 1));
submitInfo.ppSignalSemaphores = (i == (submissionCount - 1) ? &frame.renderCompleteSemaphore : nullptr);
}
submitInfo.pFence = (i == (submissionCount - 1) ? frame.renderCompleteFence : nullptr);
{
submitInfo.waitSemaphoreCount = 1;
submitInfo.ppWaitSemaphores = &frame.imageAcquiredSemaphore;
submitInfo.signalSemaphoreCount = 1;
submitInfo.ppSignalSemaphores = &frame.renderCompleteSemaphore;
}
submitInfo.pFence = frame.renderCompleteFence;

Timer timerSubmit;
timerSubmit.Start();
PPX_CHECKED_CALL(GetGraphicsQueue()->Submit(&submitInfo));
double t = timerSubmit.MillisSinceStart();

Timer timerSubmit;
timerSubmit.Start();
PPX_CHECKED_CALL(GetGraphicsQueue()->Submit(&submitInfo));
mSubmissionTimes[i] = timerSubmit.MillisSinceStart();
uint64_t frameCount = GetFrameCount();
mSubmissionTime.average = (mSubmissionTime.average * frameCount) / (frameCount + 1) + 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)
Expand Down Expand Up @@ -917,10 +919,21 @@ void GraphicsBenchmarkApp::DrawExtraInfo()
GetGraphicsQueue()->GetTimestampFrequency(&frequency);

ImGui::Columns(2);
const float avgSubmissionTimeInMs = std::accumulate(mSubmissionTimes.begin(), mSubmissionTimes.end(), 0.0f) / mSubmissionTimes.size();
ImGui::Text("CPU Average Submission Time");
ImGui::NextColumn();
ImGui::Text("%.2f ms ", avgSubmissionTimeInMs);
ImGui::Text("%.2f ms ", mSubmissionTime.average);
ImGui::NextColumn();

ImGui::Columns(2);
ImGui::Text("CPU Min Submission Time");
ImGui::NextColumn();
ImGui::Text("%.2f ms ", mSubmissionTime.min);
ImGui::NextColumn();

ImGui::Columns(2);
ImGui::Text("CPU Max Submission Time");
ImGui::NextColumn();
ImGui::Text("%.2f ms ", mSubmissionTime.max);
ImGui::NextColumn();

ImGui::Columns(2);
Expand Down
11 changes: 8 additions & 3 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const grfx::Api kApi = grfx::API_VK_1_1;
static constexpr uint32_t kMaxSphereInstanceCount = 3000;
static constexpr uint32_t kSeed = 89977;
static constexpr uint32_t kMaxFullscreenQuadsCount = 1000;
static constexpr uint32_t kMaxSubmissionCount = 1000;

static constexpr const char* kShaderBaseDir = "benchmarks/shaders";

Expand Down Expand Up @@ -171,6 +170,13 @@ class GraphicsBenchmarkApp
std::string name;
};

struct SubmissionTime
{
double min;
double max;
double average;
};

private:
std::vector<PerFrame> mPerFrame;
FreeCamera mCamera;
Expand All @@ -180,7 +186,7 @@ class GraphicsBenchmarkApp
uint64_t mGpuWorkDuration;
grfx::SamplerPtr mLinearSampler;
grfx::DescriptorPoolPtr mDescriptorPool;
std::vector<double> mSubmissionTimes;
SubmissionTime mSubmissionTime;

// SkyBox resources
Entity mSkyBox;
Expand Down Expand Up @@ -227,7 +233,6 @@ class GraphicsBenchmarkApp
std::shared_ptr<KnobCheckbox> pEnableSkyBox;
std::shared_ptr<KnobCheckbox> pEnableSpheres;
std::shared_ptr<KnobCheckbox> pAllTexturesTo1x1;
std::shared_ptr<KnobSlider<int>> pSubmissionCount;

private:
// =====================================================================
Expand Down

0 comments on commit 715eeff

Please sign in to comment.