else
OBJS += frontend/plat_dummy.o
endif
+ifdef PCNT
+CFLAGS += -DPCNT
+endif
frontend/%.o: CFLAGS += -Wall -DIN_EVDEV
$(TARGET): $(OBJS)
PCNT_ALL,
PCNT_GPU,
PCNT_SPU,
+ PCNT_BLIT,
+ PCNT_TEST,
PCNT_CNT
};
#ifdef PCNT
+static const char *pcnt_names[PCNT_CNT] = { "", "gpu", "spu", "blit", "test" };
+
+#define PCNT_FRAMES 10
+
extern unsigned int pcounters[PCNT_CNT];
extern unsigned int pcounter_starts[PCNT_CNT];
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] /= 1000 * 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);
+ 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);
memset(pcounters, 0, sizeof(pcounters));
}
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "plugin_lib.h"
#include "linux/fbdev.h"
#include "common/fonts.h"
#include "common/input.h"
#include "omap.h"
+#include "pcnt.h"
#include "../libpcsxcore/new_dynarec/new_dynarec.h"
void *pl_fbdev_buf;
int keystate;
-static int pl_fbdev_w;
+static int pl_fbdev_w, pl_fbdev_h, pl_fbdev_bpp;
+static int flip_cnt, flips_per_sec, tick_per_sec;
+extern float fps_cur; // XXX
+
+static int get_cpu_ticks(void)
+{
+ static unsigned long last_utime;
+ static int fd;
+ unsigned long utime, ret;
+ char buf[128];
+
+ if (fd == 0)
+ fd = open("/proc/self/stat", O_RDONLY);
+ lseek(fd, 0, SEEK_SET);
+ buf[0] = 0;
+ read(fd, buf, sizeof(buf));
+ buf[sizeof(buf) - 1] = 0;
+
+ sscanf(buf, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %lu", &utime);
+ ret = utime - last_utime;
+ last_utime = utime;
+ return ret;
+}
+
+static void print_fps(void)
+{
+ if (pl_fbdev_bpp == 16)
+ pl_text_out16(2, pl_fbdev_h - 10, "%2d %4.1f", flips_per_sec, fps_cur);
+}
+
+static void print_cpu_usage(void)
+{
+ if (pl_fbdev_bpp == 16)
+ pl_text_out16(pl_fbdev_w - 28, pl_fbdev_h - 10, "%3d", tick_per_sec);
+}
int pl_fbdev_init(void)
{
{
void *ret;
+ if (w == pl_fbdev_w && h == pl_fbdev_h && bpp == pl_fbdev_bpp)
+ return 0;
+
pl_fbdev_w = w;
+ pl_fbdev_h = h;
+ pl_fbdev_bpp = bpp;
vout_fbdev_clear(layer_fb);
ret = vout_fbdev_resize(layer_fb, w, h, bpp, 0, 0, 0, 0, 3);
return (ret != NULL) ? 0 : -1;
}
-void *pl_fbdev_flip(void)
+void pl_fbdev_flip(void)
{
/* doing input here because the pad is polled
* thousands of times for some reason */
stop = 1;
keystate = actions[IN_BINDTYPE_PLAYER12];
+ flip_cnt++;
+ print_fps();
+ print_cpu_usage();
+
// let's flip now
pl_fbdev_buf = vout_fbdev_flip(layer_fb);
- return pl_fbdev_buf;
}
void pl_fbdev_finish(void)
{
}
+/* called on every vsync */
+void pl_frame_limit(void)
+{
+ extern void CheckFrameRate(void);
+ static int oldsec;
+ struct timeval tv;
+
+ pcnt_end(PCNT_ALL);
+ gettimeofday(&tv, 0);
+
+ if (tv.tv_sec != oldsec) {
+ flips_per_sec = flip_cnt;
+ flip_cnt = 0;
+ tick_per_sec = get_cpu_ticks();
+ oldsec = tv.tv_sec;
+ }
+#ifdef PCNT
+ static int ya_vsync_count;
+ if (++ya_vsync_count == PCNT_FRAMES) {
+ pcnt_print(fps_cur);
+ ya_vsync_count = 0;
+ }
+#endif
+
+ CheckFrameRate();
+
+ pcnt_start(PCNT_ALL);
+}
+
static void pl_text_out16_(int x, int y, const char *text)
{
int i, l, len = strlen(text), w = pl_fbdev_w;
int pl_fbdev_init(void);
int pl_fbdev_set_mode(int w, int h, int bpp);
-void *pl_fbdev_flip(void);
+void pl_fbdev_flip(void);
void pl_fbdev_finish(void);
void pl_text_out16(int x, int y, const char *texto, ...);
#include "swap.h"
#include "plugin_lib.h"
+#include "pcnt.h"
// misc globals
int iResX;
unsigned short usCursorActive = 0;
char * pCaptionText;
-static int fbw, fbh, fb24bpp;
-static int flip_cnt, flips_per_sec;
-
#ifndef __arm__
#define bgr555_to_rgb565 memcpy
#define bgr888_to_rgb888 memcpy
{
bgr555_to_rgb565(dest, srcs, w * 2);
}
- pl_text_out16(2, fbh - 10, "%2d %2.1f", flips_per_sec, fps_cur);
}
}
-#include "pcnt.h"
-
void DoBufferSwap(void)
{
- static int fps_counter;
+ static int fbw, fb24bpp;
+
if (PSXDisplay.DisplayMode.x == 0 || PSXDisplay.DisplayMode.y == 0)
return;
/* careful if rearranging this code, we try to set mode and flip
* to get the hardware apply both changes at the same time */
- if (PSXDisplay.DisplayMode.x != fbw || PSXDisplay.DisplayMode.y != fbh
- || PSXDisplay.RGB24 != fb24bpp) {
+ if (PSXDisplay.DisplayMode.x != fbw || PSXDisplay.RGB24 != fb24bpp) {
+ int fbh = PSXDisplay.DisplayMode.y;
fbw = PSXDisplay.DisplayMode.x;
- fbh = PSXDisplay.DisplayMode.y;
fb24bpp = PSXDisplay.RGB24;
pl_fbdev_set_mode(fbw, fbh, fb24bpp ? 24 : 16);
}
+ pcnt_start(PCNT_BLIT);
blit();
- pl_fbdev_flip();
-
- pcnt_end(PCNT_ALL);
+ pcnt_end(PCNT_BLIT);
- {
- static int oldsec;
- struct timeval tv;
- flip_cnt++;
- gettimeofday(&tv, 0);
- if (tv.tv_sec != oldsec) {
- flips_per_sec = flip_cnt;
- flip_cnt = 0;
- oldsec = tv.tv_sec;
- }
- }
- if (++fps_counter == 60/6) {
- pcnt_print(fps_cur);
- fps_counter = 0;
- }
-
- pcnt_start(PCNT_ALL);
+ pl_fbdev_flip();
}
void DoClearScreenBuffer(void) // CLEAR DX BUFFER
if(!(dwActFixes&1))
lGPUstatusRet^=0x80000000; // odd/even bit
- if(!(dwActFixes&32)) // std fps limitation?
- CheckFrameRate();
+ //if(!(dwActFixes&32)) // std fps limitation?
+ // CheckFrameRate();
+ pl_frame_limit();
if(PSXDisplay.Interlaced) // interlaced mode?
{