Path: blob/21.2-virgl/src/gallium/auxiliary/hud/hud_private.h
4565 views
/**************************************************************************1*2* Copyright 2013 Marek Olšák <[email protected]>3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef HUD_PRIVATE_H28#define HUD_PRIVATE_H2930#include "pipe/p_context.h"31#include "pipe/p_state.h"32#include "util/list.h"33#include "hud/font.h"34#include "cso_cache/cso_context.h"3536enum hud_counter {37HUD_COUNTER_OFFLOADED,38HUD_COUNTER_DIRECT,39HUD_COUNTER_SYNCS,40};4142struct hud_context {43int refcount;44bool simple;4546/* Context where queries are executed. */47struct pipe_context *record_pipe;4849/* Context where the HUD is drawn: */50struct pipe_context *pipe;51struct cso_context *cso;52struct st_context_iface *st;5354struct hud_batch_query_context *batch_query;55struct list_head pane_list;5657struct util_queue_monitoring *monitored_queue;5859/* states */60struct pipe_blend_state no_blend, alpha_blend;61struct pipe_depth_stencil_alpha_state dsa;62void *fs_color, *fs_text;63struct pipe_rasterizer_state rasterizer, rasterizer_aa_lines;64void *vs_color, *vs_text;65struct cso_velems_state velems;6667/* font */68struct util_font font;69struct pipe_sampler_view *font_sampler_view;70struct pipe_sampler_state font_sampler_state;7172/* VS constant buffer */73struct {74float color[4];75float two_div_fb_width;76float two_div_fb_height;77float translate[2];78float scale[2];79float padding[2];80} constants;81struct pipe_constant_buffer constbuf;8283unsigned fb_width, fb_height;8485/* vertices for text and background drawing are accumulated here and then86* drawn all at once */87struct vertex_queue {88float *vertices;89struct pipe_vertex_buffer vbuf;90unsigned max_num_vertices;91unsigned num_vertices;92unsigned buffer_size;93} text, bg, whitelines;9495bool has_srgb;96};9798struct hud_graph {99/* initialized by common code */100struct list_head head;101struct hud_pane *pane;102float color[3];103float *vertices; /* ring buffer of vertices */104105/* name and query */106char name[128];107void *query_data;108void (*begin_query)(struct hud_graph *gr, struct pipe_context *pipe);109void (*query_new_value)(struct hud_graph *gr, struct pipe_context *pipe);110/* use this instead of ordinary free() */111void (*free_query_data)(void *ptr, struct pipe_context *pipe);112113/* mutable variables */114unsigned num_vertices;115unsigned index; /* vertex index being updated */116double current_value;117FILE *fd;118};119120struct hud_pane {121struct list_head head;122struct hud_context *hud;123unsigned x1, y1, x2, y2, y_simple;124unsigned inner_x1;125unsigned inner_y1;126unsigned inner_x2;127unsigned inner_y2;128unsigned inner_width;129unsigned inner_height;130float yscale;131unsigned max_num_vertices;132unsigned last_line; /* index of the last describing line in the graph */133uint64_t max_value;134uint64_t initial_max_value;135uint64_t ceiling;136unsigned dyn_ceil_last_ran;137boolean dyn_ceiling;138boolean sort_items;139enum pipe_driver_query_type type;140uint64_t period; /* in microseconds */141142struct list_head graph_list;143unsigned num_graphs;144unsigned next_color;145};146147148/* core */149void hud_pane_add_graph(struct hud_pane *pane, struct hud_graph *gr);150void hud_pane_set_max_value(struct hud_pane *pane, uint64_t value);151void hud_graph_add_value(struct hud_graph *gr, double value);152153/* graphs/queries */154struct hud_batch_query_context;155156#define ALL_CPUS ~0 /* optionally set as cpu_index */157158int hud_get_num_cpus(void);159160void hud_fps_graph_install(struct hud_pane *pane);161void hud_frametime_graph_install(struct hud_pane *pane);162void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index);163void hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main);164void hud_thread_counter_install(struct hud_pane *pane, const char *name,165enum hud_counter counter);166void hud_pipe_query_install(struct hud_batch_query_context **pbq,167struct hud_pane *pane,168const char *name,169enum pipe_query_type query_type,170unsigned result_index,171uint64_t max_value,172enum pipe_driver_query_type type,173enum pipe_driver_query_result_type result_type,174unsigned flags);175boolean hud_driver_query_install(struct hud_batch_query_context **pbq,176struct hud_pane *pane,177struct pipe_screen *screen, const char *name);178void hud_batch_query_begin(struct hud_batch_query_context *bq,179struct pipe_context *pipe);180void hud_batch_query_update(struct hud_batch_query_context *bq,181struct pipe_context *pipe);182void hud_batch_query_cleanup(struct hud_batch_query_context **pbq,183struct pipe_context *pipe);184185#ifdef HAVE_GALLIUM_EXTRA_HUD186int hud_get_num_nics(bool displayhelp);187#define NIC_DIRECTION_RX 1188#define NIC_DIRECTION_TX 2189#define NIC_RSSI_DBM 3190void hud_nic_graph_install(struct hud_pane *pane, const char *nic_index,191unsigned int mode);192193int hud_get_num_disks(bool displayhelp);194#define DISKSTAT_RD 1195#define DISKSTAT_WR 2196void hud_diskstat_graph_install(struct hud_pane *pane, const char *dev_name,197unsigned int mode);198199int hud_get_num_cpufreq(bool displayhelp);200#define CPUFREQ_MINIMUM 1201#define CPUFREQ_CURRENT 2202#define CPUFREQ_MAXIMUM 3203void hud_cpufreq_graph_install(struct hud_pane *pane, int cpu_index, unsigned int mode);204#endif205206#ifdef HAVE_LIBSENSORS207int hud_get_num_sensors(bool displayhelp);208#define SENSORS_TEMP_CURRENT 1209#define SENSORS_TEMP_CRITICAL 2210#define SENSORS_VOLTAGE_CURRENT 3211#define SENSORS_CURRENT_CURRENT 4212#define SENSORS_POWER_CURRENT 5213void hud_sensors_temp_graph_install(struct hud_pane *pane, const char *dev_name,214unsigned int mode);215#endif216217#endif218219220