X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=frontend%2Fpcnt.h;h=545f0c43ae79c36d2bf9078df18ac88780bea88a;hp=57bc88adff36851d82ef8f271bb49195fad6f6fe;hb=a2d91a5d28651b7cfa6d411208da5f86bc168dfe;hpb=14dffdb7a0457fc647103deafa5f1cac12e888fb diff --git a/frontend/pcnt.h b/frontend/pcnt.h index 57bc88ad..545f0c43 100644 --- a/frontend/pcnt.h +++ b/frontend/pcnt.h @@ -3,9 +3,25 @@ enum pcounters { PCNT_ALL, PCNT_GPU, PCNT_SPU, + PCNT_BLIT, + PCNT_GTE, + PCNT_TEST, PCNT_CNT }; +#ifdef PCNT + +#ifndef __ARM_ARCH_7A__ +#include +#define PCNT_DIV 1 +#else +#define PCNT_DIV 1000 +#endif + +static const char *pcnt_names[PCNT_CNT] = { "", "gpu", "spu", "blit", "gte", "test" }; + +#define PCNT_FRAMES 10 + extern unsigned int pcounters[PCNT_CNT]; extern unsigned int pcounter_starts[PCNT_CNT]; @@ -19,22 +35,47 @@ void pcnt_hook_plugins(void); static inline void pcnt_print(float fps) { - unsigned int total, gpu, spu, rem; + static int print_counter; + unsigned int total, rem; int i; for (i = 0; i < PCNT_CNT; i++) - pcounters[i] >>= 10; + pcounters[i] /= PCNT_DIV * PCNT_FRAMES; - total = pcounters[PCNT_ALL]; - gpu = pcounters[PCNT_GPU]; - spu = pcounters[PCNT_SPU]; - rem = total - gpu - spu; + rem = total = pcounters[PCNT_ALL]; + for (i = 1; i < PCNT_CNT; i++) + rem -= pcounters[i]; if (!total) total++; - printf("%2.1f %6u %6u %6u (%2d %2d %2d)\n", fps, gpu, spu, rem, - gpu * 100 / total, spu * 100 / total, rem * 100 / total); + if (--print_counter < 0) { + printf(" "); + for (i = 1; i < PCNT_CNT; i++) + printf("%5s ", pcnt_names[i]); + printf("%5s\n", "rem"); + print_counter = 30; + } + + printf("%4.1f ", fps); +#if 0 + static float pcounters_all[PCNT_CNT+1]; + static int pcounter_samples; + pcounter_samples++; + for (i = 1; i < PCNT_CNT; i++) { + pcounters_all[i] += pcounters[i]; + printf("%5.0f ", pcounters_all[i] / pcounter_samples); + } + pcounters_all[i] += rem; + printf("%5.0f\n", pcounters_all[i] / pcounter_samples); +#else + for (i = 1; i < PCNT_CNT; i++) + printf("%5u ", pcounters[i]); + printf("%5u (", rem); + for (i = 1; i < PCNT_CNT; i++) + printf("%2u ", pcounters[i] * 100 / total); + printf("%2u) %u\n", rem * 100 / total, total); +#endif memset(pcounters, 0, sizeof(pcounters)); } @@ -45,8 +86,38 @@ static inline unsigned int pcnt_get(void) __asm__ volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(val)); #else - val = 0; + // all slow on ARM :( + //struct timespec tv; + //clock_gettime(CLOCK_MONOTONIC_RAW, &tv); + //val = tv.tv_sec * 1000000000 + tv.tv_nsec; + struct timeval tv; + gettimeofday(&tv, NULL); + val = tv.tv_sec * 1000000 + tv.tv_usec; #endif return val; } +static inline void pcnt_init(void) +{ +#ifdef __ARM_ARCH_7A__ + int v; + asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(v)); + v |= 5; // master enable, ccnt reset + v &= ~8; // ccnt divider 0 + asm volatile("mcr p15, 0, %0, c9, c12, 0" :: "r"(v)); + // enable cycle counter + asm volatile("mcr p15, 0, %0, c9, c12, 1" :: "r"(1<<31)); +#endif +} + +void pcnt_gte_start(int op); +void pcnt_gte_end(int op); + +#else + +#define pcnt_start(id) +#define pcnt_end(id) +#define pcnt_hook_plugins() +#define pcnt_print(fps) + +#endif