forked from 741g/vperfetto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vperfetto-min.h
70 lines (59 loc) · 3.13 KB
/
vperfetto-min.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2020 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdint.h>
#ifndef VPERFETTO_EXPORT
#ifdef _MSC_VER
#define VPERFETTO_EXPORT extern "C" __declspec(dllexport)
#else // _MSC_VER
#ifdef __cplusplus
#define VPERFETTO_EXPORT extern "C" __attribute__((visibility("default")))
#else
#define VPERFETTO_EXPORT __attribute__((visibility("default")))
#endif
#endif // !_MSC_VER
#endif // !VPERFETTO_EXPORT
// Categories that vperfetto_min is capable of tracking.
#define VPERFETTO_LIST_CATEGORIES(f) \
f(OpenGL, "OpenGL(ES) calls") \
f(Vulkan, "Vulkan calls") \
f(EGL, "EGL calls") \
f(Driver, "Driver internals") \
f(VMM, "VMM internals") \
f(gfx, "General graphics events that don't fall under the above categories") \
// Start tracing. This is meant to be triggered when tracing starts in the guest. Use your favorite transport,
// virtio-gpu, pipe, virtual perfetto, etc etc. Just somehow wire it up :)
enum vperfetto_init_flags {
VPERFETTO_INIT_FLAG_USE_INPROCESS_BACKEND = 1 << 0,
VPERFETTO_INIT_FLAG_USE_SYSTEM_BACKEND = 1 << 1,
};
typedef void (*on_tracing_state_change_t)(bool);
struct vperfetto_min_config {
on_tracing_state_change_t on_tracing_state_change;
enum vperfetto_init_flags init_flags;
const char* filename;
uint32_t shmem_size_hint_kb;
};
VPERFETTO_EXPORT void vperfetto_min_startTracing(const struct vperfetto_min_config* config);
// End tracing. This is meant to be triggerd when tracing ends in the guest. Again, use your favorite transport.
// This will also trigger trace saving. It is assumed that at around roughly this time, the host/guest also send over the finished trace from the guest to the host to the path specified in VPERFETTO_GUEST_FILE or traceconfig.guestFilename, such as via `adb pull /data/local/traces/guestfile.trace`.
// After waiting for a while, the guest/host traces are post processed and catted together into VPERFETTO_COMBINED_FILE.
VPERFETTO_EXPORT void vperfetto_min_endTracing();
// Start/end a particular track event on the host. By default, every such event is in the 'gfx' category.
VPERFETTO_EXPORT void vperfetto_min_beginTrackEvent(const char* eventName);
VPERFETTO_EXPORT void vperfetto_min_endTrackEvent();
// Start/end a particular track event in a particular category.
#define DEFINE_CATEGORY_TRACK_EVENT_DECLARATION(name, desc) \
VPERFETTO_EXPORT void vperfetto_min_beginTrackEvent_##name(const char* eventName); \
VPERFETTO_EXPORT void vperfetto_min_endTrackEvent_##name(); \
VPERFETTO_LIST_CATEGORIES(DEFINE_CATEGORY_TRACK_EVENT_DECLARATION)