[Mesa-dev] [PATCH 2/5] gallium: implement a head-up display module

Marek Olšák maraeo at gmail.com
Mon Mar 25 16:59:02 PDT 2013


>> +   char *name = gr->name;
>> +
>> +   /* replace '-' with a space */
>
>
> why?

For convenience. I wouldn't like to have space characters in the query
names in the environment variable, but I'd like to have spaces when
it's printed on the screen. For example, GALLIUM_HUD=pixels-rendered
and "pixels rendered" on the screen.

>
>
>> +   while (*name) {
>> +      if (*name == '-')
>> +         *name = ' ';
>> +      name++;
>> +   }
>> +
[snip]
>> +
>> +   gr = CALLOC_STRUCT(hud_graph);
>
>
> if (gr)

Alright. Linux usually doesn't return NULL from malloc even if there
is not enough memory, but other operating systems might.

>
>
>
>> +
>> +   if (cpu_index == ALL_CPUS)
>> +      strcpy(gr->name, "cpu");
>> +   else
>> +      sprintf(gr->name, "cpu%u", cpu_index);
>> +   gr->query_data = CALLOC_STRUCT(cpu_info);
>> +   gr->query_new_value = query_cpu_load;
>> +   gr->free_query_data = free;
>> +
>> +   info = gr->query_data;
>> +   info->cpu_index = cpu_index;
>> +
>> +   hud_pane_add_graph(pane, gr);
>> +   hud_pane_set_max_value(pane, 100);
>> +}
>> +
>> +int
>> +get_num_cpus(void)
>> +{
>> +   uint64_t busy, total;
>> +   int i = 0;
>> +
>> +   while (get_cpu_stats(i,&busy,&total))
>> +      i++;
>> +
>> +   return i;
>> +}
>
>
> I wonder if some of this CPU-related code could go into src/gallum/util/

It's unlikely someone else will need it, so not now.

Marek


More information about the mesa-dev mailing list