venus: use MESA_TRACE_*
authorChia-I Wu <olvaffe@gmail.com>
Thu, 25 Aug 2022 22:49:37 +0000 (15:49 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 26 Aug 2022 21:47:44 +0000 (21:47 +0000)
Acked-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18260>

src/virtio/vulkan/vn_common.h

index 12994ec..69a49f1 100644 (file)
@@ -30,6 +30,7 @@
 #include "util/list.h"
 #include "util/macros.h"
 #include "util/os_time.h"
+#include "util/perf/cpu_trace.h"
 #include "util/simple_mtx.h"
 #include "util/u_math.h"
 #include "util/xmlconfig.h"
 #define vn_result(instance, result)                                          \
    ((result) >= VK_SUCCESS ? (result) : vn_error((instance), (result)))
 
-#ifdef ANDROID
-
-#include <cutils/trace.h>
-
-#define VN_TRACE_BEGIN(name) atrace_begin(ATRACE_TAG_GRAPHICS, name)
-#define VN_TRACE_END() atrace_end(ATRACE_TAG_GRAPHICS)
-
-#else
-
-/* XXX we would like to use perfetto, but it lacks a C header */
-#define VN_TRACE_BEGIN(name)
-#define VN_TRACE_END()
-
-#endif /* ANDROID */
-
-#if __has_attribute(cleanup) && __has_attribute(unused)
-
-#define VN_TRACE_SCOPE_VAR_CONCAT(name, suffix) name##suffix
-#define VN_TRACE_SCOPE_VAR(suffix)                                           \
-   VN_TRACE_SCOPE_VAR_CONCAT(_vn_trace_scope_, suffix)
-#define VN_TRACE_SCOPE(name)                                                 \
-   int VN_TRACE_SCOPE_VAR(__LINE__)                                          \
-      __attribute__((cleanup(vn_trace_scope_end), unused)) =                 \
-         vn_trace_scope_begin(name)
-
-static inline int
-vn_trace_scope_begin(const char *name)
-{
-   VN_TRACE_BEGIN(name);
-   return 0;
-}
-
-static inline void
-vn_trace_scope_end(int *scope)
-{
-   VN_TRACE_END();
-}
-
-#else
-
-#define VN_TRACE_SCOPE(name)
-
-#endif /* __has_attribute(cleanup) && __has_attribute(unused) */
-
-#define VN_TRACE_FUNC() VN_TRACE_SCOPE(__func__)
+#define VN_TRACE_BEGIN(name) MESA_TRACE_BEGIN(name)
+#define VN_TRACE_END() MESA_TRACE_END()
+#define VN_TRACE_SCOPE(name) MESA_TRACE_SCOPE(name)
+#define VN_TRACE_FUNC() MESA_TRACE_SCOPE(__func__)
 
 struct vn_instance;
 struct vn_physical_device;