1af69d88dSmrg/************************************************************************** 2af69d88dSmrg * 3af69d88dSmrg * Copyright 2013 Marek Olšák <maraeo@gmail.com> 4af69d88dSmrg * All Rights Reserved. 5af69d88dSmrg * 6af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a 7af69d88dSmrg * copy of this software and associated documentation files (the 8af69d88dSmrg * "Software"), to deal in the Software without restriction, including 9af69d88dSmrg * without limitation the rights to use, copy, modify, merge, publish, 10af69d88dSmrg * distribute, sub license, and/or sell copies of the Software, and to 11af69d88dSmrg * permit persons to whom the Software is furnished to do so, subject to 12af69d88dSmrg * the following conditions: 13af69d88dSmrg * 14af69d88dSmrg * The above copyright notice and this permission notice (including the 15af69d88dSmrg * next paragraph) shall be included in all copies or substantial portions 16af69d88dSmrg * of the Software. 17af69d88dSmrg * 18af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19af69d88dSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20af69d88dSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21af69d88dSmrg * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR 22af69d88dSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23af69d88dSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24af69d88dSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25af69d88dSmrg * 26af69d88dSmrg **************************************************************************/ 27af69d88dSmrg 28af69d88dSmrg#ifndef HUD_PRIVATE_H 29af69d88dSmrg#define HUD_PRIVATE_H 30af69d88dSmrg 31af69d88dSmrg#include "pipe/p_context.h" 3201e04c3fSmrg#include "pipe/p_state.h" 3301e04c3fSmrg#include "util/list.h" 3401e04c3fSmrg#include "hud/font.h" 357ec681f3Smrg#include "cso_cache/cso_context.h" 3601e04c3fSmrg 3701e04c3fSmrgenum hud_counter { 3801e04c3fSmrg HUD_COUNTER_OFFLOADED, 3901e04c3fSmrg HUD_COUNTER_DIRECT, 4001e04c3fSmrg HUD_COUNTER_SYNCS, 4101e04c3fSmrg}; 4201e04c3fSmrg 4301e04c3fSmrgstruct hud_context { 4401e04c3fSmrg int refcount; 4501e04c3fSmrg bool simple; 4601e04c3fSmrg 4701e04c3fSmrg /* Context where queries are executed. */ 4801e04c3fSmrg struct pipe_context *record_pipe; 4901e04c3fSmrg 5001e04c3fSmrg /* Context where the HUD is drawn: */ 5101e04c3fSmrg struct pipe_context *pipe; 5201e04c3fSmrg struct cso_context *cso; 537ec681f3Smrg struct st_context_iface *st; 5401e04c3fSmrg 5501e04c3fSmrg struct hud_batch_query_context *batch_query; 5601e04c3fSmrg struct list_head pane_list; 5701e04c3fSmrg 5801e04c3fSmrg struct util_queue_monitoring *monitored_queue; 5901e04c3fSmrg 6001e04c3fSmrg /* states */ 6101e04c3fSmrg struct pipe_blend_state no_blend, alpha_blend; 6201e04c3fSmrg struct pipe_depth_stencil_alpha_state dsa; 6301e04c3fSmrg void *fs_color, *fs_text; 6401e04c3fSmrg struct pipe_rasterizer_state rasterizer, rasterizer_aa_lines; 657ec681f3Smrg void *vs_color, *vs_text; 667ec681f3Smrg struct cso_velems_state velems; 6701e04c3fSmrg 6801e04c3fSmrg /* font */ 6901e04c3fSmrg struct util_font font; 7001e04c3fSmrg struct pipe_sampler_view *font_sampler_view; 7101e04c3fSmrg struct pipe_sampler_state font_sampler_state; 7201e04c3fSmrg 7301e04c3fSmrg /* VS constant buffer */ 7401e04c3fSmrg struct { 7501e04c3fSmrg float color[4]; 7601e04c3fSmrg float two_div_fb_width; 7701e04c3fSmrg float two_div_fb_height; 7801e04c3fSmrg float translate[2]; 7901e04c3fSmrg float scale[2]; 8001e04c3fSmrg float padding[2]; 8101e04c3fSmrg } constants; 8201e04c3fSmrg struct pipe_constant_buffer constbuf; 8301e04c3fSmrg 8401e04c3fSmrg unsigned fb_width, fb_height; 8501e04c3fSmrg 8601e04c3fSmrg /* vertices for text and background drawing are accumulated here and then 8701e04c3fSmrg * drawn all at once */ 8801e04c3fSmrg struct vertex_queue { 8901e04c3fSmrg float *vertices; 9001e04c3fSmrg struct pipe_vertex_buffer vbuf; 9101e04c3fSmrg unsigned max_num_vertices; 9201e04c3fSmrg unsigned num_vertices; 9301e04c3fSmrg unsigned buffer_size; 947ec681f3Smrg } text, bg, whitelines; 9501e04c3fSmrg 9601e04c3fSmrg bool has_srgb; 9701e04c3fSmrg}; 98af69d88dSmrg 99af69d88dSmrgstruct hud_graph { 100af69d88dSmrg /* initialized by common code */ 101af69d88dSmrg struct list_head head; 102af69d88dSmrg struct hud_pane *pane; 103af69d88dSmrg float color[3]; 104af69d88dSmrg float *vertices; /* ring buffer of vertices */ 105af69d88dSmrg 106af69d88dSmrg /* name and query */ 107af69d88dSmrg char name[128]; 108af69d88dSmrg void *query_data; 10901e04c3fSmrg void (*begin_query)(struct hud_graph *gr, struct pipe_context *pipe); 11001e04c3fSmrg void (*query_new_value)(struct hud_graph *gr, struct pipe_context *pipe); 11101e04c3fSmrg /* use this instead of ordinary free() */ 11201e04c3fSmrg void (*free_query_data)(void *ptr, struct pipe_context *pipe); 113af69d88dSmrg 114af69d88dSmrg /* mutable variables */ 115af69d88dSmrg unsigned num_vertices; 116af69d88dSmrg unsigned index; /* vertex index being updated */ 11701e04c3fSmrg double current_value; 11801e04c3fSmrg FILE *fd; 119af69d88dSmrg}; 120af69d88dSmrg 121af69d88dSmrgstruct hud_pane { 122af69d88dSmrg struct list_head head; 12301e04c3fSmrg struct hud_context *hud; 12401e04c3fSmrg unsigned x1, y1, x2, y2, y_simple; 125af69d88dSmrg unsigned inner_x1; 126af69d88dSmrg unsigned inner_y1; 127af69d88dSmrg unsigned inner_x2; 128af69d88dSmrg unsigned inner_y2; 129af69d88dSmrg unsigned inner_width; 130af69d88dSmrg unsigned inner_height; 131af69d88dSmrg float yscale; 132af69d88dSmrg unsigned max_num_vertices; 13301e04c3fSmrg unsigned last_line; /* index of the last describing line in the graph */ 134af69d88dSmrg uint64_t max_value; 13501e04c3fSmrg uint64_t initial_max_value; 13601e04c3fSmrg uint64_t ceiling; 13701e04c3fSmrg unsigned dyn_ceil_last_ran; 13801e04c3fSmrg boolean dyn_ceiling; 13901e04c3fSmrg boolean sort_items; 14001e04c3fSmrg enum pipe_driver_query_type type; 141af69d88dSmrg uint64_t period; /* in microseconds */ 142af69d88dSmrg 143af69d88dSmrg struct list_head graph_list; 144af69d88dSmrg unsigned num_graphs; 14501e04c3fSmrg unsigned next_color; 146af69d88dSmrg}; 147af69d88dSmrg 148af69d88dSmrg 149af69d88dSmrg/* core */ 150af69d88dSmrgvoid hud_pane_add_graph(struct hud_pane *pane, struct hud_graph *gr); 151af69d88dSmrgvoid hud_pane_set_max_value(struct hud_pane *pane, uint64_t value); 15201e04c3fSmrgvoid hud_graph_add_value(struct hud_graph *gr, double value); 153af69d88dSmrg 154af69d88dSmrg/* graphs/queries */ 15501e04c3fSmrgstruct hud_batch_query_context; 15601e04c3fSmrg 157af69d88dSmrg#define ALL_CPUS ~0 /* optionally set as cpu_index */ 158af69d88dSmrg 159af69d88dSmrgint hud_get_num_cpus(void); 160af69d88dSmrg 161af69d88dSmrgvoid hud_fps_graph_install(struct hud_pane *pane); 16201e04c3fSmrgvoid hud_frametime_graph_install(struct hud_pane *pane); 163af69d88dSmrgvoid hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index); 16401e04c3fSmrgvoid hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main); 16501e04c3fSmrgvoid hud_thread_counter_install(struct hud_pane *pane, const char *name, 16601e04c3fSmrg enum hud_counter counter); 16701e04c3fSmrgvoid hud_pipe_query_install(struct hud_batch_query_context **pbq, 16801e04c3fSmrg struct hud_pane *pane, 16901e04c3fSmrg const char *name, 17001e04c3fSmrg enum pipe_query_type query_type, 171af69d88dSmrg unsigned result_index, 17201e04c3fSmrg uint64_t max_value, 17301e04c3fSmrg enum pipe_driver_query_type type, 17401e04c3fSmrg enum pipe_driver_query_result_type result_type, 17501e04c3fSmrg unsigned flags); 17601e04c3fSmrgboolean hud_driver_query_install(struct hud_batch_query_context **pbq, 17701e04c3fSmrg struct hud_pane *pane, 17801e04c3fSmrg struct pipe_screen *screen, const char *name); 17901e04c3fSmrgvoid hud_batch_query_begin(struct hud_batch_query_context *bq, 18001e04c3fSmrg struct pipe_context *pipe); 18101e04c3fSmrgvoid hud_batch_query_update(struct hud_batch_query_context *bq, 18201e04c3fSmrg struct pipe_context *pipe); 18301e04c3fSmrgvoid hud_batch_query_cleanup(struct hud_batch_query_context **pbq, 18401e04c3fSmrg struct pipe_context *pipe); 18501e04c3fSmrg 18601e04c3fSmrg#ifdef HAVE_GALLIUM_EXTRA_HUD 18701e04c3fSmrgint hud_get_num_nics(bool displayhelp); 18801e04c3fSmrg#define NIC_DIRECTION_RX 1 18901e04c3fSmrg#define NIC_DIRECTION_TX 2 19001e04c3fSmrg#define NIC_RSSI_DBM 3 19101e04c3fSmrgvoid hud_nic_graph_install(struct hud_pane *pane, const char *nic_index, 19201e04c3fSmrg unsigned int mode); 19301e04c3fSmrg 19401e04c3fSmrgint hud_get_num_disks(bool displayhelp); 19501e04c3fSmrg#define DISKSTAT_RD 1 19601e04c3fSmrg#define DISKSTAT_WR 2 19701e04c3fSmrgvoid hud_diskstat_graph_install(struct hud_pane *pane, const char *dev_name, 19801e04c3fSmrg unsigned int mode); 19901e04c3fSmrg 20001e04c3fSmrgint hud_get_num_cpufreq(bool displayhelp); 20101e04c3fSmrg#define CPUFREQ_MINIMUM 1 20201e04c3fSmrg#define CPUFREQ_CURRENT 2 20301e04c3fSmrg#define CPUFREQ_MAXIMUM 3 20401e04c3fSmrgvoid hud_cpufreq_graph_install(struct hud_pane *pane, int cpu_index, unsigned int mode); 20501e04c3fSmrg#endif 20601e04c3fSmrg 20701e04c3fSmrg#ifdef HAVE_LIBSENSORS 20801e04c3fSmrgint hud_get_num_sensors(bool displayhelp); 20901e04c3fSmrg#define SENSORS_TEMP_CURRENT 1 21001e04c3fSmrg#define SENSORS_TEMP_CRITICAL 2 21101e04c3fSmrg#define SENSORS_VOLTAGE_CURRENT 3 21201e04c3fSmrg#define SENSORS_CURRENT_CURRENT 4 21301e04c3fSmrg#define SENSORS_POWER_CURRENT 5 21401e04c3fSmrgvoid hud_sensors_temp_graph_install(struct hud_pane *pane, const char *dev_name, 21501e04c3fSmrg unsigned int mode); 21601e04c3fSmrg#endif 217af69d88dSmrg 218af69d88dSmrg#endif 219