mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-05 20:48:46 +02:00
Merge branch 'examples_refactor2' into viewport (#1870)
# Conflicts: # examples/README.txt # examples/directx11_example/main.cpp # examples/directx12_example/main.cpp # examples/imgui_impl_dx10.cpp # examples/imgui_impl_dx11.cpp # examples/imgui_impl_dx12.cpp # examples/imgui_impl_glfw.cpp # examples/imgui_impl_opengl2.cpp # examples/imgui_impl_opengl2.h # examples/imgui_impl_opengl3.cpp # examples/imgui_impl_sdl2.cpp # examples/imgui_impl_sdl2.h # examples/imgui_impl_vulkan.cpp # examples/imgui_impl_vulkan.h # examples/imgui_impl_win32.cpp # examples/imgui_impl_win32.h # examples/opengl2_example/main.cpp # examples/opengl3_example/main.cpp # examples/sdl_opengl2_example/main.cpp # examples/sdl_opengl3_example/main.cpp # examples/sdl_vulkan_example/main.cpp # examples/vulkan_example/main.cpp # imgui.cpp # imgui.h
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
|
||||
// Missing features:
|
||||
// [ ] User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
|
||||
// [ ] Multi-viewport rendering (when ImGuiConfigFlags_ViewportsEnable is enabled). WORK-IN-PROGRESS.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you use this binding you'll need to call 5 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXX_CreateFontsTexture(), ImGui_ImplXXXX_NewFrame(), ImGui_ImplXXXX_Render() and ImGui_ImplXXXX_Shutdown().
|
||||
@ -12,10 +11,10 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_vulkan.cpp/.h away from the old combined GLFW+Vulkan example.
|
||||
// 2018-06-08: Vulkan: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
// 2018-03-03: Vulkan: Various refactor, created a couple of ImGui_ImplVulkanH_XXX helper that the example can use and that viewport support will use.
|
||||
// 2018-03-01: Vulkan: Renamed ImGui_ImplVulkan_Init_Info to ImGui_ImplVulkan_InitInfo and fields to match more closely Vulkan terminology.
|
||||
// 2018-02-18: Vulkan: Offset projection matrix and clipping rectangle by draw_data->DisplayPos (which will be non-zero for multi-viewport applications).
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback, ImGui_ImplVulkan_Render() calls ImGui_ImplVulkan_RenderDrawData() itself.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
// 2017-05-15: Vulkan: Fix scissor offset being negative. Fix new Vulkan validation warnings. Set required depth member for buffer image copy.
|
||||
@ -39,13 +38,13 @@ static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
|
||||
static VkRenderPass g_RenderPass = VK_NULL_HANDLE;
|
||||
static void (*g_CheckVkResultFn)(VkResult err) = NULL;
|
||||
|
||||
static VkDeviceSize g_BufferMemoryAlignment = 256;
|
||||
static VkPipelineCreateFlags g_PipelineCreateFlags = 0;
|
||||
static VkDeviceSize g_BufferMemoryAlignment = 256;
|
||||
static VkPipelineCreateFlags g_PipelineCreateFlags = 0;
|
||||
|
||||
static VkDescriptorSetLayout g_DescriptorSetLayout = VK_NULL_HANDLE;
|
||||
static VkPipelineLayout g_PipelineLayout = VK_NULL_HANDLE;
|
||||
static VkDescriptorSet g_DescriptorSet = VK_NULL_HANDLE;
|
||||
static VkPipeline g_Pipeline = VK_NULL_HANDLE;
|
||||
static VkDescriptorSetLayout g_DescriptorSetLayout = VK_NULL_HANDLE;
|
||||
static VkPipelineLayout g_PipelineLayout = VK_NULL_HANDLE;
|
||||
static VkDescriptorSet g_DescriptorSet = VK_NULL_HANDLE;
|
||||
static VkPipeline g_Pipeline = VK_NULL_HANDLE;
|
||||
|
||||
// Frame data
|
||||
struct FrameDataForRender
|
||||
@ -273,7 +272,7 @@ void ImGui_ImplVulkan_RenderDrawData(VkCommandBuffer command_buffer, ImDrawData*
|
||||
}
|
||||
|
||||
// Setup scale and translation:
|
||||
// Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps.
|
||||
// Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is (0,0) for single viewport apps.
|
||||
{
|
||||
float scale[2];
|
||||
scale[0] = 2.0f / draw_data->DisplaySize.x;
|
||||
@ -740,7 +739,7 @@ void ImGui_ImplVulkan_NewFrame()
|
||||
|
||||
#include <stdlib.h> // malloc
|
||||
|
||||
ImGui_ImplVulkan_FrameData::ImGui_ImplVulkan_FrameData()
|
||||
ImGui_ImplVulkanH_FrameData::ImGui_ImplVulkanH_FrameData()
|
||||
{
|
||||
BackbufferIndex = 0;
|
||||
CommandPool = VK_NULL_HANDLE;
|
||||
@ -750,7 +749,7 @@ ImGui_ImplVulkan_FrameData::ImGui_ImplVulkan_FrameData()
|
||||
RenderCompleteSemaphore = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
ImGui_ImplVulkan_WindowData::ImGui_ImplVulkan_WindowData()
|
||||
ImGui_ImplVulkanH_WindowData::ImGui_ImplVulkanH_WindowData()
|
||||
{
|
||||
Width = Height = 0;
|
||||
Swapchain = VK_NULL_HANDLE;
|
||||
@ -830,7 +829,7 @@ VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_d
|
||||
return VK_PRESENT_MODE_FIFO_KHR; // Always available
|
||||
}
|
||||
|
||||
void ImGui_ImplVulkanH_CreateWindowDataCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, uint32_t queue_family, ImGui_ImplVulkan_WindowData* wd, const VkAllocationCallbacks* allocator)
|
||||
void ImGui_ImplVulkanH_CreateWindowDataCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, uint32_t queue_family, ImGui_ImplVulkanH_WindowData* wd, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
IM_ASSERT(physical_device != NULL && device != NULL);
|
||||
(void)allocator;
|
||||
@ -839,7 +838,7 @@ void ImGui_ImplVulkanH_CreateWindowDataCommandBuffers(VkPhysicalDevice physical_
|
||||
VkResult err;
|
||||
for (int i = 0; i < IMGUI_VK_QUEUED_FRAMES; i++)
|
||||
{
|
||||
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[i];
|
||||
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[i];
|
||||
{
|
||||
VkCommandPoolCreateInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||
@ -887,7 +886,7 @@ int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_m
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkan_WindowData* wd, const VkAllocationCallbacks* allocator, int w, int h)
|
||||
void ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_WindowData* wd, const VkAllocationCallbacks* allocator, int w, int h)
|
||||
{
|
||||
uint32_t min_image_count = 2; // FIXME: this should become a function parameter
|
||||
|
||||
@ -1033,14 +1032,14 @@ void ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(VkPhysicalDevice
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui_ImplVulkanH_DestroyWindowData(VkInstance instance, VkDevice device, ImGui_ImplVulkan_WindowData* wd, const VkAllocationCallbacks* allocator)
|
||||
void ImGui_ImplVulkanH_DestroyWindowData(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_WindowData* wd, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
vkDeviceWaitIdle(device); // FIXME: We could wait on the Queue if we had the queue in wd-> (otherwise VulkanH functions can't use globals)
|
||||
//vkQueueWaitIdle(g_Queue);
|
||||
|
||||
for (int i = 0; i < IMGUI_VK_QUEUED_FRAMES; i++)
|
||||
{
|
||||
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[i];
|
||||
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[i];
|
||||
vkDestroyFence(device, fd->Fence, allocator);
|
||||
vkFreeCommandBuffers(device, fd->CommandPool, 1, &fd->CommandBuffer);
|
||||
vkDestroyCommandPool(device, fd->CommandPool, allocator);
|
||||
@ -1055,7 +1054,7 @@ void ImGui_ImplVulkanH_DestroyWindowData(VkInstance instance, VkDevice device, I
|
||||
vkDestroyRenderPass(device, wd->RenderPass, allocator);
|
||||
vkDestroySwapchainKHR(device, wd->Swapchain, allocator);
|
||||
vkDestroySurfaceKHR(instance, wd->Surface, allocator);
|
||||
*wd = ImGui_ImplVulkan_WindowData();
|
||||
*wd = ImGui_ImplVulkanH_WindowData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
@ -1068,7 +1067,7 @@ void ImGui_ImplVulkanH_DestroyWindowData(VkInstance instance, VkDevice device, I
|
||||
|
||||
struct ImGuiViewportDataVulkan
|
||||
{
|
||||
ImGui_ImplVulkan_WindowData WindowData;
|
||||
ImGui_ImplVulkanH_WindowData WindowData;
|
||||
|
||||
ImGuiViewportDataVulkan() { }
|
||||
~ImGuiViewportDataVulkan() { }
|
||||
@ -1078,7 +1077,7 @@ static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiViewportDataVulkan* data = IM_NEW(ImGuiViewportDataVulkan)();
|
||||
viewport->RendererUserData = data;
|
||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||
ImGui_ImplVulkanH_WindowData* wd = &data->WindowData;
|
||||
|
||||
// Create surface
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
@ -1132,11 +1131,11 @@ static void ImGui_ImplVulkan_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
|
||||
{
|
||||
ImGuiViewportDataVulkan* data = (ImGuiViewportDataVulkan*)viewport->RendererUserData;
|
||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||
ImGui_ImplVulkanH_WindowData* wd = &data->WindowData;
|
||||
VkResult err;
|
||||
|
||||
{
|
||||
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[wd->FrameIndex];
|
||||
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
|
||||
for (;;)
|
||||
{
|
||||
err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, 100);
|
||||
@ -1176,7 +1175,7 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
|
||||
ImGui_ImplVulkan_RenderDrawData(wd->Frames[wd->FrameIndex].CommandBuffer, viewport->DrawData);
|
||||
|
||||
{
|
||||
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[wd->FrameIndex];
|
||||
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
|
||||
vkCmdEndRenderPass(fd->CommandBuffer);
|
||||
{
|
||||
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
@ -1203,12 +1202,12 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
|
||||
static void ImGui_ImplVulkan_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||
{
|
||||
ImGuiViewportDataVulkan* data = (ImGuiViewportDataVulkan*)viewport->RendererUserData;
|
||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||
ImGui_ImplVulkanH_WindowData* wd = &data->WindowData;
|
||||
|
||||
VkResult err;
|
||||
uint32_t PresentIndex = wd->FrameIndex;
|
||||
|
||||
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[PresentIndex];
|
||||
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[PresentIndex];
|
||||
VkPresentInfoKHR info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||
info.waitSemaphoreCount = 1;
|
||||
|
Reference in New Issue
Block a user