Cap UI overlay rate
No need to update each frame, esp. for samples with high frame rates
This commit is contained in:
parent
a3a75219b6
commit
9a8710a57c
2 changed files with 10 additions and 1 deletions
|
|
@ -65,6 +65,7 @@ namespace vks
|
||||||
bool visible{ true };
|
bool visible{ true };
|
||||||
bool updated{ false };
|
bool updated{ false };
|
||||||
float scale{ 1.0f };
|
float scale{ 1.0f };
|
||||||
|
float updateTimer{ 0.0f };
|
||||||
|
|
||||||
UIOverlay();
|
UIOverlay();
|
||||||
~UIOverlay();
|
~UIOverlay();
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,6 @@ void VulkanExampleBase::nextFrame()
|
||||||
}
|
}
|
||||||
tPrevEnd = tEnd;
|
tPrevEnd = tEnd;
|
||||||
|
|
||||||
// TODO: Cap UI overlay update rates
|
|
||||||
updateOverlay();
|
updateOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -690,6 +689,15 @@ void VulkanExampleBase::updateOverlay()
|
||||||
if (!settings.overlay)
|
if (!settings.overlay)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// The overlay does not need to be updated with each frame, so we limit the update rate
|
||||||
|
// Not only does this save performance but it also makes display of fast changig values like fps more stable
|
||||||
|
UIOverlay.updateTimer -= frameTimer;
|
||||||
|
if (UIOverlay.updateTimer >= 0.0f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Update at max. rate of 30 fps
|
||||||
|
UIOverlay.updateTimer = 1.0f / 30.0f;
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
io.DisplaySize = ImVec2((float)width, (float)height);
|
io.DisplaySize = ImVec2((float)width, (float)height);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue