mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 19:40:10 +01:00
venus: add atrace support
Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Ryan Neph <ryanneph@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13255>
This commit is contained in:
parent
2881b43d2c
commit
6df3973b61
4 changed files with 56 additions and 0 deletions
|
|
@ -40,6 +40,14 @@ vn_debug_init(void)
|
|||
call_once(&once, vn_debug_init_once);
|
||||
}
|
||||
|
||||
void
|
||||
vn_trace_init(void)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
atrace_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
vn_log(struct vn_instance *instance, const char *format, ...)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,6 +49,49 @@
|
|||
#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(name) \
|
||||
int _vn_trace_scope_##__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__)
|
||||
|
||||
struct vn_instance;
|
||||
struct vn_physical_device;
|
||||
struct vn_device;
|
||||
|
|
@ -127,6 +170,9 @@ extern uint64_t vn_debug;
|
|||
void
|
||||
vn_debug_init(void);
|
||||
|
||||
void
|
||||
vn_trace_init(void);
|
||||
|
||||
void
|
||||
vn_log(struct vn_instance *instance, const char *format, ...)
|
||||
PRINTFLIKE(2, 3);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ VkResult
|
|||
vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion)
|
||||
{
|
||||
vn_debug_init();
|
||||
vn_trace_init();
|
||||
|
||||
vn_icd_version = MIN2(vn_icd_version, *pSupportedVersion);
|
||||
if (VN_DEBUG(INIT))
|
||||
|
|
|
|||
|
|
@ -697,6 +697,7 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
VkResult result;
|
||||
|
||||
vn_debug_init();
|
||||
vn_trace_init();
|
||||
|
||||
instance = vk_zalloc(alloc, sizeof(*instance), VN_DEFAULT_ALIGN,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue