gpu_neon: basic frameskip, change check, minor stuff
authornotaz <notasas@gmail.com>
Fri, 17 Jun 2011 22:33:50 +0000 (01:33 +0300)
committernotaz <notasas@gmail.com>
Fri, 12 Aug 2011 21:57:32 +0000 (00:57 +0300)
plugins/gpu_neon/Makefile
plugins/gpu_neon/gpu.c
plugins/gpu_neon/gpu.h
plugins/gpu_neon/vout_fb.c

index 974ac1a..556d884 100644 (file)
@@ -4,13 +4,14 @@ ARCH = $(shell $(CC) -v 2>&1 | grep -i 'target:' | awk '{print $$2}' | awk -F '-
 
 CFLAGS += -ggdb -Wall -fPIC -O2
 
 
 CFLAGS += -ggdb -Wall -fPIC -O2
 
-TARGET = gpu_neon.so
 LDFLAGS += -shared -Wl,-soname,$(TARGET)
 SRC += gpu.c
 ifeq "$(ARCH)" "arm"
 LDFLAGS += -shared -Wl,-soname,$(TARGET)
 SRC += gpu.c
 ifeq "$(ARCH)" "arm"
+TARGET = gpu_neon.so
 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
 SRC += vout_fb.c ../../frontend/arm_utils.s
 else
 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
 SRC += vout_fb.c ../../frontend/arm_utils.s
 else
+TARGET = gpu_neon.so.x86
 CFLAGS += `sdl-config --cflags` -m32
 LDFLAGS += `sdl-config --libs`
 SRC += vout_sdl.c
 CFLAGS += `sdl-config --cflags` -m32
 LDFLAGS += `sdl-config --libs`
 SRC += vout_sdl.c
index c43fd31..91a1738 100644 (file)
@@ -26,6 +26,10 @@ long GPUinit(void)
 {
   int ret = vout_init();
   gpu.status.reg = 0x14802000;
 {
   int ret = vout_init();
   gpu.status.reg = 0x14802000;
+  gpu.status.blanking = 1;
+  gpu.regs[3] = 1;
+  gpu.screen.hres = gpu.screen.w = 320;
+  gpu.screen.vres = gpu.screen.h = 240;
   gpu.lcf_hc = &gpu.zero;
   return ret;
 }
   gpu.lcf_hc = &gpu.zero;
   return ret;
 }
@@ -56,14 +60,29 @@ static noinline void update_height(void)
   gpu.screen.h = sh;
 }
 
   gpu.screen.h = sh;
 }
 
