mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-07 14:51:22 +01:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_glfw.cpp # backends/imgui_impl_vulkan.cpp
This commit is contained in:
commit
e3d7cd665d
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014-2023 Omar Cornut
|
Copyright (c) 2014-2024 Omar Cornut
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -648,9 +648,9 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
|
|
||||||
// Windows: register a WndProc hook so we can intercept some messages.
|
// Windows: register a WndProc hook so we can intercept some messages.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
bd->PrevWndProc = (WNDPROC)::GetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC);
|
bd->PrevWndProc = (WNDPROC)::GetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC);
|
||||||
IM_ASSERT(bd->PrevWndProc != nullptr);
|
IM_ASSERT(bd->PrevWndProc != nullptr);
|
||||||
::SetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bd->ClientApi = client_api;
|
bd->ClientApi = client_api;
|
||||||
@ -692,7 +692,7 @@ void ImGui_ImplGlfw_Shutdown()
|
|||||||
// Windows: restore our WndProc hook
|
// Windows: restore our WndProc hook
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
::SetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->PrevWndProc);
|
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->PrevWndProc);
|
||||||
bd->PrevWndProc = nullptr;
|
bd->PrevWndProc = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1117,8 +1117,8 @@ static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport)
|
|||||||
// GLFW hack: install hook for WM_NCHITTEST message handler
|
// GLFW hack: install hook for WM_NCHITTEST message handler
|
||||||
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
|
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
|
||||||
::SetPropA(hwnd, "IMGUI_VIEWPORT", viewport);
|
::SetPropA(hwnd, "IMGUI_VIEWPORT", viewport);
|
||||||
vd->PrevWndProc = (WNDPROC)::GetWindowLongPtr(hwnd, GWLP_WNDPROC);
|
vd->PrevWndProc = (WNDPROC)::GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
|
||||||
::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
::SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !GLFW_HAS_FOCUS_ON_SHOW
|
#if !GLFW_HAS_FOCUS_ON_SHOW
|
||||||
@ -1352,7 +1352,7 @@ static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wPara
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return ::CallWindowProc(prev_wndproc, hWnd, msg, wParam, lParam);
|
return ::CallWindowProcW(prev_wndproc, hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
#endif // #ifdef _WIN32
|
#endif // #ifdef _WIN32
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2023-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2023-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2024-01-03: Vulkan: Added MinAllocationSize field in ImGui_ImplVulkan_InitInfo to workaround zealous "best practice" validation layer. (#7189, #4238)
|
||||||
|
// 2024-01-03: Vulkan: Stoped creating command pools with VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT as we don't reset them.
|
||||||
// 2023-11-29: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs vkDestroyCommandPool(). (#7075)
|
// 2023-11-29: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs vkDestroyCommandPool(). (#7075)
|
||||||
// 2023-11-10: *BREAKING CHANGE*: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own command-buffer to upload fonts.
|
// 2023-11-10: *BREAKING CHANGE*: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own command-buffer to upload fonts.
|
||||||
// *BREAKING CHANGE*: Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unecessary as we create and destroy those objects in the backend.
|
// *BREAKING CHANGE*: Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unecessary as we create and destroy those objects in the backend.
|
||||||
@ -81,79 +83,18 @@
|
|||||||
#ifndef IMGUI_DISABLE
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_vulkan.h"
|
#include "imgui_impl_vulkan.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifndef IM_MAX
|
||||||
|
#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B))
|
||||||
|
#endif
|
||||||
|
|
||||||
// Visual Studio warnings
|
// Visual Studio warnings
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (disable: 4127) // condition expression is constant
|
#pragma warning (disable: 4127) // condition expression is constant
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData()
|
|
||||||
// [Please zero-clear before use!]
|
|
||||||
struct ImGui_ImplVulkanH_FrameRenderBuffers
|
|
||||||
{
|
|
||||||
VkDeviceMemory VertexBufferMemory;
|
|
||||||
VkDeviceMemory IndexBufferMemory;
|
|
||||||
VkDeviceSize VertexBufferSize;
|
|
||||||
VkDeviceSize IndexBufferSize;
|
|
||||||
VkBuffer VertexBuffer;
|
|
||||||
VkBuffer IndexBuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Each viewport will hold 1 ImGui_ImplVulkanH_WindowRenderBuffers
|
|
||||||
// [Please zero-clear before use!]
|
|
||||||
struct ImGui_ImplVulkanH_WindowRenderBuffers
|
|
||||||
{
|
|
||||||
uint32_t Index;
|
|
||||||
uint32_t Count;
|
|
||||||
ImGui_ImplVulkanH_FrameRenderBuffers* FrameRenderBuffers;
|
|
||||||
};
|
|
||||||
|
|
||||||
// For multi-viewport support:
|
|
||||||
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
|
||||||
struct ImGui_ImplVulkan_ViewportData
|
|
||||||
{
|
|
||||||
bool WindowOwned;
|
|
||||||
ImGui_ImplVulkanH_Window Window; // Used by secondary viewports only
|
|
||||||
ImGui_ImplVulkanH_WindowRenderBuffers RenderBuffers; // Used by all viewports
|
|
||||||
|
|
||||||
ImGui_ImplVulkan_ViewportData() { WindowOwned = false; memset(&RenderBuffers, 0, sizeof(RenderBuffers)); }
|
|
||||||
~ImGui_ImplVulkan_ViewportData() { }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Vulkan data
|
|
||||||
struct ImGui_ImplVulkan_Data
|
|
||||||
{
|
|
||||||
ImGui_ImplVulkan_InitInfo VulkanInitInfo;
|
|
||||||
VkRenderPass RenderPass;
|
|
||||||
VkDeviceSize BufferMemoryAlignment;
|
|
||||||
VkPipelineCreateFlags PipelineCreateFlags;
|
|
||||||
VkDescriptorSetLayout DescriptorSetLayout;
|
|
||||||
VkPipelineLayout PipelineLayout;
|
|
||||||
VkPipeline Pipeline;
|
|
||||||
uint32_t Subpass;
|
|
||||||
VkShaderModule ShaderModuleVert;
|
|
||||||
VkShaderModule ShaderModuleFrag;
|
|
||||||
|
|
||||||
// Font data
|
|
||||||
VkSampler FontSampler;
|
|
||||||
VkDeviceMemory FontMemory;
|
|
||||||
VkImage FontImage;
|
|
||||||
VkImageView FontView;
|
|
||||||
VkDescriptorSet FontDescriptorSet;
|
|
||||||
VkCommandPool FontCommandPool;
|
|
||||||
VkCommandBuffer FontCommandBuffer;
|
|
||||||
|
|
||||||
// Render buffers for main window
|
|
||||||
ImGui_ImplVulkanH_WindowRenderBuffers MainWindowRenderBuffers;
|
|
||||||
|
|
||||||
ImGui_ImplVulkan_Data()
|
|
||||||
{
|
|
||||||
memset((void*)this, 0, sizeof(*this));
|
|
||||||
BufferMemoryAlignment = 256;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
|
struct ImGui_ImplVulkanH_FrameRenderBuffers;
|
||||||
|
struct ImGui_ImplVulkanH_WindowRenderBuffers;
|
||||||
bool ImGui_ImplVulkan_CreateDeviceObjects();
|
bool ImGui_ImplVulkan_CreateDeviceObjects();
|
||||||
void ImGui_ImplVulkan_DestroyDeviceObjects();
|
void ImGui_ImplVulkan_DestroyDeviceObjects();
|
||||||
void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
|
||||||
@ -257,6 +198,72 @@ static PFN_vkCmdBeginRenderingKHR ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR;
|
|||||||
static PFN_vkCmdEndRenderingKHR ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR;
|
static PFN_vkCmdEndRenderingKHR ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData()
|
||||||
|
// [Please zero-clear before use!]
|
||||||
|
struct ImGui_ImplVulkanH_FrameRenderBuffers
|
||||||
|
{
|
||||||
|
VkDeviceMemory VertexBufferMemory;
|
||||||
|
VkDeviceMemory IndexBufferMemory;
|
||||||
|
VkDeviceSize VertexBufferSize;
|
||||||
|
VkDeviceSize IndexBufferSize;
|
||||||
|
VkBuffer VertexBuffer;
|
||||||
|
VkBuffer IndexBuffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Each viewport will hold 1 ImGui_ImplVulkanH_WindowRenderBuffers
|
||||||
|
// [Please zero-clear before use!]
|
||||||
|
struct ImGui_ImplVulkanH_WindowRenderBuffers
|
||||||
|
{
|
||||||
|
uint32_t Index;
|
||||||
|
uint32_t Count;
|
||||||
|
ImGui_ImplVulkanH_FrameRenderBuffers* FrameRenderBuffers;
|
||||||
|
};
|
||||||
|
|
||||||
|
// For multi-viewport support:
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplVulkan_ViewportData
|
||||||
|
{
|
||||||
|
bool WindowOwned;
|
||||||
|
ImGui_ImplVulkanH_Window Window; // Used by secondary viewports only
|
||||||
|
ImGui_ImplVulkanH_WindowRenderBuffers RenderBuffers; // Used by all viewports
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_ViewportData() { WindowOwned = false; memset(&RenderBuffers, 0, sizeof(RenderBuffers)); }
|
||||||
|
~ImGui_ImplVulkan_ViewportData() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Vulkan data
|
||||||
|
struct ImGui_ImplVulkan_Data
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_InitInfo VulkanInitInfo;
|
||||||
|
VkRenderPass RenderPass;
|
||||||
|
VkDeviceSize BufferMemoryAlignment;
|
||||||
|
VkPipelineCreateFlags PipelineCreateFlags;
|
||||||
|
VkDescriptorSetLayout DescriptorSetLayout;
|
||||||
|
VkPipelineLayout PipelineLayout;
|
||||||
|
VkPipeline Pipeline;
|
||||||
|
uint32_t Subpass;
|
||||||
|
VkShaderModule ShaderModuleVert;
|
||||||
|
VkShaderModule ShaderModuleFrag;
|
||||||
|
|
||||||
|
// Font data
|
||||||
|
VkSampler FontSampler;
|
||||||
|
VkDeviceMemory FontMemory;
|
||||||
|
VkImage FontImage;
|
||||||
|
VkImageView FontView;
|
||||||
|
VkDescriptorSet FontDescriptorSet;
|
||||||
|
VkCommandPool FontCommandPool;
|
||||||
|
VkCommandBuffer FontCommandBuffer;
|
||||||
|
|
||||||
|
// Render buffers for main window
|
||||||
|
ImGui_ImplVulkanH_WindowRenderBuffers MainWindowRenderBuffers;
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_Data()
|
||||||
|
{
|
||||||
|
memset((void*)this, 0, sizeof(*this));
|
||||||
|
BufferMemoryAlignment = 256;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// SHADERS
|
// SHADERS
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -265,7 +272,7 @@ static PFN_vkCmdEndRenderingKHR ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR;
|
|||||||
static void ImGui_ImplVulkan_InitPlatformInterface();
|
static void ImGui_ImplVulkan_InitPlatformInterface();
|
||||||
static void ImGui_ImplVulkan_ShutdownPlatformInterface();
|
static void ImGui_ImplVulkan_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// glsl_shader.vert, compiled with:
|
// backends/vulkan/glsl_shader.vert, compiled with:
|
||||||
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
|
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
|
||||||
/*
|
/*
|
||||||
#version 450 core
|
#version 450 core
|
||||||
@ -329,7 +336,7 @@ static uint32_t __glsl_shader_vert_spv[] =
|
|||||||
0x0000002d,0x0000002c,0x000100fd,0x00010038
|
0x0000002d,0x0000002c,0x000100fd,0x00010038
|
||||||
};
|
};
|
||||||
|
|
||||||
// glsl_shader.frag, compiled with:
|
// backends/vulkan/glsl_shader.frag, compiled with:
|
||||||
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
|
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
|
||||||
/*
|
/*
|
||||||
#version 450 core
|
#version 450 core
|
||||||
@ -426,16 +433,17 @@ static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory
|
|||||||
VkMemoryRequirements req;
|
VkMemoryRequirements req;
|
||||||
vkGetBufferMemoryRequirements(v->Device, buffer, &req);
|
vkGetBufferMemoryRequirements(v->Device, buffer, &req);
|
||||||
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
||||||
|
VkDeviceSize size = IM_MAX(v->MinAllocationSize, req.size);
|
||||||
VkMemoryAllocateInfo alloc_info = {};
|
VkMemoryAllocateInfo alloc_info = {};
|
||||||
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||||
alloc_info.allocationSize = req.size;
|
alloc_info.allocationSize = size;
|
||||||
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
||||||
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &buffer_memory);
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &buffer_memory);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
|
err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
p_buffer_size = req.size;
|
p_buffer_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
||||||
@ -524,9 +532,9 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
// Upload vertex/index data into a single contiguous GPU buffer
|
// Upload vertex/index data into a single contiguous GPU buffer
|
||||||
ImDrawVert* vtx_dst = nullptr;
|
ImDrawVert* vtx_dst = nullptr;
|
||||||
ImDrawIdx* idx_dst = nullptr;
|
ImDrawIdx* idx_dst = nullptr;
|
||||||
VkResult err = vkMapMemory(v->Device, rb->VertexBufferMemory, 0, rb->VertexBufferSize, 0, (void**)(&vtx_dst));
|
VkResult err = vkMapMemory(v->Device, rb->VertexBufferMemory, 0, rb->VertexBufferSize, 0, (void**)&vtx_dst);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, rb->IndexBufferSize, 0, (void**)(&idx_dst));
|
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, rb->IndexBufferSize, 0, (void**)&idx_dst);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
@ -645,7 +653,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
|||||||
{
|
{
|
||||||
VkCommandPoolCreateInfo info = {};
|
VkCommandPoolCreateInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
info.flags = 0;
|
||||||
info.queueFamilyIndex = v->QueueFamily;
|
info.queueFamilyIndex = v->QueueFamily;
|
||||||
vkCreateCommandPool(v->Device, &info, v->Allocator, &bd->FontCommandPool);
|
vkCreateCommandPool(v->Device, &info, v->Allocator, &bd->FontCommandPool);
|
||||||
}
|
}
|
||||||
@ -697,7 +705,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
|||||||
vkGetImageMemoryRequirements(v->Device, bd->FontImage, &req);
|
vkGetImageMemoryRequirements(v->Device, bd->FontImage, &req);
|
||||||
VkMemoryAllocateInfo alloc_info = {};
|
VkMemoryAllocateInfo alloc_info = {};
|
||||||
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||||
alloc_info.allocationSize = req.size;
|
alloc_info.allocationSize = IM_MAX(v->MinAllocationSize, req.size);
|
||||||
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits);
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits);
|
||||||
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &bd->FontMemory);
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &bd->FontMemory);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
@ -738,7 +746,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
|||||||
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
||||||
VkMemoryAllocateInfo alloc_info = {};
|
VkMemoryAllocateInfo alloc_info = {};
|
||||||
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||||
alloc_info.allocationSize = req.size;
|
alloc_info.allocationSize = IM_MAX(v->MinAllocationSize, req.size);
|
||||||
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
||||||
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &upload_buffer_memory);
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &upload_buffer_memory);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
@ -1332,7 +1340,7 @@ void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_devi
|
|||||||
{
|
{
|
||||||
VkCommandPoolCreateInfo info = {};
|
VkCommandPoolCreateInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
info.flags = 0;
|
||||||
info.queueFamilyIndex = queue_family;
|
info.queueFamilyIndex = queue_family;
|
||||||
err = vkCreateCommandPool(device, &info, allocator, &fd->CommandPool);
|
err = vkCreateCommandPool(device, &info, allocator, &fd->CommandPool);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
@ -72,6 +72,7 @@ struct ImGui_ImplVulkan_InitInfo
|
|||||||
// Allocation, Debugging
|
// Allocation, Debugging
|
||||||
const VkAllocationCallbacks* Allocator;
|
const VkAllocationCallbacks* Allocator;
|
||||||
void (*CheckVkResultFn)(VkResult err);
|
void (*CheckVkResultFn)(VkResult err);
|
||||||
|
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called by user code
|
// Called by user code
|
||||||
|
@ -331,7 +331,9 @@ static void ImGui_ImplWGPU_SetupRenderState(ImDrawData* draw_data, WGPURenderPas
|
|||||||
void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder)
|
void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized
|
// Avoid rendering when minimized
|
||||||
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdListsCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: Assuming that this only gets called once per frame!
|
// FIXME: Assuming that this only gets called once per frame!
|
||||||
@ -450,6 +452,12 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
// Project scissor/clipping rectangles into framebuffer space
|
// Project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
||||||
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
||||||
|
|
||||||
|
// Clamp to viewport as wgpuRenderPassEncoderSetScissorRect() won't accept values that are off bounds
|
||||||
|
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
||||||
|
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
||||||
|
if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; }
|
||||||
|
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
||||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -70,11 +70,16 @@ Other changes:
|
|||||||
- InputTextMultiline: Tabbing through a multi-line text editor which allows Tab character inputs
|
- InputTextMultiline: Tabbing through a multi-line text editor which allows Tab character inputs
|
||||||
(using the ImGuiInputTextFlags_AllowTabInput flag) doesn't automatically activate it, in order
|
(using the ImGuiInputTextFlags_AllowTabInput flag) doesn't automatically activate it, in order
|
||||||
to allow passing through multiple widgets easily. (#3092, #5759, #787)
|
to allow passing through multiple widgets easily. (#3092, #5759, #787)
|
||||||
|
- Drags, Sliders, Inputs: removed all attempts to filter non-numerical characters during text
|
||||||
|
editing. Invalid inputs not applied to value, visibly reverted after validation. (#6810, #7096)
|
||||||
|
- Drags, Sliders, Inputs: removal of filter means that "nan" and "inf" values may be input. (#7096)
|
||||||
- DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components
|
- DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components
|
||||||
width computation to better distribute the error. (#7120, #7121) [@Nahor]
|
width computation to better distribute the error. (#7120, #7121) [@Nahor]
|
||||||
- ColorEdit4: Layout tweaks for very small sizes. (#7120, #7121)
|
- ColorEdit4: Layout tweaks for very small sizes. (#7120, #7121)
|
||||||
- Menus: Tweaked hover slack logic, adding a timer to avoid situations where a slow vertical
|
- Menus: Tweaked hover slack logic, adding a timer to avoid situations where a slow vertical
|
||||||
movements toward another parent BeginMenu() can keep the wrong child menu open. (#6671, #6926)
|
movements toward another parent BeginMenu() can keep the wrong child menu open. (#6671, #6926)
|
||||||
|
- Settings: Fixed an issue marking settings as dirty when merely clicking on a border or resize
|
||||||
|
grip without moving it.
|
||||||
- Debug Tools: Added DebugFlashStyleColor() to identify a style color. Added to Style Editor.
|
- Debug Tools: Added DebugFlashStyleColor() to identify a style color. Added to Style Editor.
|
||||||
- Debug Tools: Debug Log: Hide its own clipper log to reduce noise in the output.
|
- Debug Tools: Debug Log: Hide its own clipper log to reduce noise in the output.
|
||||||
- Misc: Added IMGUI_USER_H_FILENAME to change the path included when using
|
- Misc: Added IMGUI_USER_H_FILENAME to change the path included when using
|
||||||
@ -86,10 +91,20 @@ Other changes:
|
|||||||
like most printf implementations. (#7016, #3466, #6846) [@codefrog2002]
|
like most printf implementations. (#7016, #3466, #6846) [@codefrog2002]
|
||||||
- Misc: Renamed some defines in imstb_textedit.h to avoid conflicts when using unity/jumbo builds
|
- Misc: Renamed some defines in imstb_textedit.h to avoid conflicts when using unity/jumbo builds
|
||||||
on a codebase where another copy of the library is used.
|
on a codebase where another copy of the library is used.
|
||||||
|
- Misc: During shutdown, check that io.BackendPlatformUserData and io.BackendRendererUserData are NULL
|
||||||
|
in order to catch cases where backend was not shut down. (#7175)
|
||||||
- Backends: GLFW, Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to
|
- Backends: GLFW, Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to
|
||||||
register canvas selector and auto-resize GLFW window. (#6751) [@Traveller23, @ypujante]
|
register canvas selector and auto-resize GLFW window. (#6751) [@Traveller23, @ypujante]
|
||||||
|
- Backends: GLFW: Fixed Windows specific hooks to use Unicode version of WndProc even when
|
||||||
|
compiling in MBCS mode. (#7174) [@kimidaisuki22]
|
||||||
- Backends: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs
|
- Backends: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs
|
||||||
vkDestroyCommandPool(). (#7075) [@FoonTheRaccoon]
|
vkDestroyCommandPool(). (#7075) [@FoonTheRaccoon]
|
||||||
|
- Backends: Vulkan: Added MinAllocationSize field in ImGui_ImplVulkan_InitInfo to workaround zealous
|
||||||
|
"best practice" validation layer. (#7189, #4238) [@philae-ael]
|
||||||
|
- Backends: Vulkan: Stopped creating command pools with VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
|
||||||
|
as we don't reset them.
|
||||||
|
- Backends: WebGPU: Fixed wgpuRenderPassEncoderSetScissorRect() crash when rendering modal
|
||||||
|
window's dimming layer, which has an unclipped value in ImDrawCmd::ClipRect. (#7191) [@aparis69]
|
||||||
- Examples: GLFW+Emscripten: Fixed examples not consistently resizing according to host canvas.
|
- Examples: GLFW+Emscripten: Fixed examples not consistently resizing according to host canvas.
|
||||||
(#6751) [@Traveller23, @ypujante]
|
(#6751) [@Traveller23, @ypujante]
|
||||||
|
|
||||||
|
19
imgui.cpp
19
imgui.cpp
@ -21,7 +21,7 @@
|
|||||||
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
||||||
// Everything else should be asked in 'Issues'! We are building a database of cross-linked knowledge there.
|
// Everything else should be asked in 'Issues'! We are building a database of cross-linked knowledge there.
|
||||||
|
|
||||||
// Copyright (c) 2014-2023 Omar Cornut
|
// Copyright (c) 2014-2024 Omar Cornut
|
||||||
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
|
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
|
||||||
// See LICENSE.txt for copyright and licensing details (standard MIT License).
|
// See LICENSE.txt for copyright and licensing details (standard MIT License).
|
||||||
// This library is free but needs your support to sustain development and maintenance.
|
// This library is free but needs your support to sustain development and maintenance.
|
||||||
@ -3682,8 +3682,11 @@ void ImGui::Initialize()
|
|||||||
// This function is merely here to free heap allocations.
|
// This function is merely here to free heap allocations.
|
||||||
void ImGui::Shutdown()
|
void ImGui::Shutdown()
|
||||||
{
|
{
|
||||||
// The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame)
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
IM_ASSERT_USER_ERROR(g.IO.BackendPlatformUserData == NULL, "Forgot to shutdown Platform backend?");
|
||||||
|
IM_ASSERT_USER_ERROR(g.IO.BackendRendererUserData == NULL, "Forgot to shutdown Renderer backend?");
|
||||||
|
|
||||||
|
// The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame)
|
||||||
if (g.IO.Fonts && g.FontAtlasOwnedByContext)
|
if (g.IO.Fonts && g.FontAtlasOwnedByContext)
|
||||||
{
|
{
|
||||||
g.IO.Fonts->Locked = false;
|
g.IO.Fonts->Locked = false;
|
||||||
@ -6358,15 +6361,17 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply back modified position/size to window
|
// Apply back modified position/size to window
|
||||||
if (size_target.x != FLT_MAX)
|
const ImVec2 curr_pos = window->Pos;
|
||||||
|
const ImVec2 curr_size = window->SizeFull;
|
||||||
|
if (size_target.x != FLT_MAX && (window->Size.x != size_target.x || window->SizeFull.x != size_target.x))
|
||||||
window->Size.x = window->SizeFull.x = size_target.x;
|
window->Size.x = window->SizeFull.x = size_target.x;
|
||||||
if (size_target.y != FLT_MAX)
|
if (size_target.y != FLT_MAX && (window->Size.y != size_target.y || window->SizeFull.y != size_target.y))
|
||||||
window->Size.y = window->SizeFull.y = size_target.y;
|
window->Size.y = window->SizeFull.y = size_target.y;
|
||||||
if (pos_target.x != FLT_MAX)
|
if (pos_target.x != FLT_MAX && window->Pos.x != ImTrunc(pos_target.x))
|
||||||
window->Pos.x = ImTrunc(pos_target.x);
|
window->Pos.x = ImTrunc(pos_target.x);
|
||||||
if (pos_target.y != FLT_MAX)
|
if (pos_target.y != FLT_MAX && window->Pos.y != ImTrunc(pos_target.y))
|
||||||
window->Pos.y = ImTrunc(pos_target.y);
|
window->Pos.y = ImTrunc(pos_target.y);
|
||||||
if (size_target.x != FLT_MAX || size_target.y != FLT_MAX || pos_target.x != FLT_MAX || pos_target.y != FLT_MAX)
|
if (curr_pos.x != window->Pos.x || curr_pos.y != window->Pos.y || curr_size.x != window->SizeFull.x || curr_size.y != window->SizeFull.y)
|
||||||
MarkIniSettingsDirty(window);
|
MarkIniSettingsDirty(window);
|
||||||
|
|
||||||
// Recalculate next expected border expected coordinates
|
// Recalculate next expected border expected coordinates
|
||||||
|
@ -3401,14 +3401,6 @@ bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char*
|
|||||||
return value_changed;
|
return value_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ImGuiInputTextFlags InputScalar_DefaultCharsFilter(ImGuiDataType data_type, const char* format)
|
|
||||||
{
|
|
||||||
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
|
|
||||||
return ImGuiInputTextFlags_CharsScientific;
|
|
||||||
const char format_last_char = format[0] ? format[strlen(format) - 1] : 0;
|
|
||||||
return (format_last_char == 'x' || format_last_char == 'X') ? ImGuiInputTextFlags_CharsHexadecimal : ImGuiInputTextFlags_CharsDecimal;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note that Drag/Slider functions are only forwarding the min/max values clamping values if the ImGuiSliderFlags_AlwaysClamp flag is set!
|
// Note that Drag/Slider functions are only forwarding the min/max values clamping values if the ImGuiSliderFlags_AlwaysClamp flag is set!
|
||||||
// This is intended: this way we allow CTRL+Click manual input to set a value out of bounds, for maximum flexibility.
|
// This is intended: this way we allow CTRL+Click manual input to set a value out of bounds, for maximum flexibility.
|
||||||
// However this may not be ideal for all uses, as some user code may break on out of bound values.
|
// However this may not be ideal for all uses, as some user code may break on out of bound values.
|
||||||
@ -3426,7 +3418,6 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
|||||||
ImStrTrimBlanks(data_buf);
|
ImStrTrimBlanks(data_buf);
|
||||||
|
|
||||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited;
|
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited;
|
||||||
flags |= InputScalar_DefaultCharsFilter(data_type, format);
|
|
||||||
|
|
||||||
bool value_changed = false;
|
bool value_changed = false;
|
||||||
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
|
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
|
||||||
@ -3470,9 +3461,6 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
|||||||
char buf[64];
|
char buf[64];
|
||||||
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
|
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
|
||||||
|
|
||||||
// Testing ActiveId as a minor optimization as filtering is not needed until active
|
|
||||||
if (g.ActiveId == 0 && (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0)
|
|
||||||
flags |= InputScalar_DefaultCharsFilter(data_type, format);
|
|
||||||
flags |= ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
|
flags |= ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
|
||||||
|
|
||||||
bool value_changed = false;
|
bool value_changed = false;
|
||||||
@ -3567,7 +3555,6 @@ bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* p_dat
|
|||||||
|
|
||||||
bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, const char* format, ImGuiInputTextFlags flags)
|
bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, const char* format, ImGuiInputTextFlags flags)
|
||||||
{
|
{
|
||||||
flags |= ImGuiInputTextFlags_CharsScientific;
|
|
||||||
return InputScalar(label, ImGuiDataType_Float, (void*)v, (void*)(step > 0.0f ? &step : NULL), (void*)(step_fast > 0.0f ? &step_fast : NULL), format, flags);
|
return InputScalar(label, ImGuiDataType_Float, (void*)v, (void*)(step > 0.0f ? &step : NULL), (void*)(step_fast > 0.0f ? &step_fast : NULL), format, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3610,7 +3597,6 @@ bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags)
|
|||||||
|
|
||||||
bool ImGui::InputDouble(const char* label, double* v, double step, double step_fast, const char* format, ImGuiInputTextFlags flags)
|
bool ImGui::InputDouble(const char* label, double* v, double step, double step_fast, const char* format, ImGuiInputTextFlags flags)
|
||||||
{
|
{
|
||||||
flags |= ImGuiInputTextFlags_CharsScientific;
|
|
||||||
return InputScalar(label, ImGuiDataType_Double, (void*)v, (void*)(step > 0.0 ? &step : NULL), (void*)(step_fast > 0.0 ? &step_fast : NULL), format, flags);
|
return InputScalar(label, ImGuiDataType_Double, (void*)v, (void*)(step > 0.0 ? &step : NULL), (void*)(step_fast > 0.0 ? &step_fast : NULL), format, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5245,7 +5231,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
else
|
else
|
||||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255));
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255));
|
||||||
SetNextItemWidth(w_inputs);
|
SetNextItemWidth(w_inputs);
|
||||||
if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase))
|
if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsUppercase))
|
||||||
{
|
{
|
||||||
value_changed = true;
|
value_changed = true;
|
||||||
char* p = buf;
|
char* p = buf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user