imgui_impl_vulkan.h
Go to the documentation of this file.
1 // dear imgui: Renderer for Vulkan
2 // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
3 
4 // Implemented features:
5 // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
6 // Missing features:
7 // [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
8 
9 // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
10 // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
11 // https://github.com/ocornut/imgui
12 
13 // The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
14 // IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
15 
16 // Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
17 // - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
18 // You will use those if you want to use this rendering back-end in your engine/app.
19 // - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by
20 // the back-end itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code.
21 // Read comments in imgui_impl_vulkan.h.
22 
23 #pragma once
24 
25 #include <vulkan/vulkan.h>
26 
27 // Initialization data, for ImGui_ImplVulkan_Init()
28 // [Please zero-clear before use!]
30 {
31  VkInstance Instance;
32  VkPhysicalDevice PhysicalDevice;
33  VkDevice Device;
34  uint32_t QueueFamily;
35  VkQueue Queue;
36  VkPipelineCache PipelineCache;
37  VkDescriptorPool DescriptorPool;
38  uint32_t MinImageCount; // >= 2
39  uint32_t ImageCount; // >= MinImageCount
40  VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT
41  const VkAllocationCallbacks* Allocator;
42  void (*CheckVkResultFn)(VkResult err);
43 };
44 
45 // Called by user code
46 IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
49 IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer);
50 IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
52 IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
53 
54 
55 //-------------------------------------------------------------------------
56 // Internal / Miscellaneous Vulkan Helpers
57 // (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own engine/app.)
58 //-------------------------------------------------------------------------
59 // You probably do NOT need to use or care about those functions.
60 // Those functions only exist because:
61 // 1) they facilitate the readability and maintenance of the multiple main.cpp examples files.
62 // 2) the upcoming multi-viewport feature will need them internally.
63 // Generally we avoid exposing any kind of superfluous high-level helpers in the bindings,
64 // but it is too much code to duplicate everywhere so we exceptionally expose them.
65 //
66 // Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
67 // You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work.
68 // (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions)
69 //-------------------------------------------------------------------------
70 
73 
74 // Helpers
75 IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
76 IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator);
77 IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
78 IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
79 IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
80 
81 // Helper structure to hold the data needed by one rendering frame
82 // (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
83 // [Please zero-clear before use!]
85 {
86  VkCommandPool CommandPool;
87  VkCommandBuffer CommandBuffer;
88  VkFence Fence;
89  VkImage Backbuffer;
90  VkImageView BackbufferView;
91  VkFramebuffer Framebuffer;
92 };
93 
95 {
98 };
99 
100 // Helper structure to hold the data needed by one rendering context into one OS window
101 // (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
103 {
104  int Width;
105  int Height;
106  VkSwapchainKHR Swapchain;
107  VkSurfaceKHR Surface;
108  VkSurfaceFormatKHR SurfaceFormat;
109  VkPresentModeKHR PresentMode;
110  VkRenderPass RenderPass;
112  VkClearValue ClearValue;
113  uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
114  uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
115  uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
118 
120  {
121  memset(this, 0, sizeof(*this));
122  PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
123  ClearEnable = true;
124  }
125 };
126 
ImGui_ImplVulkanH_SelectSurfaceFormat
IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat *request_formats, int request_formats_count, VkColorSpaceKHR request_color_space)
Definition: imgui_impl_vulkan.cpp:870
ImGui_ImplVulkan_Shutdown
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown()
Definition: imgui_impl_vulkan.cpp:831
ImGui_ImplVulkan_InitInfo::PhysicalDevice
VkPhysicalDevice PhysicalDevice
Definition: imgui_impl_vulkan.h:32
ImGui_ImplVulkanH_Frame::Fence
VkFence Fence
Definition: imgui_impl_vulkan.h:88
ImGui_ImplVulkanH_Frame::CommandBuffer
VkCommandBuffer CommandBuffer
Definition: imgui_impl_vulkan.h:87
ImGui_ImplVulkan_InitInfo::MinImageCount
uint32_t MinImageCount
Definition: imgui_impl_vulkan.h:38
ImGui_ImplVulkan_InitInfo
Definition: imgui_impl_vulkan.h:29
ImGui_ImplVulkanH_Window::ClearEnable
bool ClearEnable
Definition: imgui_impl_vulkan.h:111
ImGui_ImplVulkanH_Frame::BackbufferView
VkImageView BackbufferView
Definition: imgui_impl_vulkan.h:90
ImGui_ImplVulkan_SetMinImageCount
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
Definition: imgui_impl_vulkan.cpp:840
ImGui_ImplVulkanH_FrameSemaphores
Definition: imgui_impl_vulkan.h:94
ImGui_ImplVulkan_InitInfo::PipelineCache
VkPipelineCache PipelineCache
Definition: imgui_impl_vulkan.h:36
ImGui_ImplVulkan_InitInfo::DescriptorPool
VkDescriptorPool DescriptorPool
Definition: imgui_impl_vulkan.h:37
ImGui_ImplVulkanH_Window::Surface
VkSurfaceKHR Surface
Definition: imgui_impl_vulkan.h:107
ImGui_ImplVulkanH_FrameSemaphores::RenderCompleteSemaphore
VkSemaphore RenderCompleteSemaphore
Definition: imgui_impl_vulkan.h:97
ImGui_ImplVulkanH_Window::FrameIndex
uint32_t FrameIndex
Definition: imgui_impl_vulkan.h:113
ImGui_ImplVulkanH_SelectPresentMode
IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR *request_modes, int request_modes_count)
Definition: imgui_impl_vulkan.cpp:914
ImGui_ImplVulkanH_Window
Definition: imgui_impl_vulkan.h:102
ImGui_ImplVulkanH_Window::Height
int Height
Definition: imgui_impl_vulkan.h:105
ImGui_ImplVulkan_NewFrame
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame()
Definition: imgui_impl_vulkan.cpp:836
ImGui_ImplVulkanH_Window::RenderPass
VkRenderPass RenderPass
Definition: imgui_impl_vulkan.h:110
ImGui_ImplVulkan_DestroyFontUploadObjects
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects()
Definition: imgui_impl_vulkan.cpp:778
ImDrawData
Definition: imgui.h:2068
ImGui_ImplVulkan_InitInfo::QueueFamily
uint32_t QueueFamily
Definition: imgui_impl_vulkan.h:34
IMGUI_IMPL_API
#define IMGUI_IMPL_API
Definition: imgui.h:73
err
static UPB_NORETURN void err(tarjan *t)
Definition: ruby/ext/google/protobuf_c/upb.c:5856
ImGui_ImplVulkanH_Window::FrameSemaphores
ImGui_ImplVulkanH_FrameSemaphores * FrameSemaphores
Definition: imgui_impl_vulkan.h:117
ImGui_ImplVulkanH_DestroyWindow
IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window *wnd, const VkAllocationCallbacks *allocator)
Definition: imgui_impl_vulkan.cpp:1163
ImGui_ImplVulkanH_Window::SurfaceFormat
VkSurfaceFormatKHR SurfaceFormat
Definition: imgui_impl_vulkan.h:108
ImGui_ImplVulkan_InitInfo::MSAASamples
VkSampleCountFlagBits MSAASamples
Definition: imgui_impl_vulkan.h:40
ImGui_ImplVulkanH_CreateWindow
IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window *wnd, uint32_t queue_family, const VkAllocationCallbacks *allocator, int w, int h, uint32_t min_image_count)
Definition: imgui_impl_vulkan.cpp:1156
void
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
ImGui_ImplVulkan_InitInfo::CheckVkResultFn
void(* CheckVkResultFn)(VkResult err)
Definition: imgui_impl_vulkan.h:42
ImGui_ImplVulkanH_Window::Swapchain
VkSwapchainKHR Swapchain
Definition: imgui_impl_vulkan.h:106
ImGui_ImplVulkan_InitInfo::Allocator
const VkAllocationCallbacks * Allocator
Definition: imgui_impl_vulkan.h:41
ImGui_ImplVulkanH_GetMinImageCountFromPresentMode
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode)
Definition: imgui_impl_vulkan.cpp:983
ImGui_ImplVulkan_InitInfo::Device
VkDevice Device
Definition: imgui_impl_vulkan.h:33
ImGui_ImplVulkanH_Window::Width
int Width
Definition: imgui_impl_vulkan.h:104
ImGui_ImplVulkan_CreateFontsTexture
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)
Definition: imgui_impl_vulkan.cpp:435
ImGui_ImplVulkanH_Frame::Framebuffer
VkFramebuffer Framebuffer
Definition: imgui_impl_vulkan.h:91
ImGui_ImplVulkanH_Window::ImGui_ImplVulkanH_Window
ImGui_ImplVulkanH_Window()
Definition: imgui_impl_vulkan.h:119
ImGui_ImplVulkanH_Frame::CommandPool
VkCommandPool CommandPool
Definition: imgui_impl_vulkan.h:86
ImGui_ImplVulkanH_Window::SemaphoreIndex
uint32_t SemaphoreIndex
Definition: imgui_impl_vulkan.h:115
ImGui_ImplVulkanH_Window::Frames
ImGui_ImplVulkanH_Frame * Frames
Definition: imgui_impl_vulkan.h:116
ImGui_ImplVulkanH_Window::ImageCount
uint32_t ImageCount
Definition: imgui_impl_vulkan.h:114
ImGui_ImplVulkan_RenderDrawData
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData *draw_data, VkCommandBuffer command_buffer)
Definition: imgui_impl_vulkan.cpp:312
ImGui_ImplVulkan_InitInfo::Queue
VkQueue Queue
Definition: imgui_impl_vulkan.h:35
ImGui_ImplVulkanH_Window::PresentMode
VkPresentModeKHR PresentMode
Definition: imgui_impl_vulkan.h:109
w
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:3126
ImGui_ImplVulkanH_Window::ClearValue
VkClearValue ClearValue
Definition: imgui_impl_vulkan.h:112
ImGui_ImplVulkan_InitInfo::Instance
VkInstance Instance
Definition: imgui_impl_vulkan.h:31
ImGui_ImplVulkan_InitInfo::ImageCount
uint32_t ImageCount
Definition: imgui_impl_vulkan.h:39
ImGui_ImplVulkan_Init
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo *info, VkRenderPass render_pass)
Definition: imgui_impl_vulkan.cpp:808
h
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:4147
ImGui_ImplVulkanH_FrameSemaphores::ImageAcquiredSemaphore
VkSemaphore ImageAcquiredSemaphore
Definition: imgui_impl_vulkan.h:96
ImGui_ImplVulkanH_Frame::Backbuffer
VkImage Backbuffer
Definition: imgui_impl_vulkan.h:89
ImGui_ImplVulkanH_Frame
Definition: imgui_impl_vulkan.h:84


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:54