• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2021 Google, Inc.
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #ifndef TU_PERFETTO_H_
7 #define TU_PERFETTO_H_
8 
9 #ifdef HAVE_PERFETTO
10 
11 /* we can't include tu_common.h because ir3 headers are not C++-compatible */
12 #include <stdint.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #define TU_PERFETTO_MAX_STACK_DEPTH 8
19 
20 struct tu_device;
21 struct tu_queue;
22 struct tu_u_trace_submission_data;
23 
24 struct tu_perfetto_stage {
25    int stage_id;
26    /* dynamically allocated stage iid, for app_events.  0 if stage_id should be
27     * used instead.
28     */
29    uint64_t stage_iid;
30    uint64_t start_ts;
31    const void* payload;
32    void* start_payload_function;
33 };
34 
35 struct tu_perfetto_state {
36    struct tu_perfetto_stage stages[TU_PERFETTO_MAX_STACK_DEPTH];
37    unsigned stage_depth;
38    unsigned skipped_depth;
39 };
40 
41 void tu_perfetto_init(void);
42 
43 struct tu_perfetto_clocks
44 {
45    uint64_t cpu;
46    uint64_t gpu_ts;
47    uint64_t gpu_ts_offset;
48 };
49 
50 uint64_t
51 tu_perfetto_begin_submit();
52 
53 struct tu_perfetto_clocks
54 tu_perfetto_end_submit(struct tu_queue *queue,
55                        uint32_t submission_id,
56                        uint64_t start_ts,
57                        struct tu_perfetto_clocks *clocks);
58 
59 void tu_perfetto_log_create_buffer(struct tu_device *dev, struct tu_buffer *buffer);
60 void tu_perfetto_log_bind_buffer(struct tu_device *dev, struct tu_buffer *buffer);
61 void tu_perfetto_log_destroy_buffer(struct tu_device *dev, struct tu_buffer *buffer);
62 
63 void tu_perfetto_log_create_image(struct tu_device *dev, struct tu_image *image);
64 void tu_perfetto_log_bind_image(struct tu_device *dev, struct tu_image *image);
65 void tu_perfetto_log_destroy_image(struct tu_device *dev, struct tu_image *image);
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif /* HAVE_PERFETTO */
72 
73 #endif /* TU_PERFETTO_H_ */
74