aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--frontend/pcnt.h35
-rw-r--r--frontend/plugin_lib.c84
-rw-r--r--frontend/plugin_lib.h2
-rw-r--r--plugins/dfxvideo/draw_fb.c38
-rw-r--r--plugins/dfxvideo/gpu.c5
6 files changed, 123 insertions, 44 deletions
diff --git a/Makefile b/Makefile
index 10614ec..7f4d21b 100644
--- a/Makefile
+++ b/Makefile
@@ -65,6 +65,9 @@ OBJS += frontend/plat_omap.o
else
OBJS += frontend/plat_dummy.o
endif
+ifdef PCNT
+CFLAGS += -DPCNT
+endif
frontend/%.o: CFLAGS += -Wall -DIN_EVDEV
$(TARGET): $(OBJS)
diff --git a/frontend/pcnt.h b/frontend/pcnt.h
index 3cf2925..0aca901 100644
--- a/frontend/pcnt.h
+++ b/frontend/pcnt.h
@@ -3,11 +3,17 @@ enum pcounters {
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];
@@ -21,21 +27,34 @@ 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] /= 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));
}
diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c
index 35a23c1..26d5218 100644
--- a/frontend/plugin_lib.c
+++ b/frontend/plugin_lib.c
@@ -9,16 +9,57 @@
#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)
{
@@ -30,7 +71,12 @@ int pl_fbdev_set_mode(int w, int h, int bpp)
{
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);
@@ -42,7 +88,7 @@ int pl_fbdev_set_mode(int w, int h, int bpp)
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 */
@@ -53,15 +99,47 @@ void *pl_fbdev_flip(void)
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;
diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h
index 02a6240..cfb9bd1 100644
--- a/frontend/plugin_lib.h
+++ b/frontend/plugin_lib.h
@@ -23,7 +23,7 @@ extern void *pl_fbdev_buf;
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, ...);
diff --git a/plugins/dfxvideo/draw_fb.c b/plugins/dfxvideo/draw_fb.c
index b39e2ee..af05dd2 100644
--- a/plugins/dfxvideo/draw_fb.c
+++ b/plugins/dfxvideo/draw_fb.c
@@ -16,6 +16,7 @@
#include "swap.h"
#include "plugin_lib.h"
+#include "pcnt.h"
// misc globals
int iResX;
@@ -36,9 +37,6 @@ PSXPoint_t ptCursorPoint[8];
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
@@ -81,50 +79,30 @@ static void blit(void)
{
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
diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c
index 20e5eef..45f5b38 100644
--- a/plugins/dfxvideo/gpu.c
+++ b/plugins/dfxvideo/gpu.c
@@ -788,8 +788,9 @@ void CALLBACK GPUupdateLace(void) // VSYNC
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?
{