• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2024 Raspberry Pi Ltd
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #pragma once
7 
8 #include "util/hash_table.h"
9 
10 struct v3d_device_info;
11 
12 struct v3d_perfcntr_desc {
13         unsigned index;
14         const char *name;
15         const char *category;
16         const char *description;
17 };
18 
19 struct v3d_perfcntrs {
20         int fd;
21         unsigned max_perfcnt;
22         const struct v3d_device_info *devinfo;
23         struct v3d_perfcntr_desc **perfcnt;
24         struct hash_table *name_table;
25 };
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 struct v3d_perfcntrs *
32 v3d_perfcntrs_init(const struct v3d_device_info *devinfo, int fd);
33 
34 void
35 v3d_perfcntrs_fini(struct v3d_perfcntrs *perfcounters);
36 
37 static inline struct v3d_perfcntr_desc *
v3d_perfcntrs_get_by_index(struct v3d_perfcntrs * perfcounters,unsigned index)38 v3d_perfcntrs_get_by_index(struct v3d_perfcntrs *perfcounters, unsigned index)
39 {
40         if (index >= perfcounters->max_perfcnt)
41                 return NULL;
42 
43         return perfcounters->perfcnt[index];
44 }
45 
46 static inline struct v3d_perfcntr_desc *
v3d_perfcntrs_get_by_name(struct v3d_perfcntrs * perfcounters,const char * name)47 v3d_perfcntrs_get_by_name(struct v3d_perfcntrs *perfcounters, const char *name)
48 {
49         struct hash_entry *entry = _mesa_hash_table_search(perfcounters->name_table, name);
50 
51         return entry ? (struct v3d_perfcntr_desc *)entry->data : NULL;
52 }
53 
54 #ifdef __cplusplus
55 }
56 #endif
57