source: opengl-game/IMGUI/imgui_impl_vulkan.h@ ce9dc9f

feature/imgui-sdl
Last change on this file since ce9dc9f was ce9dc9f, checked in by Dmitry Portnoy <dportnoy@…>, 4 years ago

Remove all dependencies on VulkanH functions and structures from SDLGame

  • Property mode set to 100644
File size: 7.1 KB
Line 
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#include "imgui.h" // IMGUI_IMPL_API
25#include <vulkan/vulkan.h>
26
27// Initialization data, for ImGui_ImplVulkan_Init()
28// [Please zero-clear before use!]
29struct ImGui_ImplVulkan_InitInfo
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
46IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
47IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
48IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
49IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
50IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
51IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
52IMGUI_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
71struct ImGui_ImplVulkanH_Frame;
72struct ImGui_ImplVulkanH_Window;
73
74// Helpers
75IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateOrResizeWindow(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);
76IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator);
77IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
78IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
79IMGUI_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!]
84struct ImGui_ImplVulkanH_Frame
85{
86 VkCommandPool CommandPool;
87 VkCommandBuffer CommandBuffer;
88 VkFence Fence;
89 VkImage Backbuffer;
90 VkImageView BackbufferView;
91 VkFramebuffer Framebuffer;
92};
93
94struct ImGui_ImplVulkanH_FrameSemaphores
95{
96 VkSemaphore ImageAcquiredSemaphore;
97 VkSemaphore RenderCompleteSemaphore;
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.)
102struct ImGui_ImplVulkanH_Window
103{
104 int Width;
105 int Height;
106 VkSwapchainKHR Swapchain;
107 VkSurfaceKHR Surface;
108 VkSurfaceFormatKHR SurfaceFormat;
109 VkPresentModeKHR PresentMode;
110 VkRenderPass RenderPass;
111 VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
112 bool ClearEnable;
113 VkClearValue ClearValue;
114 uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
115 uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
116 uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
117 ImGui_ImplVulkanH_Frame* Frames;
118 ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
119
120 ImGui_ImplVulkanH_Window()
121 {
122 memset(this, 0, sizeof(*this));
123 PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
124 ClearEnable = true;
125 }
126};
127
Note: See TracBrowser for help on using the repository browser.