egl: atrace support
Perfetto is showing mutex contention on disp->Mutex when multiple threads are making egl calls on their own current context. This makes it easier to see what is contending with what. Signed-off-by: Rob Clark <robdclark@chromium.org> Acked-by: Eric Engestrom <eric@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18111>
This commit is contained in:
@@ -95,6 +95,7 @@
|
||||
#include <string.h>
|
||||
#include "c11/threads.h"
|
||||
#include "util/debug.h"
|
||||
#include "util/log.h"
|
||||
#include "util/macros.h"
|
||||
|
||||
#include "egldefines.h"
|
||||
@@ -282,6 +283,7 @@ _eglSetFuncName(const char *funcName, _EGLDisplay *disp, EGLenum objectType, _EG
|
||||
|
||||
#define _EGL_FUNC_START(disp, objectType, object, ret) \
|
||||
do { \
|
||||
MESA_TRACE_FUNC(); \
|
||||
if (!_eglSetFuncName(__func__, disp, objectType, (_EGLResource *) object)) { \
|
||||
if (disp) \
|
||||
_eglUnlockDisplay(disp); \
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "c11/threads.h"
|
||||
#include "util/u_thread.h"
|
||||
#include "util/u_string.h"
|
||||
|
||||
@@ -110,4 +110,52 @@ __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 */
|
||||
|
||||
Reference in New Issue
Block a user