Module: Mesa
Branch: main
Commit: 5be2e44095f1fea0cc996a7385286e74c2cf6a6d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5be2e44095f1fea0cc996a7385286e74c2cf6a6d

Author: Jarred Davies <[email protected]>
Date:   Tue Jan 31 08:06:25 2023 +0000

pvr: Add support for VK_KHR_timeline_semaphore

pvrsrvkm will run with VK_DEVICE_TIMELINE_MODE_EMULATED and
powervr will run with VK_DEVICE_TIMELINE_MODE_ASSISTED.

Signed-off-by: Jarred Davies <[email protected]>

Reviewed-by: Karmjit Mahil <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21577>

---

 src/imagination/vulkan/pvr_device.c              | 27 ++++++++++++++++++++++--
 src/imagination/vulkan/winsys/pvr_winsys.h       |  4 +++-
 src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c |  7 +++++-
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/imagination/vulkan/pvr_device.c 
b/src/imagination/vulkan/pvr_device.c
index 6ad7cf92a4e..b1465b2b8d8 100644
--- a/src/imagination/vulkan/pvr_device.c
+++ b/src/imagination/vulkan/pvr_device.c
@@ -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;
+      }
+      }
    }
 }
 
diff --git a/src/imagination/vulkan/winsys/pvr_winsys.h 
b/src/imagination/vulkan/winsys/pvr_winsys.h
index 973794f59a3..8c33737cad5 100644
--- a/src/imagination/vulkan/winsys/pvr_winsys.h
+++ b/src/imagination/vulkan/winsys/pvr_winsys.h
@@ -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;
 };
diff --git a/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c 
b/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c
index 56d3aa80faa..a67ad9ebb37 100644
--- a/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c
+++ b/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c
@@ -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)

Reply via email to