Misc: Made multiple calls to Render() during the same frame early out faster.

This commit is contained in:
ocornut 2023-08-14 16:23:04 +02:00
parent ac64b65634
commit d2c7cbcbf9
2 changed files with 6 additions and 5 deletions

View File

@ -54,6 +54,7 @@ Other changes:
of individual ImDrawList's buffer sizes when a dimming/modal background is rendered. (#6716) of individual ImDrawList's buffer sizes when a dimming/modal background is rendered. (#6716)
- ImDrawList: Fixed OOB access in _CalcCircleAutoSegmentCount when passing excessively - ImDrawList: Fixed OOB access in _CalcCircleAutoSegmentCount when passing excessively
large radius to AddCircle(). (#6657, #5317) [@EggsyCRO, @jdpatdiscord] large radius to AddCircle(). (#6657, #5317) [@EggsyCRO, @jdpatdiscord]
- Misc: Made multiple calls to Render() during the same frame early out faster.
- Debug Tools: Metrics: Fixed "Drawlists" section and per-viewport equivalent - Debug Tools: Metrics: Fixed "Drawlists" section and per-viewport equivalent
appearing empty (regression in 1.89.8). appearing empty (regression in 1.89.8).
- Demo: Demonstrate out-of-order rendering using ImDrawListSplitter. - Demo: Demonstrate out-of-order rendering using ImDrawListSplitter.

View File

@ -5077,15 +5077,15 @@ void ImGui::Render()
if (g.FrameCountEnded != g.FrameCount) if (g.FrameCountEnded != g.FrameCount)
EndFrame(); EndFrame();
const bool first_render_of_frame = (g.FrameCountRendered != g.FrameCount); if (g.FrameCountRendered == g.FrameCount)
return;
g.FrameCountRendered = g.FrameCount; g.FrameCountRendered = g.FrameCount;
g.IO.MetricsRenderWindows = 0;
g.IO.MetricsRenderWindows = 0;
CallContextHooks(&g, ImGuiContextHookType_RenderPre); CallContextHooks(&g, ImGuiContextHookType_RenderPre);
// Draw modal/window whitening backgrounds // Draw modal/window whitening backgrounds
if (first_render_of_frame) RenderDimmedBackgrounds();
RenderDimmedBackgrounds();
// Add background ImDrawList (for each active viewport) // Add background ImDrawList (for each active viewport)
for (int n = 0; n != g.Viewports.Size; n++) for (int n = 0; n != g.Viewports.Size; n++)
@ -5112,7 +5112,7 @@ void ImGui::Render()
AddRootWindowToDrawData(windows_to_render_top_most[n]); AddRootWindowToDrawData(windows_to_render_top_most[n]);
// Draw software mouse cursor if requested by io.MouseDrawCursor flag // Draw software mouse cursor if requested by io.MouseDrawCursor flag
if (g.IO.MouseDrawCursor && first_render_of_frame && g.MouseCursor != ImGuiMouseCursor_None) if (g.IO.MouseDrawCursor && g.MouseCursor != ImGuiMouseCursor_None)
RenderMouseCursor(g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48)); RenderMouseCursor(g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
// Setup ImDrawData structures for end-user // Setup ImDrawData structures for end-user