mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-03 21:59:15 +08:00
parent
677c7b2258
commit
ac8573884d
@ -1597,6 +1597,7 @@ static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
|
|||||||
|
|
||||||
// Create SwapChain, RenderPass, Framebuffer, etc.
|
// Create SwapChain, RenderPass, Framebuffer, etc.
|
||||||
wd->ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
|
wd->ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
|
||||||
|
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);
|
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;
|
vd->WindowOwned = true;
|
||||||
}
|
}
|
||||||
@ -1662,7 +1663,45 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
|
|||||||
{
|
{
|
||||||
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
|
}
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
if (v->UseDynamicRendering)
|
||||||
|
{
|
||||||
|
// Transition swapchain image to a layout suitable for drawing.
|
||||||
|
VkImageMemoryBarrier barrier = {};
|
||||||
|
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
|
barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
|
barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
barrier.image = fd->Backbuffer;
|
||||||
|
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
barrier.subresourceRange.levelCount = 1;
|
||||||
|
barrier.subresourceRange.layerCount = 1;
|
||||||
|
vkCmdPipelineBarrier(fd->CommandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier);
|
||||||
|
|
||||||
|
VkRenderingAttachmentInfo attachmentInfo = {};
|
||||||
|
attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR;
|
||||||
|
attachmentInfo.imageView = fd->BackbufferView;
|
||||||
|
attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
attachmentInfo.resolveMode = VK_RESOLVE_MODE_NONE;
|
||||||
|
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||||
|
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
|
attachmentInfo.clearValue = wd->ClearValue;
|
||||||
|
|
||||||
|
VkRenderingInfo renderingInfo = {};
|
||||||
|
renderingInfo.sType = VK_STRUCTURE_TYPE_RENDERING_INFO_KHR;
|
||||||
|
renderingInfo.renderArea.extent.width = wd->Width;
|
||||||
|
renderingInfo.renderArea.extent.height = wd->Height;
|
||||||
|
renderingInfo.layerCount = 1;
|
||||||
|
renderingInfo.viewMask = 0;
|
||||||
|
renderingInfo.colorAttachmentCount = 1;
|
||||||
|
renderingInfo.pColorAttachments = &attachmentInfo;
|
||||||
|
|
||||||
|
ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR(fd->CommandBuffer, &renderingInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
VkRenderPassBeginInfo info = {};
|
VkRenderPassBeginInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||||
info.renderPass = wd->RenderPass;
|
info.renderPass = wd->RenderPass;
|
||||||
@ -1678,7 +1717,28 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
|
|||||||
ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, wd->Pipeline);
|
ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, wd->Pipeline);
|
||||||
|
|
||||||
{
|
{
|
||||||
vkCmdEndRenderPass(fd->CommandBuffer);
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
if (v->UseDynamicRendering)
|
||||||
|
{
|
||||||
|
ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR(fd->CommandBuffer);
|
||||||
|
|
||||||
|
// Transition image to a layout suitable for presentation
|
||||||
|
VkImageMemoryBarrier barrier = {};
|
||||||
|
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
|
barrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
|
barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||||
|
barrier.image = fd->Backbuffer;
|
||||||
|
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
barrier.subresourceRange.levelCount = 1;
|
||||||
|
barrier.subresourceRange.layerCount = 1;
|
||||||
|
vkCmdPipelineBarrier(fd->CommandBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
vkCmdEndRenderPass(fd->CommandBuffer);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||||
VkSubmitInfo info = {};
|
VkSubmitInfo info = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user