Backends: Vulkan: Create a custom pipeline for secondary viewports. (#6325, #6305, #7398, #3459, #3253, #3522)
Edited from original commit: moved ImGui_ImplVulkan_CreatePipeline() call from ImGui_ImplVulkanH_CreateOrResizeWindow() to ImGui_ImplVulkan_CreateWindow().
diff --git a/backends/imgui_impl_vulkan.cpp b/backends/imgui_impl_vulkan.cpp
index c026add..f8bfc9d 100644
--- a/backends/imgui_impl_vulkan.cpp
+++ b/backends/imgui_impl_vulkan.cpp
@@ -244,7 +244,8 @@
VkPipelineCreateFlags PipelineCreateFlags;
VkDescriptorSetLayout DescriptorSetLayout;
VkPipelineLayout PipelineLayout;
- VkPipeline Pipeline;
+ VkPipeline Pipeline; // pipeline for main render pass (created by app)
+ VkPipeline PipelineForViewports; // pipeline for secondary viewports (created by backend)
VkShaderModule ShaderModuleVert;
VkShaderModule ShaderModuleFrag;
@@ -1071,6 +1072,7 @@
if (bd->DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayout, v->Allocator); bd->DescriptorSetLayout = VK_NULL_HANDLE; }
if (bd->PipelineLayout) { vkDestroyPipelineLayout(v->Device, bd->PipelineLayout, v->Allocator); bd->PipelineLayout = VK_NULL_HANDLE; }
if (bd->Pipeline) { vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator); bd->Pipeline = VK_NULL_HANDLE; }
+ if (bd->PipelineForViewports) { vkDestroyPipeline(v->Device, bd->PipelineForViewports, v->Allocator); bd->PipelineForViewports = VK_NULL_HANDLE; }
}
bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data)
@@ -1689,6 +1691,10 @@
wd->UseDynamicRendering = v->UseDynamicRendering;
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, wd, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount);
vd->WindowOwned = true;
+
+ // Create pipeline (shared by all secondary viewports)
+ if (bd->PipelineForViewports == VK_NULL_HANDLE)
+ ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &bd->PipelineForViewports, 0);
}
static void ImGui_ImplVulkan_DestroyWindow(ImGuiViewport* viewport)
@@ -1803,7 +1809,7 @@
}
}
- ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, nullptr);
+ ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, bd->PipelineForViewports);
{
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index ea2d01f..c60d461 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -83,6 +83,9 @@
- Docking: when io.ConfigDockingWithShift is enabled, fixed help tooltip erroneously
reading SetNextWindowXXX() data. (#6709, #4643, #7491) [@ocornut, @cfillion]
+- Backends: Vulkan: create a custom pipeline for secondary viewports. Fixes issues
+ when user created main viewport uses a different renderpass. (#6325, #6305, #7398,
+ #3459, #3253, #3522) [@skaman, @FunMiles]
-----------------------------------------------------------------------