You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/Building_a_Simple_Engine/GUI/02_imgui_setup.adoc
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,6 +111,11 @@ Next, we set up the Vulkan pipeline objects that define how UI geometry is proce
111
111
112
112
The pipeline infrastructure creates a specialized graphics pipeline optimized for UI rendering, which differs significantly from typical 3D rendering pipelines. UI rendering typically requires alpha blending for transparency effects, operates in 2D screen space rather than 3D world space, and uses simpler shading models focused on texture sampling rather than complex lighting calculations.
113
113
114
+
[NOTE]
115
+
====
116
+
Frames-in-flight safety: If your renderer uses more than one frame in flight and you do not stall the GPU between frames, you must duplicate the dynamic ImGui buffers (vertex/index) per frame-in-flight. Using a single shared vertex/index buffer risks the CPU overwriting data still in use by the GPU from a previous frame. The simple single-buffer members shown above are for conceptual clarity; in production, store vectors of buffers/memories sized to the max frames in flight and update/bind the buffers for the current frame index.
117
+
====
118
+
114
119
The descriptor system manages the connection between our CPU-side resources and the GPU shaders. For UI rendering, this primarily involves binding the font atlas texture to the fragment shader, though more complex UI systems might include additional textures for icons, backgrounds, or other visual elements.
115
120
116
121
=== ImGuiVulkanUtil Architecture: Device Context and System Integration
@@ -773,7 +778,7 @@ void drawFrame() {
773
778
// Render scene using dynamic rendering
774
779
// ...
775
780
776
-
// Render ImGui
781
+
// Render ImGui (in multi-frame renderers, pass the current frame index to bind per-frame buffers)
Copy file name to clipboardExpand all lines: en/Building_a_Simple_Engine/GUI/04_ui_elements.adoc
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,6 +111,69 @@ When integrating ImGui with Vulkan, consider these performance aspects:
111
111
4. *Pipeline State*: Use a dedicated pipeline for ImGui to minimize state changes
112
112
5. *Render Pass Integration*: Consider whether to use a separate render pass or subpass for the GUI
113
113
114
+
==== Frames-in-Flight: Duplicate Dynamic Buffers Per Frame
115
+
116
+
If your renderer uses multiple frames in flight (e.g., double/triple buffering) without a device wait-idle between frames, ImGui's dynamic vertex and index buffers must not be shared across frames. Otherwise, the CPU can overwrite data that the GPU from a previous frame is still reading.
117
+
118
+
- Allocate one vertex buffer and one index buffer per frame-in-flight.
119
+
- Update/bind the buffers for the current frame index only.
120
+
- Size each buffer to the frame's ImDrawData TotalVtxCount/TotalIdxCount, growing as needed.
0 commit comments