tracing

Change-Id: Ib54b0d253bde31e4ea76b2ddb1631fbf3a814529
diff --git a/src/vulkan/wsi/BUILD.gn b/src/vulkan/wsi/BUILD.gn
index 1f6201c..2ec0ba7 100644
--- a/src/vulkan/wsi/BUILD.gn
+++ b/src/vulkan/wsi/BUILD.gn
@@ -37,6 +37,10 @@
     "$magma_build_root/include:sys_abi",
     "$magma_build_root/src/magma_util",
     "$mesa_build_root/include:vulkan",
-    "$mesa_build_root/src/util" 
+    "$mesa_build_root/src/util",
+    "$magma_build_root/src/magma_util/platform:trace",
+    "//apps/tracing/lib/trace",
+
+
   ]
 }
diff --git a/src/vulkan/wsi/wsi_common_magma.cc b/src/vulkan/wsi/wsi_common_magma.cc
index 570e063..da31b7c 100644
--- a/src/vulkan/wsi/wsi_common_magma.cc
+++ b/src/vulkan/wsi/wsi_common_magma.cc
@@ -11,6 +11,8 @@
 #include "magma_system.h"
 #include "magma_util/dlog.h"
 #include "magma_util/macros.h"
+#include "apps/tracing/lib/trace/event.h"
+#include "platform_trace.h"
 
 #define typed_memcpy(dest, src, count)                                                             \
    ({                                                                                              \
@@ -131,6 +133,8 @@
       this->get_images = GetImages;
       this->acquire_next_image = AcquireNextImage;
       this->queue_present = QueuePresent;
+
+      magma::PlatformTrace::GetInstance();
    }
 
    magma_system_connection* connection() { return connection_; }
@@ -183,14 +187,19 @@
 
       uint32_t index = chain->next_index_;
       MagmaImage* image = chain->get_image(index);
-      DLOG("AcquireNextImage semaphore id 0x%" PRIx64,
-           magma_system_get_semaphore_id(image->semaphore()));
+      auto id = magma_system_get_semaphore_id(image->semaphore());
+      DLOG("AcquireNextImage semaphore id 0x%" PRIx64, id);
+
+
+      uint64_t nonce = TRACE_NONCE();
+      TRACE_ASYNC_BEGIN("magma", "AcquireNextImage Wait", nonce);
 
       magma_status_t status = magma_system_wait_semaphore(image->semaphore(), timeout);
       if (status == MAGMA_STATUS_TIMED_OUT) {
          DLOG("timeout waiting for image semaphore");
          return VK_TIMEOUT;
       }
+      TRACE_ASYNC_END("magma", "AcquireNextImage Wait", nonce);
 
       assert(status == MAGMA_STATUS_OK);