Skip to content

Commit 02af06e

Browse files
committed
Backends: Vulkan: rewrite pColorAttachmentFormats deep-copy to avoid issues when calling multiple times. (#8282, #8110)
1 parent 026d47c commit 02af06e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

backends/imgui_impl_vulkan.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,10 @@ void ImGui_ImplVulkan_CreateMainPipeline(const ImGui_ImplVulkan_MainPipelineCrea
11641164
if (v->PipelineRenderingCreateInfo.pColorAttachmentFormats != NULL)
11651165
{
11661166
// Deep copy buffer to reduce error-rate for end user (#8282)
1167-
bd->PipelineRenderingCreateInfoColorAttachmentFormats.resize((int)v->PipelineRenderingCreateInfo.colorAttachmentCount);
1168-
memcpy(bd->PipelineRenderingCreateInfoColorAttachmentFormats.Data, v->PipelineRenderingCreateInfo.pColorAttachmentFormats, (size_t)bd->PipelineRenderingCreateInfoColorAttachmentFormats.size_in_bytes());
1167+
ImVector<VkFormat> formats;
1168+
formats.resize((int)v->PipelineRenderingCreateInfo.colorAttachmentCount);
1169+
memcpy(formats.Data, v->PipelineRenderingCreateInfo.pColorAttachmentFormats, (size_t)formats.size_in_bytes());
1170+
formats.swap(bd->PipelineRenderingCreateInfoColorAttachmentFormats);
11691171
v->PipelineRenderingCreateInfo.pColorAttachmentFormats = bd->PipelineRenderingCreateInfoColorAttachmentFormats.Data;
11701172
}
11711173
}

0 commit comments

Comments
 (0)