add percetto tracing option

Percetto is available at:
https://github.com/olvaffe/percetto

Signed-off-by: John Bates <jbates@chromium.org>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
macos/master
John Bates 4 years ago
parent 0621329415
commit e64afcf897
  1. 8
      meson.build
  2. 2
      meson_options.txt
  3. 4
      src/meson.build
  4. 9
      src/virgl_util.c
  5. 29
      src/virgl_util.h

@ -91,6 +91,14 @@ endif
endif endif
if with_tracing == 'percetto'
# percetto uses C++ internally, so we need to link with C++.
# TODO: remove -lstdc++ when percetto is a shared library.
add_project_link_arguments('-lstdc++', language : 'c')
percetto_dep = dependency('percetto', version : '>=0.0.8')
conf_data.set('ENABLE_TRACING', 'TRACE_WITH_PERCETTO')
endif
if with_tracing == 'perfetto' if with_tracing == 'perfetto'
vperfetto_min_dep = dependency('vperfetto_min') vperfetto_min_dep = dependency('vperfetto_min')
conf_data.set('ENABLE_TRACING', 'TRACE_WITH_PERFETTO') conf_data.set('ENABLE_TRACING', 'TRACE_WITH_PERFETTO')

@ -63,6 +63,6 @@ option(
'tracing', 'tracing',
type : 'combo', type : 'combo',
value : 'none', value : 'none',
choices : [ 'perfetto', 'stderr', 'none' ], choices : [ 'percetto', 'perfetto', 'stderr', 'none' ],
description : 'enable emitting traces using the selected backend' description : 'enable emitting traces using the selected backend'
) )

@ -86,6 +86,10 @@ if with_tracing == 'perfetto'
virgl_depends += [vperfetto_min_dep] virgl_depends += [vperfetto_min_dep]
endif endif
if with_tracing == 'percetto'
virgl_depends += [percetto_dep]
endif
virgl_sources += vrend_sources virgl_sources += vrend_sources
if have_egl if have_egl

@ -114,6 +114,15 @@ void flush_eventfd(int fd)
} while ((len == -1 && errno == EINTR) || len == sizeof(value)); } while ((len == -1 && errno == EINTR) || len == sizeof(value));
} }
#if ENABLE_TRACING == TRACE_WITH_PERCETTO
PERCETTO_CATEGORY_DEFINE(VIRGL_PERCETTO_CATEGORIES)
void trace_init(void)
{
PERCETTO_INIT(PERCETTO_CLOCK_DONT_CARE);
}
#endif
#if ENABLE_TRACING == TRACE_WITH_PERFETTO #if ENABLE_TRACING == TRACE_WITH_PERFETTO
void trace_init(void) void trace_init(void)
{ {

@ -34,6 +34,7 @@
#define TRACE_WITH_PERFETTO 1 #define TRACE_WITH_PERFETTO 1
#define TRACE_WITH_STDERR 2 #define TRACE_WITH_STDERR 2
#define TRACE_WITH_PERCETTO 3
#define BIT(n) (UINT32_C(1) << (n)) #define BIT(n) (UINT32_C(1) << (n))
@ -63,20 +64,42 @@ void flush_eventfd(int fd);
#ifdef ENABLE_TRACING #ifdef ENABLE_TRACING
void trace_init(void); void trace_init(void);
const char *trace_begin(const char *scope);
void trace_end(const char **dummy);
#define TRACE_INIT() trace_init() #define TRACE_INIT() trace_init()
#define TRACE_FUNC() TRACE_SCOPE(__func__) #define TRACE_FUNC() TRACE_SCOPE(__func__)
#if ENABLE_TRACING == TRACE_WITH_PERCETTO
#include <percetto.h>
#define VIRGL_PERCETTO_CATEGORIES(C, G) \
C(virgl, "virglrenderer") \
C(virgls, "virglrenderer detailed events", "slow")
PERCETTO_CATEGORY_DECLARE(VIRGL_PERCETTO_CATEGORIES)
#define TRACE_SCOPE(SCOPE) TRACE_EVENT(virgl, SCOPE)
/* Trace high frequency events (tracing may impact performance). */
#define TRACE_SCOPE_SLOW(SCOPE) TRACE_EVENT(virgls, SCOPE)
#else
const char *trace_begin(const char *scope);
void trace_end(const char **scope);
#define TRACE_SCOPE(SCOPE) \ #define TRACE_SCOPE(SCOPE) \
const char *trace_dummy __attribute__((cleanup (trace_end), unused)) = \ const char *trace_dummy __attribute__((cleanup (trace_end), unused)) = \
trace_begin(SCOPE) trace_begin(SCOPE)
#define TRACE_SCOPE_SLOW(SCOPE) TRACE_SCOPE(SCOPE)
#endif /* ENABLE_TRACING == TRACE_WITH_PERCETTO */
#else #else
#define TRACE_INIT() #define TRACE_INIT()
#define TRACE_FUNC() #define TRACE_FUNC()
#define TRACE_SCOPE(SCOPE) #define TRACE_SCOPE(SCOPE)
#endif #define TRACE_SCOPE_SLOW(SCOPE)
#endif /* ENABLE_TRACING */
#endif /* VIRGL_UTIL_H */ #endif /* VIRGL_UTIL_H */

Loading…
Cancel
Save