}
static void
-hud_start_queries(struct hud_context *hud)
+hud_start_queries(struct hud_context *hud, struct pipe_context *pipe)
{
struct hud_pane *pane;
struct hud_graph *gr;
/* Start queries. */
- hud_batch_query_begin(hud->batch_query);
+ hud_batch_query_begin(hud->batch_query, pipe);
LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
LIST_FOR_EACH_ENTRY(gr, &pane->graph_list, head) {
if (gr->begin_query)
- gr->begin_query(gr);
+ gr->begin_query(gr, pipe);
}
}
}
/* Stop queries, query results, and record vertices for charts. */
static void
-hud_stop_queries(struct hud_context *hud)
+hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe)
{
struct hud_pane *pane;
struct hud_graph *gr, *next;
/* Allocate everything once and divide the storage into 3 portions
* manually, because u_upload_alloc can unmap memory from previous calls.
*/
- u_upload_alloc(hud->pipe->stream_uploader, 0,
+ u_upload_alloc(pipe->stream_uploader, 0,
hud->bg.buffer_size +
hud->whitelines.buffer_size +
hud->text.buffer_size +
hud->text.buffer_size / sizeof(float);
/* prepare all graphs */
- hud_batch_query_update(hud->batch_query);
+ hud_batch_query_update(hud->batch_query, pipe);
LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
LIST_FOR_EACH_ENTRY(gr, &pane->graph_list, head) {
- gr->query_new_value(gr);
+ gr->query_new_value(gr, pipe);
}
if (pane->sort_items) {
}
/* unmap the uploader's vertex buffer before drawing */
- u_upload_unmap(hud->pipe->stream_uploader);
+ u_upload_unmap(pipe->stream_uploader);
}
void
hud_run(struct hud_context *hud, struct pipe_resource *tex)
{
- hud_stop_queries(hud);
+ hud_stop_queries(hud, hud->pipe);
hud_draw_results(hud, tex);
- hud_start_queries(hud);
+ hud_start_queries(hud, hud->pipe);
}
static void
}
static void
-hud_graph_destroy(struct hud_graph *graph)
+hud_graph_destroy(struct hud_graph *graph, struct pipe_context *pipe)
{
FREE(graph->vertices);
if (graph->free_query_data)
- graph->free_query_data(graph->query_data);
+ graph->free_query_data(graph->query_data, pipe);
if (graph->fd)
fclose(graph->fd);
FREE(graph);
#endif
else if (strcmp(name, "samples-passed") == 0 &&
has_occlusion_query(hud->pipe->screen)) {
- hud_pipe_query_install(&hud->batch_query, pane, hud->pipe,
+ hud_pipe_query_install(&hud->batch_query, pane,
"samples-passed",
PIPE_QUERY_OCCLUSION_COUNTER, 0, 0,
PIPE_DRIVER_QUERY_TYPE_UINT64,
}
else if (strcmp(name, "primitives-generated") == 0 &&
has_streamout(hud->pipe->screen)) {
- hud_pipe_query_install(&hud->batch_query, pane, hud->pipe,
+ hud_pipe_query_install(&hud->batch_query, pane,
"primitives-generated",
PIPE_QUERY_PRIMITIVES_GENERATED, 0, 0,
PIPE_DRIVER_QUERY_TYPE_UINT64,
if (strcmp(name, pipeline_statistics_names[i]) == 0)
break;
if (i < ARRAY_SIZE(pipeline_statistics_names)) {
- hud_pipe_query_install(&hud->batch_query, pane, hud->pipe, name,
+ hud_pipe_query_install(&hud->batch_query, pane, name,
PIPE_QUERY_PIPELINE_STATISTICS, i,
0, PIPE_DRIVER_QUERY_TYPE_UINT64,
PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE,
/* driver queries */
if (!processed) {
- if (!hud_driver_query_install(&hud->batch_query, pane, hud->pipe,
- name)) {
+ if (!hud_driver_query_install(&hud->batch_query, pane,
+ hud->pipe->screen, name)) {
fprintf(stderr, "gallium_hud: unknown driver query '%s'\n", name);
fflush(stderr);
}
LIST_FOR_EACH_ENTRY_SAFE(pane, pane_tmp, &hud->pane_list, head) {
LIST_FOR_EACH_ENTRY_SAFE(graph, graph_tmp, &pane->graph_list, head) {
LIST_DEL(&graph->head);
- hud_graph_destroy(graph);
+ hud_graph_destroy(graph, pipe);
}
LIST_DEL(&pane->head);
FREE(pane);
}
- hud_batch_query_cleanup(&hud->batch_query);
+ hud_batch_query_cleanup(&hud->batch_query, pipe);
pipe->delete_fs_state(pipe, hud->fs_color);
pipe->delete_fs_state(pipe, hud->fs_text);
pipe->delete_vs_state(pipe, hud->vs);
};
static void
-query_cpu_load(struct hud_graph *gr)
+query_cpu_load(struct hud_graph *gr, struct pipe_context *pipe)
{
struct cpu_info *info = gr->query_data;
uint64_t now = os_time_get();
}
static void
-free_query_data(void *p)
+free_query_data(void *p, struct pipe_context *pipe)
{
FREE(p);
}
};
static void
-query_api_thread_busy_status(struct hud_graph *gr)
+query_api_thread_busy_status(struct hud_graph *gr, struct pipe_context *pipe)
{
struct thread_info *info = gr->query_data;
int64_t now = os_time_get_nano();
}
static void
-query_thread_counter(struct hud_graph *gr)
+query_thread_counter(struct hud_graph *gr, struct pipe_context *pipe)
{
struct counter_info *info = gr->query_data;
int64_t now = os_time_get_nano();
#define NUM_QUERIES 8
struct hud_batch_query_context {
- struct pipe_context *pipe;
unsigned num_query_types;
unsigned allocated_query_types;
unsigned *query_types;
};
void
-hud_batch_query_update(struct hud_batch_query_context *bq)
+hud_batch_query_update(struct hud_batch_query_context *bq,
+ struct pipe_context *pipe)
{
- struct pipe_context *pipe;
-
if (!bq || bq->failed)
return;
- pipe = bq->pipe;
-
if (bq->query[bq->head])
pipe->end_query(pipe, bq->query[bq->head]);
assert(bq->query[bq->head]);
- pipe->destroy_query(bq->pipe, bq->query[bq->head]);
+ pipe->destroy_query(pipe, bq->query[bq->head]);
bq->query[bq->head] = NULL;
}
}
void
-hud_batch_query_begin(struct hud_batch_query_context *bq)
+hud_batch_query_begin(struct hud_batch_query_context *bq,
+ struct pipe_context *pipe)
{
if (!bq || bq->failed || !bq->query[bq->head])
return;
- if (!bq->pipe->begin_query(bq->pipe, bq->query[bq->head])) {
+ if (!pipe->begin_query(pipe, bq->query[bq->head])) {
fprintf(stderr,
"gallium_hud: could not begin batch query. You may have "
"selected too many or incompatible queries.\n");
static boolean
batch_query_add(struct hud_batch_query_context **pbq,
- struct pipe_context *pipe, unsigned query_type,
- unsigned *result_index)
+ unsigned query_type, unsigned *result_index)
{
struct hud_batch_query_context *bq = *pbq;
unsigned i;
bq = CALLOC_STRUCT(hud_batch_query_context);
if (!bq)
return false;
- bq->pipe = pipe;
*pbq = bq;
}
}
void
-hud_batch_query_cleanup(struct hud_batch_query_context **pbq)
+hud_batch_query_cleanup(struct hud_batch_query_context **pbq,
+ struct pipe_context *pipe)
{
struct hud_batch_query_context *bq = *pbq;
unsigned idx;
*pbq = NULL;
if (bq->query[bq->head] && !bq->failed)
- bq->pipe->end_query(bq->pipe, bq->query[bq->head]);
+ pipe->end_query(pipe, bq->query[bq->head]);
for (idx = 0; idx < NUM_QUERIES; ++idx) {
if (bq->query[idx])
- bq->pipe->destroy_query(bq->pipe, bq->query[idx]);
+ pipe->destroy_query(pipe, bq->query[idx]);
FREE(bq->result[idx]);
}
}
struct query_info {
- struct pipe_context *pipe;
struct hud_batch_query_context *batch;
unsigned query_type;
unsigned result_index; /* unit depends on query_type */
}
static void
-query_new_value_normal(struct query_info *info)
+query_new_value_normal(struct query_info *info, struct pipe_context *pipe)
{
- struct pipe_context *pipe = info->pipe;
-
if (info->last_time) {
if (info->query[info->head])
pipe->end_query(pipe, info->query[info->head]);
}
static void
-begin_query(struct hud_graph *gr)
+begin_query(struct hud_graph *gr, struct pipe_context *pipe)
{
struct query_info *info = gr->query_data;
- struct pipe_context *pipe = info->pipe;
assert(!info->batch);
if (info->query[info->head])
}
static void
-query_new_value(struct hud_graph *gr)
+query_new_value(struct hud_graph *gr, struct pipe_context *pipe)
{
struct query_info *info = gr->query_data;
uint64_t now = os_time_get();
if (info->batch) {
query_new_value_batch(info);
} else {
- query_new_value_normal(info);
+ query_new_value_normal(info, pipe);
}
if (!info->last_time) {
}
static void
-free_query_info(void *ptr)
+free_query_info(void *ptr, struct pipe_context *pipe)
{
struct query_info *info = ptr;
if (!info->batch && info->last_time) {
- struct pipe_context *pipe = info->pipe;
int i;
pipe->end_query(pipe, info->query[info->head]);
void
hud_pipe_query_install(struct hud_batch_query_context **pbq,
- struct hud_pane *pane, struct pipe_context *pipe,
+ struct hud_pane *pane,
const char *name, unsigned query_type,
unsigned result_index,
uint64_t max_value, enum pipe_driver_query_type type,
gr->free_query_data = free_query_info;
info = gr->query_data;
- info->pipe = pipe;
info->result_type = result_type;
if (flags & PIPE_DRIVER_QUERY_FLAG_BATCH) {
- if (!batch_query_add(pbq, pipe, query_type, &info->result_index))
+ if (!batch_query_add(pbq, query_type, &info->result_index))
goto fail_info;
info->batch = *pbq;
} else {
boolean
hud_driver_query_install(struct hud_batch_query_context **pbq,
- struct hud_pane *pane, struct pipe_context *pipe,
+ struct hud_pane *pane, struct pipe_screen *screen,
const char *name)
{
- struct pipe_screen *screen = pipe->screen;
struct pipe_driver_query_info query;
unsigned num_queries, i;
boolean found = FALSE;
if (!found)
return FALSE;
- hud_pipe_query_install(pbq, pane, pipe, query.name, query.query_type, 0,
+ hud_pipe_query_install(pbq, pane, query.name, query.query_type, 0,
query.max_value.u64, query.type, query.result_type,
query.flags);
};
static void
-query_fps(struct hud_graph *gr)
+query_fps(struct hud_graph *gr, struct pipe_context *pipe)
{
struct fps_info *info = gr->query_data;
uint64_t now = os_time_get();
}
static void
-free_query_data(void *p)
+free_query_data(void *p, struct pipe_context *pipe)
{
FREE(p);
}
/* name and query */
char name[128];
void *query_data;
- void (*begin_query)(struct hud_graph *gr);
- void (*query_new_value)(struct hud_graph *gr);
- void (*free_query_data)(void *ptr); /**< do not use ordinary free() */
+ void (*begin_query)(struct hud_graph *gr, struct pipe_context *pipe);
+ void (*query_new_value)(struct hud_graph *gr, struct pipe_context *pipe);
+ /* use this instead of ordinary free() */
+ void (*free_query_data)(void *ptr, struct pipe_context *pipe);
/* mutable variables */
unsigned num_vertices;
void hud_thread_counter_install(struct hud_pane *pane, const char *name,
enum hud_counter counter);
void hud_pipe_query_install(struct hud_batch_query_context **pbq,
- struct hud_pane *pane, struct pipe_context *pipe,
+ struct hud_pane *pane,
const char *name, unsigned query_type,
unsigned result_index,
uint64_t max_value,
unsigned flags);
boolean hud_driver_query_install(struct hud_batch_query_context **pbq,
struct hud_pane *pane,
- struct pipe_context *pipe, const char *name);
-void hud_batch_query_begin(struct hud_batch_query_context *bq);
-void hud_batch_query_update(struct hud_batch_query_context *bq);
-void hud_batch_query_cleanup(struct hud_batch_query_context **pbq);
+ struct pipe_screen *screen, const char *name);
+void hud_batch_query_begin(struct hud_batch_query_context *bq,
+ struct pipe_context *pipe);
+void hud_batch_query_update(struct hud_batch_query_context *bq,
+ struct pipe_context *pipe);
+void hud_batch_query_cleanup(struct hud_batch_query_context **pbq,
+ struct pipe_context *pipe);
#if HAVE_GALLIUM_EXTRA_HUD
int hud_get_num_nics(bool displayhelp);