xref: /aosp_15_r20/external/mesa3d/src/freedreno/drm/freedreno_drm_perfetto.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2024 Google, Inc.
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #ifndef FREEDRENO_DRM_PERFETTO_H_
7 #define FREEDRENO_DRM_PERFETTO_H_
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /**
14  * Memory events are logged as transition between allocation categories.
15  * Ie. a new allocation from kernel would be NONE -> ACTIVE, while a
16  * freed buffer going to the BO cache would be ACTIVE -> CACHE, and then
17  * if it is eventually freed from the cache, CACHE -> NONE.
18  */
19 enum fd_alloc_category {
20    FD_ALLOC_NONE,       /* freed / not allocated */
21    FD_ALLOC_HEAP,       /* unused bo heap memory */
22    FD_ALLOC_CACHE,      /* unused bo cache memory */
23    FD_ALLOC_ACTIVE,     /* actively used */
24 };
25 
26 struct fd_bo;
27 
28 #ifdef HAVE_PERFETTO
29 void fd_drm_perfetto_init(void);
30 void fd_alloc_log(struct fd_bo *bo, enum fd_alloc_category from, enum fd_alloc_category to);
31 #else
32 static inline void
fd_drm_perfetto_init(void)33 fd_drm_perfetto_init(void)
34 {
35 }
36 static inline void
fd_alloc_log(struct fd_bo * bo,enum fd_alloc_category from,enum fd_alloc_category to)37 fd_alloc_log(struct fd_bo *bo, enum fd_alloc_category from, enum fd_alloc_category to)
38 {
39 }
40 #endif
41 
42 #ifdef __cplusplus
43 } /* end of extern "C" */
44 #endif
45 
46 #endif /* FREEDRENO_DRM_PERFETTO_H_ */
47