remove gpu vblank callbacks
[pcsx_rearmed.git] / frontend / pcnt.h
CommitLineData
14dffdb7 1
2enum pcounters {
3 PCNT_ALL,
4 PCNT_GPU,
5 PCNT_SPU,
72228559 6 PCNT_BLIT,
82ed88eb 7 PCNT_GTE,
72228559 8 PCNT_TEST,
14dffdb7 9 PCNT_CNT
10};
11
fa9cfe0a 12#ifdef PCNT
13
82ed88eb 14static const char *pcnt_names[PCNT_CNT] = { "", "gpu", "spu", "blit", "gte", "test" };
72228559 15
16#define PCNT_FRAMES 10
17
14dffdb7 18extern unsigned int pcounters[PCNT_CNT];
19extern unsigned int pcounter_starts[PCNT_CNT];
20
21#define pcnt_start(id) \
22 pcounter_starts[id] = pcnt_get()
23
24#define pcnt_end(id) \
25 pcounters[id] += pcnt_get() - pcounter_starts[id]
26
27void pcnt_hook_plugins(void);
28
29static inline void pcnt_print(float fps)
30{
72228559 31 static int print_counter;
32 unsigned int total, rem;
14dffdb7 33 int i;
34
35 for (i = 0; i < PCNT_CNT; i++)
72228559 36 pcounters[i] /= 1000 * PCNT_FRAMES;
14dffdb7 37
72228559 38 rem = total = pcounters[PCNT_ALL];
39 for (i = 1; i < PCNT_CNT; i++)
40 rem -= pcounters[i];
14dffdb7 41 if (!total)
42 total++;
43
72228559 44 if (--print_counter < 0) {
45 printf(" ");
46 for (i = 1; i < PCNT_CNT; i++)
47 printf("%5s ", pcnt_names[i]);
48 printf("%5s\n", "rem");
49 print_counter = 30;
50 }
51
52 printf("%4.1f ", fps);
fc42805b 53#if 0
54 static float pcounters_all[PCNT_CNT+1];
55 static int pcounter_samples;
56 pcounter_samples++;
57
58 for (i = 1; i < PCNT_CNT; i++) {
59 pcounters_all[i] += pcounters[i];
60 printf("%5.0f ", pcounters_all[i] / pcounter_samples);
61 }
62 pcounters_all[i] += rem;
63 printf("%5.0f\n", pcounters_all[i] / pcounter_samples);
64#else
72228559 65 for (i = 1; i < PCNT_CNT; i++)
66 printf("%5u ", pcounters[i]);
67 printf("%5u (", rem);
68 for (i = 1; i < PCNT_CNT; i++)
69 printf("%2u ", pcounters[i] * 100 / total);
70 printf("%2u) %u\n", rem * 100 / total, total);
fc42805b 71#endif
14dffdb7 72 memset(pcounters, 0, sizeof(pcounters));
73}
74
75static inline unsigned int pcnt_get(void)
76{
77 unsigned int val;
78#ifdef __ARM_ARCH_7A__
79 __asm__ volatile("mrc p15, 0, %0, c9, c13, 0"
80 : "=r"(val));
81#else
82 val = 0;
83#endif
84 return val;
85}
86
19e57cbf 87static inline void pcnt_init(void)
88{
89#ifdef __ARM_ARCH_7A__
90 int v;
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));
97#endif
98}
99
82ed88eb 100void pcnt_gte_start(int op);
101void pcnt_gte_end(int op);
102
fa9cfe0a 103#else
104
105#define pcnt_start(id)
106#define pcnt_end(id)
107#define pcnt_hook_plugins()
69af03a2 108#define pcnt_print(fps)
fa9cfe0a 109
110#endif