xref: /aosp_15_r20/external/mesa3d/src/intel/perf/intel_perf_query.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2019 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef INTEL_PERF_QUERY_H
25 #define INTEL_PERF_QUERY_H
26 
27 #include <stdint.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 struct intel_device_info;
34 
35 struct intel_perf_config;
36 struct intel_perf_context;
37 struct intel_perf_query_object;
38 
39 bool
40 intel_perf_open(struct intel_perf_context *perf_ctx,
41                 int metrics_set_id,
42                 uint64_t report_format,
43                 int period_exponent,
44                 int drm_fd,
45                 uint32_t ctx_id,
46                 bool enable);
47 
48 void
49 intel_perf_close(struct intel_perf_context *perfquery,
50                  const struct intel_perf_query_info *query);
51 
52 bool intel_perf_oa_stream_ready(struct intel_perf_context *perf_ctx);
53 
54 ssize_t
55 intel_perf_read_oa_stream(struct intel_perf_context *perf_ctx,
56                           void* buf,
57                           size_t nbytes);
58 
59 struct intel_perf_context *intel_perf_new_context(void *parent);
60 
61 void intel_perf_free_context(struct intel_perf_context *perf_ctx);
62 
63 void intel_perf_init_context(struct intel_perf_context *perf_ctx,
64                              struct intel_perf_config *perf_cfg,
65                              void * mem_ctx, /* ralloc context */
66                              void * ctx,  /* driver context (eg, brw_context) */
67                              void * bufmgr,  /* eg brw_bufmgr */
68                              const struct intel_device_info *devinfo,
69                              uint32_t hw_ctx,
70                              int drm_fd);
71 
72 const struct intel_perf_query_info* intel_perf_query_info(const struct intel_perf_query_object *);
73 
74 struct intel_perf_config *intel_perf_config(struct intel_perf_context *ctx);
75 
76 int intel_perf_active_queries(struct intel_perf_context *perf_ctx,
77                             const struct intel_perf_query_info *query);
78 
79 struct intel_perf_query_object *
80 intel_perf_new_query(struct intel_perf_context *, unsigned query_index);
81 
82 
83 bool intel_perf_begin_query(struct intel_perf_context *perf_ctx,
84                             struct intel_perf_query_object *query);
85 void intel_perf_end_query(struct intel_perf_context *perf_ctx,
86                           struct intel_perf_query_object *query);
87 void intel_perf_wait_query(struct intel_perf_context *perf_ctx,
88                            struct intel_perf_query_object *query,
89                            void *current_batch);
90 bool intel_perf_is_query_ready(struct intel_perf_context *perf_ctx,
91                                struct intel_perf_query_object *query,
92                                void *current_batch);
93 void intel_perf_delete_query(struct intel_perf_context *perf_ctx,
94                              struct intel_perf_query_object *query);
95 void intel_perf_get_query_data(struct intel_perf_context *perf_ctx,
96                                struct intel_perf_query_object *query,
97                                void *current_batch,
98                                int data_size,
99                                unsigned *data,
100                                unsigned *bytes_written);
101 
102 void intel_perf_dump_query_count(struct intel_perf_context *perf_ctx);
103 void intel_perf_dump_query(struct intel_perf_context *perf_ctx,
104                            struct intel_perf_query_object *obj,
105                            void *current_batch);
106 
107 #ifdef __cplusplus
108 } // extern "C"
109 #endif
110 
111 #endif /* INTEL_PERF_QUERY_H */
112