Beispiel #1
0
static void
query_cpu_load(struct hud_graph *gr)
{
   struct cpu_info *info = gr->query_data;
   uint64_t now = os_time_get();

   if (info->last_time) {
      if (info->last_time + gr->pane->period <= now) {
         uint64_t cpu_busy, cpu_total, cpu_load;

         get_cpu_stats(info->cpu_index, &cpu_busy, &cpu_total);

         cpu_load = (cpu_busy - info->last_cpu_busy) * 100 /
                    (double)(cpu_total - info->last_cpu_total);
         hud_graph_add_value(gr, cpu_load);

         info->last_cpu_busy = cpu_busy;
         info->last_cpu_total = cpu_total;
         info->last_time = now;
      }
   }
   else {
      /* initialize */
      info->last_time = now;
      get_cpu_stats(info->cpu_index, &info->last_cpu_busy,
                    &info->last_cpu_total);
   }
}
Beispiel #2
0
static void
query_sti_load(struct hud_graph *gr)
{
   struct sensors_temp_info *sti = gr->query_data;
   uint64_t now = os_time_get();

   if (sti->last_time) {
      if (sti->last_time + gr->pane->period <= now) {
         get_sensor_values(sti);

         switch (sti->mode) {
         case SENSORS_TEMP_CURRENT:
            hud_graph_add_value(gr, (uint64_t) sti->current);
            break;
         case SENSORS_TEMP_CRITICAL:
            hud_graph_add_value(gr, (uint64_t) sti->critical);
            break;
         case SENSORS_VOLTAGE_CURRENT:
            hud_graph_add_value(gr, (uint64_t)(sti->current * 1000));
            break;
         case SENSORS_CURRENT_CURRENT:
            hud_graph_add_value(gr, (uint64_t) sti->current);
            break;
         case SENSORS_POWER_CURRENT:
            hud_graph_add_value(gr, (uint64_t) sti->current);
            break;
         }

         sti->last_time = now;
      }
   }
   else {
      /* initialize */
      get_sensor_values(sti);
      sti->last_time = now;
   }
}
static void
query_fps(struct hud_graph *gr)
{
   struct fps_info *info = gr->query_data;
   uint64_t now = os_time_get();

   info->frames++;

   if (info->last_time) {
      if (info->last_time + gr->pane->period <= now) {
         double fps = ((uint64_t)info->frames) * 1000000 /
                      (double)(now - info->last_time);
         info->frames = 0;
         info->last_time = now;

         hud_graph_add_value(gr, fps);
      }
   }
   else {
      info->last_time = now;
   }
}
Beispiel #4
0
static void
query_new_value(struct hud_graph *gr)
{
   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);
   }

   if (!info->last_time) {
      info->last_time = now;
      return;
   }

   if (info->num_results && info->last_time + gr->pane->period <= now) {
      uint64_t value;

      switch (info->result_type) {
      default:
      case PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE:
         value = info->results_cumulative / info->num_results;
         break;
      case PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE:
         value = info->results_cumulative;
         break;
      }

      hud_graph_add_value(gr, value);

      info->last_time = now;
      info->results_cumulative = 0;
      info->num_results = 0;
   }
}
static void
query_new_value(struct hud_graph *gr)
{
   struct query_info *info = gr->query_data;
   struct pipe_context *pipe = info->pipe;
   uint64_t now = os_time_get();

   if (info->last_time) {
      pipe->end_query(pipe, info->query[info->head]);

      /* read query results */
      while (1) {
         struct pipe_query *query = info->query[info->tail];
         union pipe_query_result result;
         uint64_t *res64 = (uint64_t *)&result;

         if (pipe->get_query_result(pipe, query, FALSE, &result)) {
            info->results_cumulative += res64[info->result_index];
            info->num_results++;

            if (info->tail == info->head)
               break;

            info->tail = (info->tail+1) % NUM_QUERIES;
         }
         else {
            /* the oldest query is busy */
            if ((info->head+1) % NUM_QUERIES == info->tail) {
               /* all queries are busy, throw away the last query and create
                * a new one */
               fprintf(stderr,
                       "gallium_hud: all queries are busy after %i frames, "
                       "can't add another query\n",
                       NUM_QUERIES);
               pipe->destroy_query(pipe, info->query[info->head]);
               info->query[info->head] =
                     pipe->create_query(pipe, info->query_type);
            }
            else {
               /* the last query is busy, we need to add a new one we can use
                * for this frame */
               info->head = (info->head+1) % NUM_QUERIES;
               if (!info->query[info->head]) {
                  info->query[info->head] =
                        pipe->create_query(pipe, info->query_type);
               }
            }
            break;
         }
      }

      if (info->num_results && info->last_time + gr->pane->period <= now) {
         /* compute the average value across all frames */
         hud_graph_add_value(gr, info->results_cumulative / info->num_results);

         info->last_time = now;
         info->results_cumulative = 0;
         info->num_results = 0;
      }

      pipe->begin_query(pipe, info->query[info->head]);
   }
   else {
      /* initialize */
      info->last_time = now;
      info->query[info->head] = pipe->create_query(pipe, info->query_type);
      pipe->begin_query(pipe, info->query[info->head]);
   }
}