+static noinline void decide_frameskip(void)
+{
+  gpu.frameskip.frame_ready = !gpu.frameskip.active;
+
+  if (!gpu.frameskip.active && *gpu.frameskip.advice)
+    gpu.frameskip.active = 1;
+  else
+    gpu.frameskip.active = 0;
+}
+
 void GPUwriteStatus(uint32_t data)
 {
   static const short hres[8] = { 256, 368, 320, 384, 512, 512, 640, 640 };
   static const short vres[4] = { 240, 480, 256, 480 };
   uint32_t cmd = data >> 24;
 
 void GPUwriteStatus(uint32_t data)
 {
   static const short hres[8] = { 256, 368, 320, 384, 512, 512, 640, 640 };
   static const short vres[4] = { 240, 480, 256, 480 };
   uint32_t cmd = data >> 24;
 
-  if (cmd < ARRAY_SIZE(gpu.regs))
+  if (cmd < ARRAY_SIZE(gpu.regs)) {
+    if (cmd != 0 && gpu.regs[cmd] == data)
+      return;
     gpu.regs[cmd] = data;
     gpu.regs[cmd] = data;
+  }
+
+  gpu.state.fb_dirty = 1;
 
   switch (cmd) {
     case 0x00:
 
   switch (cmd) {
     case 0x00:
@@ -79,6 +98,8 @@ void GPUwriteStatus(uint32_t data)
     case 0x05:
       gpu.screen.x = data & 0x3ff;
       gpu.screen.y = (data >> 10) & 0x3ff;
     case 0x05:
       gpu.screen.x = data & 0x3ff;
       gpu.screen.y = (data >> 10) & 0x3ff;
+      if (gpu.frameskip.enabled)
+        decide_frameskip();
       break;
     case 0x06:
       gpu.screen.x1 = data & 0xfff;
       break;
     case 0x06:
       gpu.screen.x1 = data & 0xfff;
@@ -198,6 +219,7 @@ static void start_vram_transfer(uint32_t pos_word, uint32_t size_word, int is_re
 static int check_cmd(uint32_t *data, int count)
 {
   int len, cmd, start, pos;
 static int check_cmd(uint32_t *data, int count)
 {
   int len, cmd, start, pos;
+  int vram_dirty = 0;
 
   // process buffer
   for (start = pos = 0; pos < count; )
 
   // process buffer
   for (start = pos = 0; pos < count; )
@@ -240,6 +262,8 @@ static int check_cmd(uint32_t *data, int count)
           gpu.status.reg |= (list[0] & 3) << 11;
           break;
       }
           gpu.status.reg |= (list[0] & 3) << 11;
           break;
       }
+      if (2 <= cmd && cmd < 0xc0)
+        vram_dirty = 1;
 
       if (pos + len > count) {
         cmd = -1;
 
       if (pos + len > count) {
         cmd = -1;
@@ -251,7 +275,8 @@ static int check_cmd(uint32_t *data, int count)
     }
 
     if (pos - start > 0) {
     }
 
     if (pos - start > 0) {
-      do_cmd_list(data + start, pos - start);
+      if (!gpu.frameskip.active)
+        do_cmd_list(data + start, pos - start);
       start = pos;
     }
 
       start = pos;
     }
 
@@ -265,6 +290,8 @@ static int check_cmd(uint32_t *data, int count)
       break;
   }
 
       break;
   }
 
+  gpu.state.fb_dirty |= vram_dirty;
+
   return count - pos;
 }
 
   return count - pos;
 }
 
@@ -390,6 +417,8 @@ typedef struct GPUFREEZETAG
 
 long GPUfreeze(uint32_t type, GPUFreeze_t *freeze)
 {
 
 long GPUfreeze(uint32_t type, GPUFreeze_t *freeze)
 {
+  int i;
+
   switch (type) {
     case 1: // save
       if (gpu.cmd_len > 0)
   switch (type) {
     case 1: // save
       if (gpu.cmd_len > 0)
@@ -402,9 +431,10 @@ long GPUfreeze(uint32_t type, GPUFreeze_t *freeze)
       memcpy(gpu.vram, freeze->psxVRam, sizeof(gpu.vram));
       memcpy(gpu.regs, freeze->ulControl, sizeof(gpu.regs));
       gpu.status.reg = freeze->ulStatus;
       memcpy(gpu.vram, freeze->psxVRam, sizeof(gpu.vram));
       memcpy(gpu.regs, freeze->ulControl, sizeof(gpu.regs));
       gpu.status.reg = freeze->ulStatus;
-      GPUwriteStatus((5 << 24) | gpu.regs[5]);
-      GPUwriteStatus((7 << 24) | gpu.regs[7]);
-      GPUwriteStatus((8 << 24) | gpu.regs[8]);
+      for (i = 8; i > 0; i--) {
+        gpu.regs[i] ^= 1; // avoid reg change detection
+        GPUwriteStatus((i << 24) | (gpu.regs[i] ^ 1));
+      }
       break;
   }
 
       break;
   }
 
index 8813a44..bb2d6f6 100644 (file)
@@ -57,6 +57,15 @@ struct psx_gpu {
   int cmd_len;
   const uint32_t *lcf_hc;
   uint32_t zero;
   int cmd_len;
   const uint32_t *lcf_hc;
   uint32_t zero;
+  struct {
+    uint32_t fb_dirty:1;
+  } state;
+  struct {
+    uint32_t enabled:1;
+    uint32_t active:1;
+    uint32_t frame_ready:1;
+    const int *advice;
+  } frameskip;
 };
 
 extern struct psx_gpu gpu;
 };
 
 extern struct psx_gpu gpu;
index fdcfd51..f80a29f 100644 (file)
@@ -81,12 +81,20 @@ static void blit(void)
 
 void GPUupdateLace(void)
 {
 
 void GPUupdateLace(void)
 {
-  if (!gpu.status.blanking)
+  if (gpu.frameskip.enabled && !gpu.frameskip.frame_ready)
+    return;
+
+  if (!gpu.status.blanking && gpu.state.fb_dirty) {
     blit();
     blit();
+    gpu.state.fb_dirty = 0;
+  }
 }
 
 long GPUopen(void)
 {
 }
 
 long GPUopen(void)
 {
+  gpu.frameskip.enabled = cbs->frameskip;
+  gpu.frameskip.advice = &cbs->fskip_advice;
+
   cbs->pl_fbdev_open();
   screen_buf = cbs->pl_fbdev_flip();
   return 0;
   cbs->pl_fbdev_open();
   screen_buf = cbs->pl_fbdev_flip();
   return 0;
@@ -101,6 +109,9 @@ long GPUclose(void)
 void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_)
 {
   cbs = cbs_;
 void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_)
 {
   cbs = cbs_;
+  gpu.frameskip.enabled = cbs->frameskip;
+  gpu.frameskip.advice = &cbs->fskip_advice;
+  gpu.frameskip.active = gpu.frameskip.frame_ready = 0;
 }
 
 // vim:shiftwidth=2:expandtab
 }
 
 // vim:shiftwidth=2:expandtab