14 static const char *pcnt_names[PCNT_CNT] = { "", "gpu", "spu", "blit", "gte", "test" };
16 #define PCNT_FRAMES 10
18 extern unsigned int pcounters[PCNT_CNT];
19 extern unsigned int pcounter_starts[PCNT_CNT];
21 #define pcnt_start(id) \
22 pcounter_starts[id] = pcnt_get()
24 #define pcnt_end(id) \
25 pcounters[id] += pcnt_get() - pcounter_starts[id]
27 void pcnt_hook_plugins(void);
29 static inline void pcnt_print(float fps)
31 static int print_counter;
32 unsigned int total, rem;
35 for (i = 0; i < PCNT_CNT; i++)
36 pcounters[i] /= 1000 * PCNT_FRAMES;
38 rem = total = pcounters[PCNT_ALL];
39 for (i = 1; i < PCNT_CNT; i++)
44 if (--print_counter < 0) {
46 for (i = 1; i < PCNT_CNT; i++)
47 printf("%5s ", pcnt_names[i]);
48 printf("%5s\n", "rem");
52 printf("%4.1f ", fps);
54 static float pcounters_all[PCNT_CNT+1];
55 static int pcounter_samples;
58 for (i = 1; i < PCNT_CNT; i++) {
59 pcounters_all[i] += pcounters[i];
60 printf("%5.0f ", pcounters_all[i] / pcounter_samples);
62 pcounters_all[i] += rem;
63 printf("%5.0f\n", pcounters_all[i] / pcounter_samples);
65 for (i = 1; i < PCNT_CNT; i++)
66 printf("%5u ", pcounters[i]);
68 for (i = 1; i < PCNT_CNT; i++)
69 printf("%2u ", pcounters[i] * 100 / total);
70 printf("%2u) %u\n", rem * 100 / total, total);
72 memset(pcounters, 0, sizeof(pcounters));
75 static inline unsigned int pcnt_get(void)
78 #ifdef __ARM_ARCH_7A__
79 __asm__ volatile("mrc p15, 0, %0, c9, c13, 0"
87 static inline void pcnt_init(void)
89 #ifdef __ARM_ARCH_7A__
91 asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(v));
92 v |= 5; // master enable, ccnt reset
93 v &= ~8; // ccnt divider 0
94 asm volatile("mcr p15, 0, %0, c9, c12, 0" :: "r"(v));
95 // enable cycle counter
96 asm volatile("mcr p15, 0, %0, c9, c12, 1" :: "r"(1<<31));
100 void pcnt_gte_start(int op);
101 void pcnt_gte_end(int op);
105 #define pcnt_start(id)
107 #define pcnt_hook_plugins()
108 #define pcnt_print(fps)