vulkan/wsi: Provide the implicitly synchronized BO to vkQueueSubmit
authorJason Ekstrand <jason@jlekstrand.net>
Thu, 21 Nov 2019 11:47:10 +0000 (05:47 -0600)
committerJason Ekstrand <jason@jlekstrand.net>
Fri, 6 Dec 2019 19:58:06 +0000 (19:58 +0000)
This lets us treat the implicit synchronization that we need for X11 and
Wayland like a semaphore.  Instead of trusting the driver to somehow
figure out when that memory object needs to be signaled, we provide an
explicit point where the driver can set EXEC_OBJECT_WRITE and signal the
dma_fence on the BO.  Without this, we have to somehow track inside the
driver when WSI buffers are actually used to avoid extra synchronization
dependencies.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/vulkan/wsi/wsi_common.c
src/vulkan/wsi/wsi_common.h

index b8f6c6d70de620c383c77738b3acf24e3dff53b2..3abffe3dee70df38b7fc88b021673ae119542af2 100644 (file)
@@ -1042,9 +1042,18 @@ wsi_common_queue_present(const struct wsi_device *wsi,
          wsi->ResetFences(device, 1, &swapchain->fences[image_index]);
       }
 
          wsi->ResetFences(device, 1, &swapchain->fences[image_index]);
       }
 
+      struct wsi_image *image =
+         swapchain->get_wsi_image(swapchain, image_index);
+
+      struct wsi_memory_signal_submit_info mem_signal = {
+         .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA,
+         .pNext = NULL,
+         .memory = image->memory,
+      };
+
       VkSubmitInfo submit_info = {
          .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
       VkSubmitInfo submit_info = {
          .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
-         .pNext = NULL,
+         .pNext = &mem_signal,
       };
 
       VkPipelineStageFlags *stage_flags = NULL;
       };
 
       VkPipelineStageFlags *stage_flags = NULL;
@@ -1075,11 +1084,10 @@ wsi_common_queue_present(const struct wsi_device *wsi,
          /* If we are using prime blits, we need to perform the blit now.  The
           * command buffer is attached to the image.
           */
          /* If we are using prime blits, we need to perform the blit now.  The
           * command buffer is attached to the image.
           */
-         struct wsi_image *image =
-            swapchain->get_wsi_image(swapchain, image_index);
          submit_info.commandBufferCount = 1;
          submit_info.pCommandBuffers =
             &image->prime.blit_cmd_buffers[queue_family_index];
          submit_info.commandBufferCount = 1;
          submit_info.pCommandBuffers =
             &image->prime.blit_cmd_buffers[queue_family_index];
+         mem_signal.memory = image->prime.memory;
       }
 
       result = wsi->QueueSubmit(queue, 1, &submit_info, swapchain->fences[image_index]);
       }
 
       result = wsi->QueueSubmit(queue, 1, &submit_info, swapchain->fences[image_index]);
index 064b16a5e7ab14f686e7dd0d12996519ed9a7d28..d15dea7b0eb97c59ff2abad85800ea42266248a3 100644 (file)
@@ -37,6 +37,7 @@
 #define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA (VkStructureType)1000001003
 #define VK_STRUCTURE_TYPE_WSI_FORMAT_MODIFIER_PROPERTIES_LIST_MESA (VkStructureType)1000001004
 #define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA (VkStructureType)1000001005
 #define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA (VkStructureType)1000001003
 #define VK_STRUCTURE_TYPE_WSI_FORMAT_MODIFIER_PROPERTIES_LIST_MESA (VkStructureType)1000001004
 #define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA (VkStructureType)1000001005
+#define VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA (VkStructureType)1000001006
 
 struct wsi_image_create_info {
     VkStructureType sType;
 
 struct wsi_image_create_info {
     VkStructureType sType;
@@ -76,6 +77,13 @@ struct wsi_surface_supported_counters {
 
 };
 
 
 };
 
+/* To be chained into VkSubmitInfo */
+struct wsi_memory_signal_submit_info {
+    VkStructureType sType;
+    const void *pNext;
+    VkDeviceMemory memory;
+};
+
 struct wsi_fence {
    VkDevice                     device;
    const struct wsi_device      *wsi_device;
 struct wsi_fence {
    VkDevice                     device;
    const struct wsi_device      *wsi_device;