v3dv: Add emulated timeline semaphore support
authorJason Ekstrand <jason.ekstrand@collabora.com>
Mon, 4 Apr 2022 23:37:26 +0000 (18:37 -0500)
committerMarge Bot <emma+marge@anholt.net>
Wed, 13 Apr 2022 17:22:14 +0000 (17:22 +0000)
This is trivial thanks to the emulated timelines provided in common
code.  "Real" timeline semaphores which can be shared across processes
will require kernel support.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15704>

src/broadcom/vulkan/v3dv_device.c
src/broadcom/vulkan/v3dv_private.h

index f4c9cc2..02392bf 100644 (file)
@@ -145,6 +145,7 @@ get_device_extensions(const struct v3dv_physical_device *device,
       .KHR_shader_non_semantic_info        = true,
       .KHR_sampler_mirror_clamp_to_edge    = true,
       .KHR_storage_buffer_storage_class    = true,
+      .KHR_timeline_semaphore              = true,
       .KHR_uniform_buffer_standard_layout  = true,
 #ifdef V3DV_USE_WSI_PLATFORM
       .KHR_swapchain                       = true,
@@ -879,8 +880,17 @@ physical_device_init(struct v3dv_physical_device *device,
    device->drm_syncobj_type.import_sync_file = NULL;
    device->drm_syncobj_type.export_sync_file = NULL;
 
+   /* Multiwait is required for emulated timeline semaphores and is supported
+    * by the v3d kernel interface.
+    */
+   device->drm_syncobj_type.features |= VK_SYNC_FEATURE_GPU_MULTI_WAIT;
+
+   device->sync_timeline_type =
+      vk_sync_timeline_get_type(&device->drm_syncobj_type);
+
    device->sync_types[0] = &device->drm_syncobj_type;
-   device->sync_types[1] = NULL;
+   device->sync_types[1] = &device->sync_timeline_type.sync;
+   device->sync_types[2] = NULL;
    device->vk.supported_sync_types = device->sync_types;
 
    result = v3dv_wsi_init(device);
@@ -1163,6 +1173,7 @@ v3dv_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
       .storageBuffer8BitAccess = true,
       .storagePushConstant8 = true,
       .imagelessFramebuffer = true,
+      .timelineSemaphore = true,
    };
 
    VkPhysicalDeviceVulkan11Features vk11 = {
@@ -1548,6 +1559,7 @@ v3dv_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
        */
       .independentResolveNone = false,
       .independentResolve = false,
+      .maxTimelineSemaphoreValueDifference = UINT64_MAX,
    };
    memset(vk12.driverName, 0, VK_MAX_DRIVER_NAME_SIZE_KHR);
    snprintf(vk12.driverName, VK_MAX_DRIVER_NAME_SIZE_KHR, "V3DV Mesa");
index 950fd33..c922c8d 100644 (file)
@@ -44,6 +44,7 @@
 #include "vk_physical_device.h"
 #include "vk_shader_module.h"
 #include "vk_sync.h"
+#include "vk_sync_timeline.h"
 #include "vk_util.h"
 
 #include "vk_command_buffer.h"
@@ -142,7 +143,8 @@ struct v3dv_physical_device {
    uint8_t driver_uuid[VK_UUID_SIZE];
 
    struct vk_sync_type drm_syncobj_type;
-   const struct vk_sync_type *sync_types[2];
+   struct vk_sync_timeline_type sync_timeline_type;
+   const struct vk_sync_type *sync_types[3];
 
    struct disk_cache *disk_cache;