This extension adds a single function to query the current GPU
timestamp, just like glGetInteger64v(GL_TIMESTAMP, &timestamp). This
function is needed to complete the implementation of
GOOGLE_display_timing, which needs to be able to correlate GPU and CPU
timestamps.

Signed-off-by: Keith Packard <kei...@keithp.com>

v2:     Update to track extension API that now returns both device and
        surface timestamps.
---
 src/amd/vulkan/radv_device.c      | 21 +++++++++++++++++++++
 src/amd/vulkan/radv_extensions.py |  1 +
 src/amd/vulkan/radv_private.h     |  1 +
 3 files changed, 23 insertions(+)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index ad3465f594e..2ea208f7d6f 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -4772,3 +4772,24 @@ radv_GetDeviceGroupPeerMemoryFeatures(
                               VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT |
                               VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT;
 }
+
+VkResult radv_QueryCurrentTimestampMESA(VkDevice _device, VkSurfaceKHR 
_surface,
+                                       VkCurrentTimestampMESA *timestamp)
+{
+       RADV_FROM_HANDLE(radv_device, device, _device);
+       VkResult result;
+
+       timestamp->deviceTimestamp = device->ws->query_value(device->ws,
+                                                            RADEON_TIMESTAMP);
+
+       result = wsi_common_convert_timestamp(
+               &device->physical_device->wsi_device,
+               _device,
+               _surface,
+               radv_get_current_time(),
+               &timestamp->surfaceTimestamp);
+       if (result != VK_SUCCESS)
+               return result;
+
+       return VK_SUCCESS;
+}
diff --git a/src/amd/vulkan/radv_extensions.py 
b/src/amd/vulkan/radv_extensions.py
index a0f1038110b..e5e6f25fca1 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -108,6 +108,7 @@ EXTENSIONS = [
     Extension('VK_AMD_shader_core_properties',            1, True),
     Extension('VK_AMD_shader_info',                       1, True),
     Extension('VK_AMD_shader_trinary_minmax',             1, True),
+    Extension('VK_MESA_query_timestamp',                  1, True),
 ]
 
 class VkVersion:
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index df335b43d8d..fe895ac777c 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -75,6 +75,7 @@ typedef uint32_t xcb_window_t;
 #include <vulkan/vulkan_intel.h>
 #include <vulkan/vk_icd.h>
 #include <vulkan/vk_android_native_buffer.h>
+#include <vulkan/vk_mesa_query_timestamp.h>
 
 #include "radv_entrypoints.h"
 
-- 
2.17.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to