1 /**************************************************************************
3 * Copyright 2013 Marek Olšák <maraeo@gmail.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
31 #include "pipe/p_context.h"
32 #include "pipe/p_state.h"
33 #include "util/list.h"
35 #include "cso_cache/cso_context.h"
38 HUD_COUNTER_OFFLOADED
,
47 /* Context where queries are executed. */
48 struct pipe_context
*record_pipe
;
50 /* Context where the HUD is drawn: */
51 struct pipe_context
*pipe
;
52 struct cso_context
*cso
;
54 struct hud_batch_query_context
*batch_query
;
55 struct list_head pane_list
;
57 struct util_queue_monitoring
*monitored_queue
;
60 struct pipe_blend_state no_blend
, alpha_blend
;
61 struct pipe_depth_stencil_alpha_state dsa
;
62 void *fs_color
, *fs_text
;
63 struct pipe_rasterizer_state rasterizer
, rasterizer_aa_lines
;
65 struct cso_velems_state velems
;
68 struct util_font font
;
69 struct pipe_sampler_view
*font_sampler_view
;
70 struct pipe_sampler_state font_sampler_state
;
72 /* VS constant buffer */
75 float two_div_fb_width
;
76 float two_div_fb_height
;
81 struct pipe_constant_buffer constbuf
;
83 unsigned fb_width
, fb_height
;
85 /* vertices for text and background drawing are accumulated here and then
86 * drawn all at once */
89 struct pipe_vertex_buffer vbuf
;
90 unsigned max_num_vertices
;
91 unsigned num_vertices
;
93 } text
, bg
, whitelines
;
99 /* initialized by common code */
100 struct list_head head
;
101 struct hud_pane
*pane
;
103 float *vertices
; /* ring buffer of vertices */
108 void (*begin_query
)(struct hud_graph
*gr
, struct pipe_context
*pipe
);
109 void (*query_new_value
)(struct hud_graph
*gr
, struct pipe_context
*pipe
);
110 /* use this instead of ordinary free() */
111 void (*free_query_data
)(void *ptr
, struct pipe_context
*pipe
);
113 /* mutable variables */
114 unsigned num_vertices
;
115 unsigned index
; /* vertex index being updated */
116 double current_value
;
121 struct list_head head
;
122 struct hud_context
*hud
;
123 unsigned x1
, y1
, x2
, y2
, y_simple
;
128 unsigned inner_width
;
129 unsigned inner_height
;
131 unsigned max_num_vertices
;
132 unsigned last_line
; /* index of the last describing line in the graph */
134 uint64_t initial_max_value
;
136 unsigned dyn_ceil_last_ran
;
139 enum pipe_driver_query_type type
;
140 uint64_t period
; /* in microseconds */
142 struct list_head graph_list
;
149 void hud_pane_add_graph(struct hud_pane
*pane
, struct hud_graph
*gr
);
150 void hud_pane_set_max_value(struct hud_pane
*pane
, uint64_t value
);
151 void hud_graph_add_value(struct hud_graph
*gr
, double value
);
154 struct hud_batch_query_context
;
156 #define ALL_CPUS ~0 /* optionally set as cpu_index */
158 int hud_get_num_cpus(void);
160 void hud_fps_graph_install(struct hud_pane
*pane
);
161 void hud_frametime_graph_install(struct hud_pane
*pane
);
162 void hud_cpu_graph_install(struct hud_pane
*pane
, unsigned cpu_index
);
163 void hud_thread_busy_install(struct hud_pane
*pane
, const char *name
, bool main
);
164 void hud_thread_counter_install(struct hud_pane
*pane
, const char *name
,
165 enum hud_counter counter
);
166 void hud_pipe_query_install(struct hud_batch_query_context
**pbq
,
167 struct hud_pane
*pane
,
169 enum pipe_query_type query_type
,
170 unsigned result_index
,
172 enum pipe_driver_query_type type
,
173 enum pipe_driver_query_result_type result_type
,
175 boolean
hud_driver_query_install(struct hud_batch_query_context
**pbq
,
176 struct hud_pane
*pane
,
177 struct pipe_screen
*screen
, const char *name
);
178 void hud_batch_query_begin(struct hud_batch_query_context
*bq
,
179 struct pipe_context
*pipe
);
180 void hud_batch_query_update(struct hud_batch_query_context
*bq
,
181 struct pipe_context
*pipe
);
182 void hud_batch_query_cleanup(struct hud_batch_query_context
**pbq
,
183 struct pipe_context
*pipe
);
185 #ifdef HAVE_GALLIUM_EXTRA_HUD
186 int hud_get_num_nics(bool displayhelp
);
187 #define NIC_DIRECTION_RX 1
188 #define NIC_DIRECTION_TX 2
189 #define NIC_RSSI_DBM 3
190 void hud_nic_graph_install(struct hud_pane
*pane
, const char *nic_index
,
193 int hud_get_num_disks(bool displayhelp
);
194 #define DISKSTAT_RD 1
195 #define DISKSTAT_WR 2
196 void hud_diskstat_graph_install(struct hud_pane
*pane
, const char *dev_name
,
199 int hud_get_num_cpufreq(bool displayhelp
);
200 #define CPUFREQ_MINIMUM 1
201 #define CPUFREQ_CURRENT 2
202 #define CPUFREQ_MAXIMUM 3
203 void hud_cpufreq_graph_install(struct hud_pane
*pane
, int cpu_index
, unsigned int mode
);
206 #ifdef HAVE_LIBSENSORS
207 int hud_get_num_sensors(bool displayhelp
);
208 #define SENSORS_TEMP_CURRENT 1
209 #define SENSORS_TEMP_CRITICAL 2
210 #define SENSORS_VOLTAGE_CURRENT 3
211 #define SENSORS_CURRENT_CURRENT 4
212 #define SENSORS_POWER_CURRENT 5
213 void hud_sensors_temp_graph_install(struct hud_pane
*pane
, const char *dev_name
,