| 1 | |
| 2 | enum pcounters { |
| 3 | PCNT_ALL, |
| 4 | PCNT_GPU, |
| 5 | PCNT_SPU, |
| 6 | PCNT_CNT |
| 7 | }; |
| 8 | |
| 9 | #ifdef PCNT |
| 10 | |
| 11 | extern unsigned int pcounters[PCNT_CNT]; |
| 12 | extern unsigned int pcounter_starts[PCNT_CNT]; |
| 13 | |
| 14 | #define pcnt_start(id) \ |
| 15 | pcounter_starts[id] = pcnt_get() |
| 16 | |
| 17 | #define pcnt_end(id) \ |
| 18 | pcounters[id] += pcnt_get() - pcounter_starts[id] |
| 19 | |
| 20 | void pcnt_hook_plugins(void); |
| 21 | |
| 22 | static inline void pcnt_print(float fps) |
| 23 | { |
| 24 | unsigned int total, gpu, spu, rem; |
| 25 | int i; |
| 26 | |
| 27 | for (i = 0; i < PCNT_CNT; i++) |
| 28 | pcounters[i] >>= 10; |
| 29 | |
| 30 | total = pcounters[PCNT_ALL]; |
| 31 | gpu = pcounters[PCNT_GPU]; |
| 32 | spu = pcounters[PCNT_SPU]; |
| 33 | rem = total - gpu - spu; |
| 34 | if (!total) |
| 35 | total++; |
| 36 | |
| 37 | printf("%2.1f %6u %6u %6u (%2d %2d %2d)\n", fps, gpu, spu, rem, |
| 38 | gpu * 100 / total, spu * 100 / total, rem * 100 / total); |
| 39 | |
| 40 | memset(pcounters, 0, sizeof(pcounters)); |
| 41 | } |
| 42 | |
| 43 | static inline unsigned int pcnt_get(void) |
| 44 | { |
| 45 | unsigned int val; |
| 46 | #ifdef __ARM_ARCH_7A__ |
| 47 | __asm__ volatile("mrc p15, 0, %0, c9, c13, 0" |
| 48 | : "=r"(val)); |
| 49 | #else |
| 50 | val = 0; |
| 51 | #endif |
| 52 | return val; |
| 53 | } |
| 54 | |
| 55 | #else |
| 56 | |
| 57 | #define pcnt_start(id) |
| 58 | #define pcnt_end(id) |
| 59 | #define pcnt_hook_plugins() |
| 60 | |
| 61 | static inline void pcnt_print(float fps) |
| 62 | { |
| 63 | printf("%2.1f\n", fps); |
| 64 | } |
| 65 | |
| 66 | #endif |