The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

c/client: Tidy VK compositor

+24 -28
+24 -28
src/xrt/compositor/client/comp_vk_client.c
··· 14 14 15 15 #include "comp_vk_client.h" 16 16 17 - #include <stdio.h> 18 - #include <stdlib.h> 19 - #include <assert.h> 20 - 21 - #define MS_TO_NS(ms) (ms * 1000L * 1000L) 22 - 23 17 24 18 /*! 25 19 * Down-cast helper. ··· 671 665 return XRT_ERROR_FAILED_TO_SUBMIT_VULKAN_COMMANDS; 672 666 } 673 667 674 - // Prerecord command buffers for swapchain image ownership/layout 675 - // transitions 668 + // Prerecord command buffers for swapchain image ownership/layout transitions 676 669 for (uint32_t i = 0; i < xsc->image_count; i++) { 677 670 ret = vk_init_cmd_buffer(vk, &sc->acquire[i]); 678 671 if (ret != VK_SUCCESS) { ··· 691 684 .layerCount = VK_REMAINING_ARRAY_LAYERS, 692 685 }; 693 686 694 - /* 695 - * The biggest reason is that VK_IMAGE_LAYOUT_PRESENT_SRC_KHR is 696 - * used here is that this is what hello_xr used to barrier to, 697 - * and it worked on a wide verity of drivers. So it's safe. 698 - * 699 - * There might not be a Vulkan renderer on the other endm 700 - * there could be a OpenGL compositor, heck there could be a X 701 - * server even. On Linux VK_IMAGE_LAYOUT_PRESENT_SRC_KHR is what 702 - * you use if you want to "flush" out all of the pixels to the 703 - * memory buffer that has been shared to you from a X11 server. 704 - * 705 - * This is not what the spec says you should do when it comes to 706 - * external images thou. Instead we should use the queue family 707 - * index `VK_QUEUE_FAMILY_EXTERNAL`. And use semaphores to 708 - * synchronize. 709 - */ 710 687 VkImageMemoryBarrier acquire = { 711 688 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, 712 689 .srcAccessMask = 0, ··· 732 709 }; 733 710 734 711 //! @todo less conservative pipeline stage masks based on usage 735 - vk->vkCmdPipelineBarrier(sc->acquire[i], VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 736 - VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, &acquire); 737 - vk->vkCmdPipelineBarrier(sc->release[i], VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 738 - VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0, NULL, 1, &release); 712 + vk->vkCmdPipelineBarrier( // 713 + sc->acquire[i], // commandBuffer 714 + VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // srcStageMask 715 + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // dstStageMask 716 + 0, // dependencyFlags 717 + 0, // memoryBarrierCount 718 + NULL, // pMemoryBarriers 719 + 0, // bufferMemoryBarrierCount 720 + NULL, // pBufferMemoryBarriers 721 + 1, // imageMemoryBarrierCount 722 + &acquire); // pImageMemoryBarriers 723 + 724 + vk->vkCmdPipelineBarrier( // 725 + sc->release[i], // commandBuffer 726 + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // srcStageMask 727 + VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, // dstStageMask 728 + 0, // dependencyFlags 729 + 0, // memoryBarrierCount 730 + NULL, // pMemoryBarriers 731 + 0, // bufferMemoryBarrierCount 732 + NULL, // pBufferMemoryBarriers 733 + 1, // imageMemoryBarrierCount 734 + &release); // pImageMemoryBarriers 739 735 740 736 ret = vk->vkEndCommandBuffer(sc->acquire[i]); 741 737 if (ret != VK_SUCCESS) {