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 GEN_PERF_QUERY_H
25 #define GEN_PERF_QUERY_H
26 
27 #include <stdint.h>
28 
29 struct gen_device_info;
30 
31 struct gen_perf_config;
32 struct gen_perf_context;
33 struct gen_perf_query_object;
34 
35 struct gen_perf_context *gen_perf_new_context(void *parent);
36 
37 void gen_perf_init_context(struct gen_perf_context *perf_ctx,
38                            struct gen_perf_config *perf_cfg,
39                            void * ctx,  /* driver context (eg, brw_context) */
40                            void * bufmgr,  /* eg brw_bufmgr */
41                            const struct gen_device_info *devinfo,
42                            uint32_t hw_ctx,
43                            int drm_fd);
44 
45 const struct gen_perf_query_info* gen_perf_query_info(const struct gen_perf_query_object *);
46 
47 
48 void gen_perf_init_context(struct gen_perf_context *perf_ctx,
49                            struct gen_perf_config *perf_cfg,
50                            void * ctx,  /* driver context (eg, brw_context) */
51                            void * bufmgr,  /* eg brw_bufmgr */
52                            const struct gen_device_info *devinfo,
53                            uint32_t hw_ctx,
54                            int drm_fd);
55 
56 struct gen_perf_config *gen_perf_config(struct gen_perf_context *ctx);
57 
58 int gen_perf_active_queries(struct gen_perf_context *perf_ctx,
59                             const struct gen_perf_query_info *query);
60 
61 struct gen_perf_query_object *
62 gen_perf_new_query(struct gen_perf_context *, unsigned query_index);
63 
64 
65 bool gen_perf_begin_query(struct gen_perf_context *perf_ctx,
66                           struct gen_perf_query_object *query);
67 void gen_perf_end_query(struct gen_perf_context *perf_ctx,
68                         struct gen_perf_query_object *query);
69 void gen_perf_wait_query(struct gen_perf_context *perf_ctx,
70                          struct gen_perf_query_object *query,
71                          void *current_batch);
72 bool gen_perf_is_query_ready(struct gen_perf_context *perf_ctx,
73                              struct gen_perf_query_object *query,
74                              void *current_batch);
75 void gen_perf_delete_query(struct gen_perf_context *perf_ctx,
76                            struct gen_perf_query_object *query);
77 void gen_perf_get_query_data(struct gen_perf_context *perf_ctx,
78                              struct gen_perf_query_object *query,
79                              void *current_batch,
80                              int data_size,
81                              unsigned *data,
82                              unsigned *bytes_written);
83 
84 void gen_perf_dump_query_count(struct gen_perf_context *perf_ctx);
85 void gen_perf_dump_query(struct gen_perf_context *perf_ctx,
86                          struct gen_perf_query_object *obj,
87                          void *current_batch);
88 
89 #endif /* GEN_PERF_QUERY_H */
90