From 0c4f50090aa9ec3d9ea7d0159a801dd2cea5df83 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 20 Aug 2025 17:48:03 +0200 Subject: [PATCH] DrawList: fixed CloneOutput() taking a copy of the ImDrawListSharedData pointer. (#8894, #1860) Amend b82e99c032 --- imgui.h | 2 +- imgui_draw.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/imgui.h b/imgui.h index 0df769352..95c70c71b 100644 --- a/imgui.h +++ b/imgui.h @@ -3316,7 +3316,7 @@ struct ImDrawList // Advanced: Miscellaneous IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible - IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer. + IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer. For multi-threaded rendering, consider using `imgui_threaded_rendering` from https://github.com/ocornut/imgui_club instead. // Advanced: Channels // - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 4b089286f..0426d4a2e 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -478,9 +478,10 @@ void ImDrawList::_ClearFreeMemory() _Splitter.ClearFreeMemory(); } +// Note: For multi-threaded rendering, consider using `imgui_threaded_rendering` from https://github.com/ocornut/imgui_club ImDrawList* ImDrawList::CloneOutput() const { - ImDrawList* dst = IM_NEW(ImDrawList(_Data)); + ImDrawList* dst = IM_NEW(ImDrawList(NULL)); dst->CmdBuffer = CmdBuffer; dst->IdxBuffer = IdxBuffer; dst->VtxBuffer = VtxBuffer;