freedreno: hw timestamp support
authorRob Clark <robclark@freedesktop.org>
Tue, 23 Feb 2016 17:03:43 +0000 (12:03 -0500)
committerRob Clark <robdclark@gmail.com>
Sat, 23 Jul 2016 17:39:30 +0000 (13:39 -0400)
If the kernel supports it, use hw counter for timestamps.

Signed-off-by: Rob Clark <robdclark@gmail.com>
configure.ac
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/freedreno/freedreno_screen.h

index bbc3af434243ed54de1e8420c9c06c0ff55b7254..5c196a93196371e7ce68043c34a4c3a74d26ac34 100644 (file)
@@ -74,7 +74,7 @@ LIBDRM_AMDGPU_REQUIRED=2.4.63
 LIBDRM_INTEL_REQUIRED=2.4.61
 LIBDRM_NVVIEUX_REQUIRED=2.4.66
 LIBDRM_NOUVEAU_REQUIRED=2.4.66
-LIBDRM_FREEDRENO_REQUIRED=2.4.67
+LIBDRM_FREEDRENO_REQUIRED=2.4.68
 LIBDRM_VC4_REQUIRED=2.4.69
 DRI2PROTO_REQUIRED=2.6
 DRI3PROTO_REQUIRED=1.0
index 81fb2adae424ea9fe208c1929018eb962c52a409..0aaa4d048997daae8daa903b9b99d750ffb75186 100644 (file)
@@ -109,8 +109,18 @@ fd_screen_get_device_vendor(struct pipe_screen *pscreen)
 static uint64_t
 fd_screen_get_timestamp(struct pipe_screen *pscreen)
 {
-       int64_t cpu_time = os_time_get() * 1000;
-       return cpu_time + fd_screen(pscreen)->cpu_gpu_time_delta;
+       struct fd_screen *screen = fd_screen(pscreen);
+
+       if (screen->has_timestamp) {
+               uint64_t n;
+               fd_pipe_get_param(screen->pipe, FD_TIMESTAMP, &n);
+               debug_assert(screen->max_freq > 0);
+               return n * 1000000000 / screen->max_freq;
+       } else {
+               int64_t cpu_time = os_time_get() * 1000;
+               return cpu_time + screen->cpu_gpu_time_delta;
+       }
+
 }
 
 static void
@@ -595,6 +605,8 @@ fd_screen_create(struct fd_device *dev)
                screen->max_freq = 0;
        } else {
                screen->max_freq = val;
+               if (fd_pipe_get_param(screen->pipe, FD_TIMESTAMP, &val) == 0)
+                       screen->has_timestamp = true;
        }
 
        if (fd_pipe_get_param(screen->pipe, FD_GPU_ID, &val)) {
index a81c77863902c8e051a036e0eb9c8f87cfb02967..0c899d5a7f07d2933241ad3509b8a9e5026300b3 100644 (file)
@@ -58,6 +58,7 @@ struct fd_screen {
        uint32_t chip_id;        /* coreid:8 majorrev:8 minorrev:8 patch:8 */
        uint32_t max_freq;
        uint32_t max_rts;        /* max # of render targets */
+       bool has_timestamp;
 
        void *compiler;          /* currently unused for a2xx */