util/perf: add cpu_trace.h
Move MESA_TRACE_* to the new file. 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>
This commit is contained in:
@@ -95,8 +95,8 @@
|
||||
#include <string.h>
|
||||
#include "c11/threads.h"
|
||||
#include "util/debug.h"
|
||||
#include "util/log.h"
|
||||
#include "util/macros.h"
|
||||
#include "util/perf/cpu_trace.h"
|
||||
|
||||
#include "egldefines.h"
|
||||
#include "eglglobals.h"
|
||||
|
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "freedreno_priv.h"
|
||||
|
||||
#include "util/perf/cpu_trace.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/slab.h"
|
||||
#include "util/timespec.h"
|
||||
|
@@ -110,52 +110,4 @@ __mesa_log_use_args(UNUSED const char *format, ...) { }
|
||||
}
|
||||
#endif
|
||||
|
||||
/* NOTE: for now disable atrace for C++ to workaround a ndk bug with ordering
|
||||
* between stdatomic.h and atomic.h. See:
|
||||
*
|
||||
* https://github.com/android/ndk/issues/1178
|
||||
*/
|
||||
#if defined(ANDROID) && !defined(__cplusplus)
|
||||
|
||||
#include <cutils/trace.h>
|
||||
|
||||
#define MESA_TRACE_BEGIN(name) atrace_begin(ATRACE_TAG_GRAPHICS, name)
|
||||
#define MESA_TRACE_END() atrace_end(ATRACE_TAG_GRAPHICS)
|
||||
|
||||
#else
|
||||
|
||||
/* XXX we would like to use perfetto, but it lacks a C header */
|
||||
#define MESA_TRACE_BEGIN(name)
|
||||
#define MESA_TRACE_END()
|
||||
|
||||
#endif /* ANDROID */
|
||||
|
||||
#if __has_attribute(cleanup) && __has_attribute(unused)
|
||||
|
||||
#define MESA_TRACE_SCOPE(name) \
|
||||
int _mesa_trace_scope_##__LINE__ \
|
||||
__attribute__((cleanup(mesa_trace_scope_end), unused)) = \
|
||||
mesa_trace_scope_begin(name)
|
||||
|
||||
static inline int
|
||||
mesa_trace_scope_begin(const char *name)
|
||||
{
|
||||
MESA_TRACE_BEGIN(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
mesa_trace_scope_end(int *scope)
|
||||
{
|
||||
MESA_TRACE_END();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define MESA_TRACE_SCOPE(name)
|
||||
|
||||
#endif /* __has_attribute(cleanup) && __has_attribute(unused) */
|
||||
|
||||
#define MESA_TRACE_FUNC() MESA_TRACE_SCOPE(__func__)
|
||||
|
||||
#endif /* MESA_LOG_H */
|
||||
|
57
src/util/perf/cpu_trace.h
Normal file
57
src/util/perf/cpu_trace.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2022 Google LLC
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef CPU_TRACE_H
|
||||
#define CPU_TRACE_H
|
||||
|
||||
/* NOTE: for now disable atrace for C++ to workaround a ndk bug with ordering
|
||||
* between stdatomic.h and atomic.h. See:
|
||||
*
|
||||
* https://github.com/android/ndk/issues/1178
|
||||
*/
|
||||
#if defined(ANDROID) && !defined(__cplusplus)
|
||||
|
||||
#include <cutils/trace.h>
|
||||
|
||||
#define MESA_TRACE_BEGIN(name) atrace_begin(ATRACE_TAG_GRAPHICS, name)
|
||||
#define MESA_TRACE_END() atrace_end(ATRACE_TAG_GRAPHICS)
|
||||
|
||||
#else
|
||||
|
||||
/* XXX we would like to use perfetto, but it lacks a C header */
|
||||
#define MESA_TRACE_BEGIN(name)
|
||||
#define MESA_TRACE_END()
|
||||
|
||||
#endif /* ANDROID */
|
||||
|
||||
#if __has_attribute(cleanup) && __has_attribute(unused)
|
||||
|
||||
#define MESA_TRACE_SCOPE(name) \
|
||||
int _mesa_trace_scope_##__LINE__ \
|
||||
__attribute__((cleanup(mesa_trace_scope_end), unused)) = \
|
||||
mesa_trace_scope_begin(name)
|
||||
|
||||
static inline int
|
||||
mesa_trace_scope_begin(const char *name)
|
||||
{
|
||||
MESA_TRACE_BEGIN(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
mesa_trace_scope_end(int *scope)
|
||||
{
|
||||
MESA_TRACE_END();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define MESA_TRACE_SCOPE(name)
|
||||
|
||||
#endif /* __has_attribute(cleanup) && __has_attribute(unused) */
|
||||
|
||||
#define MESA_TRACE_FUNC() MESA_TRACE_SCOPE(__func__)
|
||||
|
||||
#endif /* CPU_TRACE_H */
|
Reference in New Issue
Block a user