summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2019-08-21 13:47:25 +0200
committerDylan Baker <[email protected]>2019-09-04 16:14:26 -0700
commit0a83226dc6a859e5aef0cda2cc757c056113435a (patch)
treef7eaa2bcc814f275de8bea20fcfbefc7d37359b4 /src
parent26cd4074812dab67498afd744c03257c31574cc3 (diff)
vulkan/overlay: bounce image back to present layout
Once we write the overlay to an image to be presented, we must not forget to put it back into present layout. Signed-off-by: Lionel Landwerlin <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111401 Cc: <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> (cherry picked from commit 320b0f66c27407008784da3606e23cb44c70ddf0)
Diffstat (limited to 'src')
-rw-r--r--src/vulkan/overlay-layer/overlay.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/vulkan/overlay-layer/overlay.cpp b/src/vulkan/overlay-layer/overlay.cpp
index 4d5f032d3a2..96c33d4ead5 100644
--- a/src/vulkan/overlay-layer/overlay.cpp
+++ b/src/vulkan/overlay-layer/overlay.cpp
@@ -912,6 +912,7 @@ static void CreateOrResizeBuffer(struct device_data *data,
}
static struct overlay_draw *render_swapchain_display(struct swapchain_data *data,
+ struct queue_data *present_queue,
const VkSemaphore *wait_semaphores,
unsigned n_wait_semaphores,
unsigned image_index)
@@ -955,7 +956,7 @@ static struct overlay_draw *render_swapchain_display(struct swapchain_data *data
imb.subresourceRange.levelCount = 1;
imb.subresourceRange.baseArrayLayer = 0;
imb.subresourceRange.layerCount = 1;
- imb.srcQueueFamilyIndex = device_data->graphic_queue->family_index;
+ imb.srcQueueFamilyIndex = present_queue->family_index;
imb.dstQueueFamilyIndex = device_data->graphic_queue->family_index;
device_data->vtable.CmdPipelineBarrier(draw->command_buffer,
VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
@@ -1082,6 +1083,30 @@ static struct overlay_draw *render_swapchain_display(struct swapchain_data *data
}
device_data->vtable.CmdEndRenderPass(draw->command_buffer);
+
+ /* Bounce the image to display back to present layout. */
+ imb.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+ imb.pNext = nullptr;
+ imb.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+ imb.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+ imb.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ imb.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
+ imb.image = data->images[image_index];
+ imb.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ imb.subresourceRange.baseMipLevel = 0;
+ imb.subresourceRange.levelCount = 1;
+ imb.subresourceRange.baseArrayLayer = 0;
+ imb.subresourceRange.layerCount = 1;
+ imb.srcQueueFamilyIndex = device_data->graphic_queue->family_index;
+ imb.dstQueueFamilyIndex = present_queue->family_index;
+ device_data->vtable.CmdPipelineBarrier(draw->command_buffer,
+ VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
+ VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
+ 0, /* dependency flags */
+ 0, nullptr, /* memory barriers */
+ 0, nullptr, /* buffer memory barriers */
+ 1, &imb); /* image memory barriers */
+
device_data->vtable.EndCommandBuffer(draw->command_buffer);
VkSubmitInfo submit_info = {};
@@ -1514,6 +1539,7 @@ static void shutdown_swapchain_data(struct swapchain_data *data)
}
static struct overlay_draw *before_present(struct swapchain_data *swapchain_data,
+ struct queue_data *present_queue,
const VkSemaphore *wait_semaphores,
unsigned n_wait_semaphores,
unsigned imageIndex)
@@ -1525,7 +1551,7 @@ static struct overlay_draw *before_present(struct swapchain_data *swapchain_data
if (!instance_data->params.no_display && swapchain_data->n_frames > 0) {
compute_swapchain_display(swapchain_data);
- draw = render_swapchain_display(swapchain_data,
+ draw = render_swapchain_display(swapchain_data, present_queue,
wait_semaphores, n_wait_semaphores,
imageIndex);
}
@@ -1630,6 +1656,7 @@ static VkResult overlay_QueuePresentKHR(
FIND(struct swapchain_data, swapchain);
before_present(swapchain_data,
+ queue_data,
pPresentInfo->pWaitSemaphores,
pPresentInfo->waitSemaphoreCount,
pPresentInfo->pImageIndices[i]);
@@ -1655,6 +1682,7 @@ static VkResult overlay_QueuePresentKHR(
uint32_t image_index = pPresentInfo->pImageIndices[i];
struct overlay_draw *draw = before_present(swapchain_data,
+ queue_data,
pPresentInfo->pWaitSemaphores,
pPresentInfo->waitSemaphoreCount,
image_index);