Skip to content

Commit

Permalink
Backends: Vulkan: Create a custom pipeline for secondary viewports. (#…
Browse files Browse the repository at this point in the history
…6325, #6305, #7398, #3459, #3253, #3522)

Edited from original commit: moved ImGui_ImplVulkan_CreatePipeline() call from ImGui_ImplVulkanH_CreateOrResizeWindow() to ImGui_ImplVulkan_CreateWindow().
  • Loading branch information
skaman authored and ocornut committed Apr 30, 2024
1 parent 49e70e6 commit ebb8d78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backends/imgui_impl_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]


-----------------------------------------------------------------------
Expand Down

0 comments on commit ebb8d78

Please sign in to comment.