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().
This commit is contained in:
Sandro Cavazzoni 2023-04-12 21:56:35 +02:00 committed by ocornut
parent 49e70e60a2
commit ebb8d78102
2 changed files with 11 additions and 2 deletions

View File

@ -244,7 +244,8 @@ struct ImGui_ImplVulkan_Data
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 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
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 @@ static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
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 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
}
}
ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, nullptr);
ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, bd->PipelineForViewports);
{
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING

View File

@ -83,6 +83,9 @@ Docking+Viewports Branch:
- 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]
-----------------------------------------------------------------------