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"
37 HUD_COUNTER_OFFLOADED
,
46 /* Context where queries are executed. */
47 struct pipe_context
*record_pipe
;
49 /* Context where the HUD is drawn: */
50 struct pipe_context
*pipe
;
51 struct cso_context
*cso
;
53 struct hud_batch_query_context
*batch_query
;
54 struct list_head pane_list
;
56 struct util_queue_monitoring
*monitored_queue
;
59 struct pipe_blend_state no_blend
, alpha_blend
;
60 struct pipe_depth_stencil_alpha_state dsa
;
61 void *fs_color
, *fs_text
;
62 struct pipe_rasterizer_state rasterizer
, rasterizer_aa_lines
;
64 struct pipe_vertex_element velems
[2];
67 struct util_font font
;
68 struct pipe_sampler_view
*font_sampler_view
;
69 struct pipe_sampler_state font_sampler_state
;
71 /* VS constant buffer */
74 float two_div_fb_width
;
75 float two_div_fb_height
;
80 struct pipe_constant_buffer constbuf
;
82 unsigned fb_width
, fb_height
;
84 /* vertices for text and background drawing are accumulated here and then
85 * drawn all at once */
88 struct pipe_vertex_buffer vbuf
;
89 unsigned max_num_vertices
;
90 unsigned num_vertices
;
92 } text
, bg
, whitelines
, color_prims
;
98 /* initialized by common code */
99 struct list_head head
;
100 struct hud_pane
*pane
;
102 float *vertices
; /* ring buffer of vertices */
107 void (*begin_query
)(struct hud_graph
*gr
, struct pipe_context
*pipe
);
108 void (*query_new_value
)(struct hud_graph
*gr
, struct pipe_context
*pipe
);
109 /* use this instead of ordinary free() */
110 void (*free_query_data
)(void *ptr
, struct pipe_context
*pipe
);
112 /* mutable variables */
113 unsigned num_vertices
;
114 unsigned index
; /* vertex index being updated */
115 double current_value
;
120 struct list_head head
;
121 struct hud_context
*hud
;
122 unsigned x1
, y1
, x2
, y2
, y_simple
;
127 unsigned inner_width
;
128 unsigned inner_height
;
130 unsigned max_num_vertices
;
131 unsigned last_line
; /* index of the last describing line in the graph */
133 uint64_t initial_max_value
;
135 unsigned dyn_ceil_last_ran
;
138 enum pipe_driver_query_type type
;
139 uint64_t period
; /* in microseconds */
141 struct list_head graph_list
;
148 void hud_pane_add_graph(struct hud_pane
*pane
, struct hud_graph
*gr
);
149 void hud_pane_set_max_value(struct hud_pane
*pane
, uint64_t value
);
150 void hud_graph_add_value(struct hud_graph
*gr
, double value
);
153 struct hud_batch_query_context
;
155 #define ALL_CPUS ~0 /* optionally set as cpu_index */
157 int hud_get_num_cpus(void);
159 void hud_fps_graph_install(struct hud_pane
*pane
);
160 void hud_frametime_graph_install(struct hud_pane
*pane
);
161 void hud_cpu_graph_install(struct hud_pane
*pane
, unsigned cpu_index
);
162 void hud_thread_busy_install(struct hud_pane
*pane
, const char *name
, bool main
);
163 void hud_thread_counter_install(struct hud_pane
*pane
, const char *name
,
164 enum hud_counter counter
);
165 void hud_pipe_query_install(struct hud_batch_query_context
**pbq
,
166 struct hud_pane
*pane
,
168 enum pipe_query_type query_type
,
169 unsigned result_index
,
171 enum pipe_driver_query_type type
,
172 enum pipe_driver_query_result_type result_type
,
174 boolean
hud_driver_query_install(struct hud_batch_query_context
**pbq
,
175 struct hud_pane
*pane
,
176 struct pipe_screen
*screen
, const char *name
);
177 void hud_batch_query_begin(struct hud_batch_query_context
*bq
,
178 struct pipe_context
*pipe
);
179 void hud_batch_query_update(struct hud_batch_query_context
*bq
,
180 struct pipe_context
*pipe
);
181 void hud_batch_query_cleanup(struct hud_batch_query_context
**pbq
,
182 struct pipe_context
*pipe
);
184 #ifdef HAVE_GALLIUM_EXTRA_HUD
185 int hud_get_num_nics(bool displayhelp
);
186 #define NIC_DIRECTION_RX 1
187 #define NIC_DIRECTION_TX 2
188 #define NIC_RSSI_DBM 3
189 void hud_nic_graph_install(struct hud_pane
*pane
, const char *nic_index
,
192 int hud_get_num_disks(bool displayhelp
);
193 #define DISKSTAT_RD 1
194 #define DISKSTAT_WR 2
195 void hud_diskstat_graph_install(struct hud_pane
*pane
, const char *dev_name
,
198 int hud_get_num_cpufreq(bool displayhelp
);
199 #define CPUFREQ_MINIMUM 1
200 #define CPUFREQ_CURRENT 2
201 #define CPUFREQ_MAXIMUM 3
202 void hud_cpufreq_graph_install(struct hud_pane
*pane
, int cpu_index
, unsigned int mode
);
205 #ifdef HAVE_LIBSENSORS
206 int hud_get_num_sensors(bool displayhelp
);
207 #define SENSORS_TEMP_CURRENT 1
208 #define SENSORS_TEMP_CRITICAL 2
209 #define SENSORS_VOLTAGE_CURRENT 3
210 #define SENSORS_CURRENT_CURRENT 4
211 #define SENSORS_POWER_CURRENT 5
212 void hud_sensors_temp_graph_install(struct hud_pane
*pane
, const char *dev_name
,