Skip to content

Commit

Permalink
fb: add missing viv_gpu_top.c
Browse files Browse the repository at this point in the history
Doesn't actually work yet, but this fixes the build.
  • Loading branch information
laanwj committed Aug 1, 2013
1 parent e6de10d commit a0d0f46
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,4 +4,5 @@
*.fdr
*.swp
*.so
tags

79 changes: 79 additions & 0 deletions native/fb/viv_gpu_top.c
@@ -0,0 +1,79 @@
/* Watch usage of Vivante GPU live.
* Needs profiling support built-in.
*
* XXX work in progress.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>

#include <etnaviv/viv.h>
#include <etnaviv/viv_profile.h>

static const char *bars[] = {
" ",
"▏",
"▎",
"▍",
"▌",
"▋",
"▊",
"▉",
"█"
};

static unsigned long gettime(void)
{
struct timeval t;
gettimeofday(&t, NULL);
return (t.tv_usec + (t.tv_sec * 1000000));
}

int main()
{
struct viv_conn *conn = 0;
int rv;
rv = viv_open(VIV_HW_3D, &conn);
if(rv!=0)
{
fprintf(stderr, "Error opening device\n");
exit(1);
}
uint32_t num_profile_counters = viv_get_num_profile_counters();

/* Need to figure out which timers are persistent and
* which ones reset after querying.
*/

uint32_t *counter_data = calloc(num_profile_counters, 4);
if(viv_read_profile_counters_3d(conn, counter_data) != 0)
{
fprintf(stderr, "Error querying counters (probably unsupported with this kernel, or not built into libetnaviv)\n");
exit(1);
}
for(uint32_t c=0; c<num_profile_counters; ++c)
{
struct viv_profile_counter_info *info = viv_get_profile_counter_info(c);
printf("[%d] %s %u\n", c, info->name, counter_data[c]);
}
/*
* Sort list of counters by activity /s
* Show number per second
* Show minimum
* Show maximum
* Show a bar, based on current activity percentage of maximum (and some pre-determined value, to prevent
* everything from hanging at max)
*/

return 0;
}

0 comments on commit a0d0f46

Please sign in to comment.