Skip to content

Commit cc0a669

Browse files
committed
Backends: Vulkan: minor internal renames/tweaks to reduce further patches. (#8946, #8110, #8111, #8686)
1 parent 5fe9622 commit cc0a669

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

backends/imgui_impl_vulkan.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,37 +1001,37 @@ static VkPipeline ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAlloc
10011001
dynamic_state.dynamicStateCount = (uint32_t)IM_ARRAYSIZE(dynamic_states);
10021002
dynamic_state.pDynamicStates = dynamic_states;
10031003

1004-
VkGraphicsPipelineCreateInfo info = {};
1005-
info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1006-
info.flags = bd->PipelineCreateFlags;
1007-
info.stageCount = 2;
1008-
info.pStages = stage;
1009-
info.pVertexInputState = &vertex_info;
1010-
info.pInputAssemblyState = &ia_info;
1011-
info.pViewportState = &viewport_info;
1012-
info.pRasterizationState = &raster_info;
1013-
info.pMultisampleState = &ms_info;
1014-
info.pDepthStencilState = &depth_info;
1015-
info.pColorBlendState = &blend_info;
1016-
info.pDynamicState = &dynamic_state;
1017-
info.layout = bd->PipelineLayout;
1018-
info.renderPass = renderPass;
1019-
info.subpass = subpass;
1004+
VkGraphicsPipelineCreateInfo create_info = {};
1005+
create_info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
1006+
create_info.flags = bd->PipelineCreateFlags;
1007+
create_info.stageCount = 2;
1008+
create_info.pStages = stage;
1009+
create_info.pVertexInputState = &vertex_info;
1010+
create_info.pInputAssemblyState = &ia_info;
1011+
create_info.pViewportState = &viewport_info;
1012+
create_info.pRasterizationState = &raster_info;
1013+
create_info.pMultisampleState = &ms_info;
1014+
create_info.pDepthStencilState = &depth_info;
1015+
create_info.pColorBlendState = &blend_info;
1016+
create_info.pDynamicState = &dynamic_state;
1017+
create_info.layout = bd->PipelineLayout;
1018+
create_info.renderPass = renderPass;
1019+
create_info.subpass = subpass;
10201020

10211021
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
10221022
if (bd->VulkanInitInfo.UseDynamicRendering)
10231023
{
10241024
IM_ASSERT(pipeline_rendering_create_info && "PipelineRenderingCreateInfo must not be nullptr when using dynamic rendering");
10251025
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");
10261026
IM_ASSERT(pipeline_rendering_create_info->pNext == nullptr && "PipelineRenderingCreateInfo::pNext must be nullptr");
1027-
info.pNext = pipeline_rendering_create_info;
1028-
info.renderPass = VK_NULL_HANDLE; // Just make sure it's actually nullptr.
1027+
create_info.pNext = pipeline_rendering_create_info;
1028+
create_info.renderPass = VK_NULL_HANDLE; // Just make sure it's actually nullptr.
10291029
}
10301030
#else
10311031
IM_ASSERT(pipeline_rendering_create_info == nullptr);
10321032
#endif
10331033
VkPipeline pipeline;
1034-
VkResult err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &info, allocator, &pipeline);
1034+
VkResult err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &create_info, allocator, &pipeline);
10351035
check_vk_result(err);
10361036
return pipeline;
10371037
}
@@ -1108,11 +1108,11 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
11081108
}
11091109

11101110
// Create pipeline
1111-
if (v->RenderPass
1111+
bool create_main_pipeline = (v->RenderPass != VK_NULL_HANDLE);
11121112
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
1113-
|| (v->UseDynamicRendering && v->PipelineRenderingCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR)
1113+
create_main_pipeline |= (v->UseDynamicRendering && v->PipelineRenderingCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR);
11141114
#endif
1115-
)
1115+
if (create_main_pipeline)
11161116
{
11171117
ImGui_ImplVulkan_MainPipelineCreateInfo mp_info = {};
11181118
mp_info.RenderPass = v->RenderPass;
@@ -1292,6 +1292,7 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
12921292
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
12931293
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
12941294

1295+
// Sanity checks
12951296
IM_ASSERT(info->Instance != VK_NULL_HANDLE);
12961297
IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
12971298
IM_ASSERT(info->Device != VK_NULL_HANDLE);

0 commit comments

Comments
 (0)