Skip to content

Commit ee03cef

Browse files
committed
Backends: Vulkan: revert using a struct for ImGui_ImplVulkan_CreatePipeline() for now. (#8110, #8111, #8053)
1 parent e51d93e commit ee03cef

File tree

1 file changed

+17
-34
lines changed

1 file changed

+17
-34
lines changed

backends/imgui_impl_vulkan.cpp

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -906,21 +906,10 @@ static void ImGui_ImplVulkan_CreateShaderModules(VkDevice device, const VkAlloca
906906
}
907907
}
908908

909-
struct ImGui_ImplVulkan_PipelineCreateInfo
910-
{
911-
VkDevice Device = VK_NULL_HANDLE;
912-
const VkAllocationCallbacks* Allocator = nullptr;
913-
VkPipelineCache PipelineCache = VK_NULL_HANDLE;
914-
VkRenderPass RenderPass = VK_NULL_HANDLE;
915-
uint32_t Subpass = 0;
916-
VkSampleCountFlagBits MSAASamples = {};
917-
const ImGui_ImplVulkan_PipelineRenderingCreateInfo* pRenderingInfo = nullptr;
918-
};
919-
920-
static VkPipeline ImGui_ImplVulkan_CreatePipeline(ImGui_ImplVulkan_PipelineCreateInfo const& pci)
909+
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)
921910
{
922911
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
923-
ImGui_ImplVulkan_CreateShaderModules(pci.Device, pci.Allocator);
912+
ImGui_ImplVulkan_CreateShaderModules(device, allocator);
924913

925914
VkPipelineShaderStageCreateInfo stage[2] = {};
926915
stage[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
@@ -975,7 +964,7 @@ static VkPipeline ImGui_ImplVulkan_CreatePipeline(ImGui_ImplVulkan_PipelineCreat
975964

976965
VkPipelineMultisampleStateCreateInfo ms_info = {};
977966
ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
978-
ms_info.rasterizationSamples = (pci.MSAASamples != 0) ? pci.MSAASamples : VK_SAMPLE_COUNT_1_BIT;
967+
ms_info.rasterizationSamples = (MSAASamples != 0) ? MSAASamples : VK_SAMPLE_COUNT_1_BIT;
979968

980969
VkPipelineColorBlendAttachmentState color_attachment[1] = {};
981970
color_attachment[0].blendEnable = VK_TRUE;
@@ -1015,23 +1004,25 @@ static VkPipeline ImGui_ImplVulkan_CreatePipeline(ImGui_ImplVulkan_PipelineCreat
10151004
info.pColorBlendState = &blend_info;
10161005
info.pDynamicState = &dynamic_state;
10171006
info.layout = bd->PipelineLayout;
1018-
info.renderPass = pci.RenderPass;
1019-
info.subpass = pci.Subpass;
1007+
info.renderPass = renderPass;
1008+
info.subpass = subpass;
10201009

10211010
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
10221011
if (bd->VulkanInitInfo.UseDynamicRendering)
10231012
{
1024-
IM_ASSERT(pci.pRenderingInfo && "PipelineRenderingCreateInfo must not be nullptr when using dynamic rendering");
1025-
IM_ASSERT(pci.pRenderingInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR && "PipelineRenderingCreateInfo::sType must be VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR");
1026-
IM_ASSERT(pci.pRenderingInfo->pNext == nullptr && "PipelineRenderingCreateInfo::pNext must be nullptr");
1027-
info.pNext = pci.pRenderingInfo;
1013+
IM_ASSERT(pipeline_rendering_create_info && "PipelineRenderingCreateInfo must not be nullptr when using dynamic rendering");
1014+
IM_ASSERT(pipeline_rendering_create_info->sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR && "PipelineRenderingCreateInfo::sType must be VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR");
1015+
IM_ASSERT(pipeline_rendering_create_info->pNext == nullptr && "PipelineRenderingCreateInfo::pNext must be nullptr");
1016+
info.pNext = pipeline_rendering_create_info;
10281017
info.renderPass = VK_NULL_HANDLE; // Just make sure it's actually nullptr.
10291018
}
1019+
#else
1020+
IM_ASSERT(pipeline_rendering_create_info == nullptr);
10301021
#endif
1031-
VkPipeline res;
1032-
VkResult err = vkCreateGraphicsPipelines(pci.Device, pci.PipelineCache, 1, &info, pci.Allocator, &res);
1022+
VkPipeline pipeline;
1023+
VkResult err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &info, allocator, &pipeline);
10331024
check_vk_result(err);
1034-
return res;
1025+
return pipeline;
10351026
}
10361027

10371028
bool ImGui_ImplVulkan_CreateDeviceObjects()
@@ -1170,25 +1161,17 @@ void ImGui_ImplVulkan_ReCreateMainPipeline(ImGui_ImplVulkan_MainPipelineCreateIn
11701161
v->MSAASamples = info.MSAASamples;
11711162
v->Subpass = info.Subpass;
11721163

1164+
ImGui_ImplVulkan_PipelineRenderingCreateInfo * pipeline_rendering_create_info = nullptr;
11731165
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
11741166
if (info.pDynamicRendering)
11751167
{
11761168
v->PipelineRenderingCreateInfo = *info.pDynamicRendering;
1169+
pipeline_rendering_create_info = &v->PipelineRenderingCreateInfo;
11771170
}
11781171
#else
11791172
IM_ASSERT(info.pDynamicRendering == nullptr);
11801173
#endif
1181-
1182-
ImGui_ImplVulkan_PipelineCreateInfo pci;
1183-
pci.Device = v->Device;
1184-
pci.Allocator = v->Allocator;
1185-
pci.PipelineCache = v->PipelineCache;
1186-
pci.RenderPass = v->RenderPass;
1187-
pci.Subpass = v->Subpass;
1188-
pci.MSAASamples = v->MSAASamples;
1189-
pci.pRenderingInfo = info.pDynamicRendering;
1190-
1191-
bd->Pipeline = ImGui_ImplVulkan_CreatePipeline(pci);
1174+
bd->Pipeline = ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, v->RenderPass, v->MSAASamples, v->Subpass, pipeline_rendering_create_info);
11921175
}
11931176

11941177
void ImGui_ImplVulkan_DestroyDeviceObjects()

0 commit comments

Comments
 (0)