···14141515#include "comp_vk_client.h"
16161717-#include <stdio.h>
1818-#include <stdlib.h>
1919-#include <assert.h>
2020-2121-#define MS_TO_NS(ms) (ms * 1000L * 1000L)
2222-23172418/*!
2519 * Down-cast helper.
···671665 return XRT_ERROR_FAILED_TO_SUBMIT_VULKAN_COMMANDS;
672666 }
673667674674- // Prerecord command buffers for swapchain image ownership/layout
675675- // transitions
668668+ // Prerecord command buffers for swapchain image ownership/layout transitions
676669 for (uint32_t i = 0; i < xsc->image_count; i++) {
677670 ret = vk_init_cmd_buffer(vk, &sc->acquire[i]);
678671 if (ret != VK_SUCCESS) {
···691684 .layerCount = VK_REMAINING_ARRAY_LAYERS,
692685 };
693686694694- /*
695695- * The biggest reason is that VK_IMAGE_LAYOUT_PRESENT_SRC_KHR is
696696- * used here is that this is what hello_xr used to barrier to,
697697- * and it worked on a wide verity of drivers. So it's safe.
698698- *
699699- * There might not be a Vulkan renderer on the other endm
700700- * there could be a OpenGL compositor, heck there could be a X
701701- * server even. On Linux VK_IMAGE_LAYOUT_PRESENT_SRC_KHR is what
702702- * you use if you want to "flush" out all of the pixels to the
703703- * memory buffer that has been shared to you from a X11 server.
704704- *
705705- * This is not what the spec says you should do when it comes to
706706- * external images thou. Instead we should use the queue family
707707- * index `VK_QUEUE_FAMILY_EXTERNAL`. And use semaphores to
708708- * synchronize.
709709- */
710687 VkImageMemoryBarrier acquire = {
711688 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
712689 .srcAccessMask = 0,
···732709 };
733710734711 //! @todo less conservative pipeline stage masks based on usage
735735- vk->vkCmdPipelineBarrier(sc->acquire[i], VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
736736- VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, &acquire);
737737- vk->vkCmdPipelineBarrier(sc->release[i], VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
738738- VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0, NULL, 1, &release);
712712+ vk->vkCmdPipelineBarrier( //
713713+ sc->acquire[i], // commandBuffer
714714+ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // srcStageMask
715715+ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // dstStageMask
716716+ 0, // dependencyFlags
717717+ 0, // memoryBarrierCount
718718+ NULL, // pMemoryBarriers
719719+ 0, // bufferMemoryBarrierCount
720720+ NULL, // pBufferMemoryBarriers
721721+ 1, // imageMemoryBarrierCount
722722+ &acquire); // pImageMemoryBarriers
723723+724724+ vk->vkCmdPipelineBarrier( //
725725+ sc->release[i], // commandBuffer
726726+ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // srcStageMask
727727+ VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, // dstStageMask
728728+ 0, // dependencyFlags
729729+ 0, // memoryBarrierCount
730730+ NULL, // pMemoryBarriers
731731+ 0, // bufferMemoryBarrierCount
732732+ NULL, // pBufferMemoryBarriers
733733+ 1, // imageMemoryBarrierCount
734734+ &release); // pImageMemoryBarriers
739735740736 ret = vk->vkEndCommandBuffer(sc->acquire[i]);
741737 if (ret != VK_SUCCESS) {