mirror of
https://github.com/ocornut/imgui.git
synced 2026-09-26 16:05:45 +03:00
Merge 752c4eec50 into aa0181478b
This commit is contained in:
commit
c3fbc41b3b
1 changed files with 0 additions and 75 deletions
|
|
@ -1918,81 +1918,6 @@ void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevic
|
|||
|
||||
ImGui_ImplVulkanH_CreateWindowSwapChain(physical_device, device, wd, allocator, width, height, min_image_count, image_usage);
|
||||
ImGui_ImplVulkanH_CreateWindowCommandBuffers(physical_device, device, wd, queue_family, allocator);
|
||||
|
||||
// FIXME: to submit the command buffer, we need a queue. In the examples folder, the ImGui_ImplVulkanH_CreateOrResizeWindow function is called
|
||||
// before the ImGui_ImplVulkan_Init function, so we don't have access to the queue yet. Here we have the queue_family that we can use to grab
|
||||
// a queue from the device and submit the command buffer. It would be better to have access to the queue as suggested in the FIXME below.
|
||||
VkCommandPool command_pool;
|
||||
VkCommandPoolCreateInfo pool_info = {};
|
||||
pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||
pool_info.queueFamilyIndex = queue_family;
|
||||
VkResult err = vkCreateCommandPool(device, &pool_info, allocator, &command_pool);
|
||||
check_vk_result(err);
|
||||
|
||||
VkFenceCreateInfo fence_info = {};
|
||||
fence_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
VkFence fence;
|
||||
err = vkCreateFence(device, &fence_info, allocator, &fence);
|
||||
check_vk_result(err);
|
||||
|
||||
VkCommandBufferAllocateInfo alloc_info = {};
|
||||
alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||
alloc_info.commandPool = command_pool;
|
||||
alloc_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||
alloc_info.commandBufferCount = 1;
|
||||
VkCommandBuffer command_buffer;
|
||||
err = vkAllocateCommandBuffers(device, &alloc_info, &command_buffer);
|
||||
check_vk_result(err);
|
||||
|
||||
VkCommandBufferBeginInfo begin_info = {};
|
||||
begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
||||
begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
||||
err = vkBeginCommandBuffer(command_buffer, &begin_info);
|
||||
check_vk_result(err);
|
||||
|
||||
// Transition the images to the correct layout for rendering
|
||||
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
||||
{
|
||||
VkImageMemoryBarrier barrier = {};
|
||||
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
barrier.image = wd->Frames[i].Backbuffer;
|
||||
barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
barrier.subresourceRange.levelCount = 1;
|
||||
barrier.subresourceRange.layerCount = 1;
|
||||
vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier);
|
||||
}
|
||||
|
||||
err = vkEndCommandBuffer(command_buffer);
|
||||
check_vk_result(err);
|
||||
VkSubmitInfo submit_info = {};
|
||||
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||
submit_info.commandBufferCount = 1;
|
||||
submit_info.pCommandBuffers = &command_buffer;
|
||||
|
||||
VkQueue queue;
|
||||
vkGetDeviceQueue(device, queue_family, 0, &queue);
|
||||
err = vkQueueSubmit(queue, 1, &submit_info, fence);
|
||||
check_vk_result(err);
|
||||
err = vkWaitForFences(device, 1, &fence, VK_TRUE, UINT64_MAX);
|
||||
check_vk_result(err);
|
||||
err = vkResetFences(device, 1, &fence);
|
||||
check_vk_result(err);
|
||||
|
||||
err = vkResetCommandPool(device, command_pool, 0);
|
||||
check_vk_result(err);
|
||||
|
||||
// Destroy command buffer and fence and command pool
|
||||
vkFreeCommandBuffers(device, command_pool, 1, &command_buffer);
|
||||
vkDestroyCommandPool(device, command_pool, allocator);
|
||||
vkDestroyFence(device, fence, allocator);
|
||||
command_pool = VK_NULL_HANDLE;
|
||||
command_buffer = VK_NULL_HANDLE;
|
||||
fence = VK_NULL_HANDLE;
|
||||
queue = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue