pvr: Add support for VK_KHR_timeline_semaphore
authorJarred Davies <jarred.davies@imgtec.com>
Tue, 31 Jan 2023 08:06:25 +0000 (08:06 +0000)
committerMarge Bot <emma+marge@anholt.net>
Tue, 28 Feb 2023 21:39:49 +0000 (21:39 +0000)
pvrsrvkm will run with VK_DEVICE_TIMELINE_MODE_EMULATED and
powervr will run with VK_DEVICE_TIMELINE_MODE_ASSISTED.

Signed-off-by: Jarred Davies <jarred.davies@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21577>

src/imagination/vulkan/pvr_device.c
src/imagination/vulkan/winsys/pvr_winsys.h
src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c

index 6ad7cf9..b1465b2 100644 (file)
@@ -133,6 +133,7 @@ static void pvr_physical_device_get_supported_extensions(
    *extensions = (struct vk_device_extension_table){
       .KHR_external_memory = true,
       .KHR_external_memory_fd = true,
+      .KHR_timeline_semaphore = true,
 #if defined(PVR_USE_WSI_PLATFORM)
       .KHR_swapchain = true,
 #endif
@@ -667,7 +668,18 @@ void pvr_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
    };
 
    vk_foreach_struct (ext, pFeatures->pNext) {
-      pvr_debug_ignored_stype(ext->sType);
+      switch (ext->sType) {
+      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES: {
+         VkPhysicalDeviceTimelineSemaphoreFeatures *pFeature =
+            (VkPhysicalDeviceTimelineSemaphoreFeatures *)ext;
+         pFeature->timelineSemaphore = VK_TRUE;
+         break;
+      }
+      default: {
+         pvr_debug_ignored_stype(ext->sType);
+         break;
+      }
+      }
    }
 }
 
@@ -1043,7 +1055,18 @@ void pvr_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
           VK_UUID_SIZE);
 
    vk_foreach_struct (ext, pProperties->pNext) {
-      pvr_debug_ignored_stype(ext->sType);
+      switch (ext->sType) {
+      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES: {
+         VkPhysicalDeviceTimelineSemaphoreProperties *pProperties =
+            (VkPhysicalDeviceTimelineSemaphoreProperties *)ext;
+         pProperties->maxTimelineSemaphoreValueDifference = UINT64_MAX;
+         break;
+      }
+      default: {
+         pvr_debug_ignored_stype(ext->sType);
+         break;
+      }
+      }
    }
 }
 
index 973794f..8c33737 100644 (file)
@@ -41,6 +41,7 @@
 #include "util/macros.h"
 #include "util/vma.h"
 #include "vk_sync.h"
+#include "vk_sync_timeline.h"
 
 struct pvr_device_info;
 struct pvr_device_runtime_info;
@@ -480,8 +481,9 @@ struct pvr_winsys {
    uint64_t page_size;
    uint32_t log2_page_size;
 
-   const struct vk_sync_type *sync_types[2];
+   const struct vk_sync_type *sync_types[3];
    struct vk_sync_type syncobj_type;
+   struct vk_sync_timeline_type timeline_syncobj_type;
 
    const struct pvr_winsys_ops *ops;
 };
index 56d3aa8..a67ad9e 100644 (file)
@@ -48,6 +48,7 @@
 #include "util/os_misc.h"
 #include "vk_log.h"
 #include "vk_sync.h"
+#include "vk_sync_timeline.h"
 
 /* Amount of space used to hold sync prim values (in bytes). */
 #define PVR_SRV_SYNC_PRIM_VALUE_SIZE 4U
@@ -677,7 +678,11 @@ struct pvr_winsys *pvr_srv_winsys_create(int master_fd,
 
    srv_ws->base.syncobj_type = pvr_srv_sync_type;
    srv_ws->base.sync_types[0] = &srv_ws->base.syncobj_type;
-   srv_ws->base.sync_types[1] = NULL;
+
+   srv_ws->base.timeline_syncobj_type =
+      vk_sync_timeline_get_type(srv_ws->base.sync_types[0]);
+   srv_ws->base.sync_types[1] = &srv_ws->base.timeline_syncobj_type.sync;
+   srv_ws->base.sync_types[2] = NULL;
 
    result = pvr_srv_memctx_init(srv_ws);
    if (result != VK_SUCCESS)