mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 04:40:09 +01:00
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:
parent
19b7d5284b
commit
022cd156d4
4 changed files with 59 additions and 49 deletions
|
|
@ -95,8 +95,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "c11/threads.h"
|
#include "c11/threads.h"
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
#include "util/log.h"
|
|
||||||
#include "util/macros.h"
|
#include "util/macros.h"
|
||||||
|
#include "util/perf/cpu_trace.h"
|
||||||
|
|
||||||
#include "egldefines.h"
|
#include "egldefines.h"
|
||||||
#include "eglglobals.h"
|
#include "eglglobals.h"
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "freedreno_priv.h"
|
#include "freedreno_priv.h"
|
||||||
|
|
||||||
|
#include "util/perf/cpu_trace.h"
|
||||||
#include "util/u_atomic.h"
|
#include "util/u_atomic.h"
|
||||||
#include "util/slab.h"
|
#include "util/slab.h"
|
||||||
#include "util/timespec.h"
|
#include "util/timespec.h"
|
||||||
|
|
|
||||||
|
|
@ -110,52 +110,4 @@ __mesa_log_use_args(UNUSED const char *format, ...) { }
|
||||||
}
|
}
|
||||||
#endif
|
#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 */
|
#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 */
|
||||||
Loading…
Add table
Reference in a new issue