From 7268c65d73c3024853fb8b1e99c23eafc12e35f4 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 22 Aug 2018 17:59:58 +0200 Subject: [PATCH] Examples: imgui_impl_vulkan: Comments (re) --- examples/imgui_impl_vulkan.cpp | 17 +++++++++++------ examples/imgui_impl_vulkan.h | 23 +++++++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp index b653cdc7..1cd83b23 100644 --- a/examples/imgui_impl_vulkan.cpp +++ b/examples/imgui_impl_vulkan.cpp @@ -726,14 +726,19 @@ void ImGui_ImplVulkan_NewFrame() { } + //------------------------------------------------------------------------- -// Optional / Miscellaneous Vulkan Helpers +// Internal / Miscellaneous Vulkan Helpers //------------------------------------------------------------------------- -// - Those functions do NOT use any of the state used/affected by the regular ImGui_ImplVulkan_XXX functions. -// - If your application/engine already has code to create all that stuff (swap chain, render pass, frame buffers, etc.) you may ignore those. -// - Those functions are used by the example main.cpp and will be used by imgui_impl_vulkan.cpp in the upcoming multi-viewport branch (1.70). -// Generally we try to not provide any kind of superfluous high-level helpers in the examples, but it is too much code to duplicate -// in the main.cpp of every examples. Since the upcoming multi-viewport will need these, we include them here. +// You probably do NOT need to use or care about those functions. +// Those functions only exist because: +// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files. +// 2) the upcoming multi-viewport feature will need them internally. +// Generally we avoid exposing any kind of superfluous high-level helpers in the bindings, +// but it is too much code to duplicate everywhere so we exceptionally expose them. +// Your application/engine will likely already have code to setup all that stuff (swap chain, render pass, frame buffers, etc.). +// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work. +// (those functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions) //------------------------------------------------------------------------- #include // malloc diff --git a/examples/imgui_impl_vulkan.h b/examples/imgui_impl_vulkan.h index 8bb19e03..45993472 100644 --- a/examples/imgui_impl_vulkan.h +++ b/examples/imgui_impl_vulkan.h @@ -36,18 +36,23 @@ IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, V IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer); IMGUI_IMPL_API void ImGui_ImplVulkan_InvalidateFontUploadObjects(); -// Called by ImGui_ImplVulkan_Init() +// Called by ImGui_ImplVulkan_Init() might be useful elsewhere. IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateDeviceObjects(); IMGUI_IMPL_API void ImGui_ImplVulkan_InvalidateDeviceObjects(); + //------------------------------------------------------------------------- -// Optional / Miscellaneous Vulkan Helpers +// Internal / Miscellaneous Vulkan Helpers //------------------------------------------------------------------------- -// - Those functions do NOT use any of the state used/affected by the regular ImGui_ImplVulkan_XXX functions. -// - If your application/engine already has code to create all that stuff (swap chain, render pass, frame buffers, etc.) you may ignore those. -// - Those functions are used by the example main.cpp and will be used by imgui_impl_vulkan.cpp in the upcoming multi-viewport branch (1.70). -// Generally we try to not provide any kind of superfluous high-level helpers in the examples, but it is too much code to duplicate -// in the main.cpp of every examples. Since the upcoming multi-viewport will need these, we include them here. +// You probably do NOT need to use or care about those functions. +// Those functions only exist because: +// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files. +// 2) the upcoming multi-viewport feature will need them internally. +// Generally we avoid exposing any kind of superfluous high-level helpers in the bindings, +// but it is too much code to duplicate everywhere so we exceptionally expose them. +// Your application/engine will likely already have code to setup all that stuff (swap chain, render pass, frame buffers, etc.). +// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work. +// (those functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions) //------------------------------------------------------------------------- struct ImGui_ImplVulkanH_FrameData; @@ -60,9 +65,10 @@ IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhys IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count); IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode); +// Helper structure to hold the data needed by one rendering frame struct ImGui_ImplVulkanH_FrameData { - uint32_t BackbufferIndex; // keep track of recently rendered swapchain frame indices + uint32_t BackbufferIndex; // Keep track of recently rendered swapchain frame indices VkCommandPool CommandPool; VkCommandBuffer CommandBuffer; VkFence Fence; @@ -72,6 +78,7 @@ struct ImGui_ImplVulkanH_FrameData IMGUI_IMPL_API ImGui_ImplVulkanH_FrameData(); }; +// Helper structure to hold the data needed by one rendering context into one OS window struct ImGui_ImplVulkanH_WindowData { int Width;