mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Backends: Vulkan: misc amends (e.g. changelog, coding style). (8110, 8111, 8053)
# Conflicts: # backends/imgui_impl_vulkan.cpp
This commit is contained in:
parent
ee03cef14f
commit
1ecc34a0b1
3 changed files with 41 additions and 50 deletions
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
// 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)
|
||||||
|
// 2025-09-04: Vulkan: Added ImGui_ImplVulkan_CreateMainPipeline(). (#8110, #8111)
|
||||||
// 2025-07-27: Vulkan: Fixed texture update corruption introduced on 2025-06-11. (#8801, #8755, #8840)
|
// 2025-07-27: Vulkan: Fixed texture update corruption introduced on 2025-06-11. (#8801, #8755, #8840)
|
||||||
// 2025-07-07: Vulkan: Fixed texture synchronization issue introduced on 2025-06-11. (#8772)
|
// 2025-07-07: Vulkan: Fixed texture synchronization issue introduced on 2025-06-11. (#8772)
|
||||||
// 2025-06-27: Vulkan: Fixed validation errors during texture upload/update by aligning upload size to 'nonCoherentAtomSize'. (#8743, #8744)
|
// 2025-06-27: Vulkan: Fixed validation errors during texture upload/update by aligning upload size to 'nonCoherentAtomSize'. (#8743, #8744)
|
||||||
|
|
@ -906,7 +907,11 @@ static void ImGui_ImplVulkan_CreateShaderModules(VkDevice device, const VkAlloca
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VkPipeline ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationCallbacks* allocator, VkPipelineCache pipelineCache, VkRenderPass renderPass, VkSampleCountFlagBits MSAASamples, uint32_t subpass, const ImGui_ImplVulkan_PipelineRenderingCreateInfo* pipeline_rendering_create_info)
|
#if !defined(IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING) && !(defined(VK_VERSION_1_3) || defined(VK_KHR_dynamic_rendering))
|
||||||
|
typedef void VkPipelineRenderingCreateInfoKHR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static VkPipeline ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationCallbacks* allocator, VkPipelineCache pipelineCache, VkRenderPass renderPass, VkSampleCountFlagBits MSAASamples, uint32_t subpass, const VkPipelineRenderingCreateInfoKHR* pipeline_rendering_create_info)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_CreateShaderModules(device, allocator);
|
ImGui_ImplVulkan_CreateShaderModules(device, allocator);
|
||||||
|
|
@ -1096,33 +1101,22 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
// Create pipeline
|
||||||
bool create_pipeline = false;
|
const VkPipelineRenderingCreateInfoKHR* p_dynamic_rendering_create_info = nullptr;
|
||||||
const ImGui_ImplVulkan_PipelineRenderingCreateInfo* p_dynamic_rendering = nullptr;
|
|
||||||
if (v->RenderPass)
|
|
||||||
{
|
|
||||||
create_pipeline = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
if (v->UseDynamicRendering && v->PipelineRenderingCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR)
|
if (v->UseDynamicRendering && v->PipelineRenderingCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR)
|
||||||
{
|
p_dynamic_rendering_create_info = &v->PipelineRenderingCreateInfo;
|
||||||
p_dynamic_rendering = &v->PipelineRenderingCreateInfo;
|
|
||||||
create_pipeline = true;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
if (v->RenderPass || p_dynamic_rendering_create_info != nullptr)
|
||||||
if (create_pipeline)
|
{
|
||||||
{
|
ImGui_ImplVulkan_MainPipelineCreateInfo mp_info = {};
|
||||||
ImGui_ImplVulkan_MainPipelineCreateInfo mp_info = {};
|
mp_info.RenderPass = v->RenderPass;
|
||||||
mp_info.RenderPass = v->RenderPass;
|
mp_info.Subpass = v->Subpass;
|
||||||
mp_info.Subpass = v->Subpass;
|
mp_info.MSAASamples = v->MSAASamples;
|
||||||
mp_info.MSAASamples = v->MSAASamples;
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
mp_info.pDynamicRendering = p_dynamic_rendering;
|
mp_info.pDynamicRendering = p_dynamic_rendering_create_info;
|
||||||
|
#endif
|
||||||
ImGui_ImplVulkan_ReCreateMainPipeline(mp_info);
|
ImGui_ImplVulkan_CreateMainPipeline(mp_info);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create command pool/buffer for texture upload
|
// Create command pool/buffer for texture upload
|
||||||
|
|
@ -1148,7 +1142,7 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplVulkan_ReCreateMainPipeline(ImGui_ImplVulkan_MainPipelineCreateInfo const& info)
|
void ImGui_ImplVulkan_CreateMainPipeline(const ImGui_ImplVulkan_MainPipelineCreateInfo& info)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
|
@ -1161,15 +1155,13 @@ void ImGui_ImplVulkan_ReCreateMainPipeline(ImGui_ImplVulkan_MainPipelineCreateIn
|
||||||
v->MSAASamples = info.MSAASamples;
|
v->MSAASamples = info.MSAASamples;
|
||||||
v->Subpass = info.Subpass;
|
v->Subpass = info.Subpass;
|
||||||
|
|
||||||
ImGui_ImplVulkan_PipelineRenderingCreateInfo * pipeline_rendering_create_info = nullptr;
|
VkPipelineRenderingCreateInfoKHR* pipeline_rendering_create_info = nullptr;
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
if (info.pDynamicRendering)
|
if (info.pDynamicRendering)
|
||||||
{
|
{
|
||||||
v->PipelineRenderingCreateInfo = *info.pDynamicRendering;
|
v->PipelineRenderingCreateInfo = *info.pDynamicRendering;
|
||||||
pipeline_rendering_create_info = &v->PipelineRenderingCreateInfo;
|
pipeline_rendering_create_info = &v->PipelineRenderingCreateInfo;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
IM_ASSERT(info.pDynamicRendering == nullptr);
|
|
||||||
#endif
|
#endif
|
||||||
bd->Pipeline = ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, v->RenderPass, v->MSAASamples, v->Subpass, pipeline_rendering_create_info);
|
bd->Pipeline = ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, v->RenderPass, v->MSAASamples, v->Subpass, pipeline_rendering_create_info);
|
||||||
}
|
}
|
||||||
|
|
@ -1297,14 +1289,14 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
||||||
IM_ASSERT(info->MinImageCount >= 2);
|
IM_ASSERT(info->MinImageCount >= 2);
|
||||||
IM_ASSERT(info->ImageCount >= info->MinImageCount);
|
IM_ASSERT(info->ImageCount >= info->MinImageCount);
|
||||||
|
|
||||||
ImGui_ImplVulkan_InitInfo * v = &bd->VulkanInitInfo;
|
bd->VulkanInitInfo = *info;
|
||||||
*v = *info;
|
|
||||||
|
|
||||||
VkPhysicalDeviceProperties properties;
|
VkPhysicalDeviceProperties properties;
|
||||||
vkGetPhysicalDeviceProperties(info->PhysicalDevice, &properties);
|
vkGetPhysicalDeviceProperties(info->PhysicalDevice, &properties);
|
||||||
bd->NonCoherentAtomSize = properties.limits.nonCoherentAtomSize;
|
bd->NonCoherentAtomSize = properties.limits.nonCoherentAtomSize;
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
if (v->PipelineRenderingCreateInfo.pColorAttachmentFormats != NULL)
|
if (v->PipelineRenderingCreateInfo.pColorAttachmentFormats != NULL)
|
||||||
{
|
{
|
||||||
// Deep copy buffer to reduce error-rate for end user (#8282)
|
// Deep copy buffer to reduce error-rate for end user (#8282)
|
||||||
|
|
|
||||||
|
|
@ -65,12 +65,6 @@
|
||||||
// Backend uses a small number of descriptors per font atlas + as many as additional calls done to ImGui_ImplVulkan_AddTexture().
|
// Backend uses a small number of descriptors per font atlas + as many as additional calls done to ImGui_ImplVulkan_AddTexture().
|
||||||
#define IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE (8) // Minimum per atlas
|
#define IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE (8) // Minimum per atlas
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
|
||||||
typedef VkPipelineRenderingCreateInfoKHR ImGui_ImplVulkan_PipelineRenderingCreateInfo;
|
|
||||||
#else
|
|
||||||
typedef void ImGui_ImplVulkan_PipelineRenderingCreateInfo;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Initialization data, for ImGui_ImplVulkan_Init()
|
// Initialization data, for ImGui_ImplVulkan_Init()
|
||||||
// [Please zero-clear before use!]
|
// [Please zero-clear before use!]
|
||||||
// - About descriptor pool:
|
// - About descriptor pool:
|
||||||
|
|
@ -104,8 +98,7 @@ struct ImGui_ImplVulkan_InitInfo
|
||||||
// Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
// Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
||||||
bool UseDynamicRendering;
|
bool UseDynamicRendering;
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
// (Optional, valid iif .sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR)
|
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo; // Optional, valid if .sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR
|
||||||
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// (Optional) Allocation, Debugging
|
// (Optional) Allocation, Debugging
|
||||||
|
|
@ -115,21 +108,25 @@ struct ImGui_ImplVulkan_InitInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info); // The main pipeline will be created if possible (RenderPass xor (UseDynamicRendering && PipelineRenderingCreateInfo->sType is correct))
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info);
|
||||||
#define IMGUI_IMPL_VULKAN_HAS_MAIN_PIPELINE_RE_CREATION 1
|
|
||||||
struct ImGui_ImplVulkan_MainPipelineCreateInfo
|
|
||||||
{
|
|
||||||
VkRenderPass RenderPass = VK_NULL_HANDLE;
|
|
||||||
uint32_t Subpass = 0;
|
|
||||||
VkSampleCountFlagBits MSAASamples = {};
|
|
||||||
const ImGui_ImplVulkan_PipelineRenderingCreateInfo* pDynamicRendering = nullptr;
|
|
||||||
};
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_ReCreateMainPipeline(ImGui_ImplVulkan_MainPipelineCreateInfo const& info); // (render_pass xor (p_dynamic_rendering && p_dynamic_rendering is correct (sType and pNext))
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
||||||
|
|
||||||
|
// (Advanced) Use e.g. if you need to recreate pipeline without reinitializing the backend (see #8110, #8111)
|
||||||
|
// The main window pipeline will be created by ImGui_ImplVulkan_Init() if possible (== RenderPass xor (UseDynamicRendering && PipelineRenderingCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR))
|
||||||
|
// Else, the pipeline can be created, or re-created, using ImGui_ImplVulkan_CreateMainPipeline() before rendering.
|
||||||
|
struct ImGui_ImplVulkan_MainPipelineCreateInfo
|
||||||
|
{
|
||||||
|
VkRenderPass RenderPass = VK_NULL_HANDLE;
|
||||||
|
uint32_t Subpass = 0;
|
||||||
|
VkSampleCountFlagBits MSAASamples = {};
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
const VkPipelineRenderingCreateInfoKHR* pDynamicRendering = nullptr;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplVulkan_CreateMainPipeline(const ImGui_ImplVulkan_MainPipelineCreateInfo& info); // (render_pass xor (p_dynamic_rendering && p_dynamic_rendering is correct (sType and pNext))
|
||||||
|
|
||||||
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
|
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex);
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,8 @@ Other Changes:
|
||||||
- Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and
|
- Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and
|
||||||
PresentMode to configure how secondary viewports are created. Currently only used
|
PresentMode to configure how secondary viewports are created. Currently only used
|
||||||
multi-viewport mode. (#8892) [@PTSVU]
|
multi-viewport mode. (#8892) [@PTSVU]
|
||||||
|
- Backends: Vulkan: added ImGui_ImplVulkan_CreateMainPipeline() to recreate pipeline
|
||||||
|
without reinitializing backend. (#8110, #8111) [@SuperRonan]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue