various enhancement tweaks
authornotaz <notasas@gmail.com>
Sun, 26 Aug 2012 23:04:01 +0000 (02:04 +0300)
committernotaz <notasas@gmail.com>
Thu, 11 Oct 2012 21:05:08 +0000 (00:05 +0300)
plugins/gpu_neon/psx_gpu/psx_gpu_parse.c
plugins/gpu_neon/psx_gpu_if.c
plugins/gpulib/vout_pl.c

index af82d7e..f920c73 100644 (file)
@@ -601,12 +601,22 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_command)
                        break;
       }
   
-               case 0x80:          //  vid -> vid
-        render_block_move(psx_gpu, list_s16[2] & 0x3FF, list_s16[3] & 0x1FF,
-         list_s16[4] & 0x3FF, list_s16[5] & 0x1FF,
-         ((list_s16[6] - 1) & 0x3FF) + 1, ((list_s16[7] - 1) & 0x1FF) + 1);
-                       break;
+      case 0x80:          //  vid -> vid
+      {
+        u32 sx = list_s16[2] & 0x3FF;
+        u32 sy = list_s16[3] & 0x1FF;
+        u32 dx = list_s16[4] & 0x3FF;
+        u32 dy = list_s16[5] & 0x1FF;
+        u32 w = ((list_s16[6] - 1) & 0x3FF) + 1;
+        u32 h = ((list_s16[7] - 1) & 0x1FF) + 1;
+
+        if (sx == dx && sy == dy && psx_gpu->mask_msb == 0)
+          break;
+
+        render_block_move(psx_gpu, sx, sy, dx, dy, w, h);
+        break;
+      } 
+
 #ifdef PCSX
                case 0xA0:          //  sys -> vid
                case 0xC0:          //  vid -> sys
@@ -750,15 +760,18 @@ breakloop:
   return list - list_start;
 }
 
-#define select_enhancement_buf(psx_gpu) { \
-  u32 _x, _b; \
-  _x = psx_gpu->saved_viewport_start_x + 8; \
-  for (_b = 0; _x >= psx_gpu->enhancement_x_threshold; _b++) \
-    _x -= psx_gpu->enhancement_x_threshold; \
-  psx_gpu->enhancement_current_buf_ptr = \
-    psx_gpu->enhancement_buf_ptr + _b * 1024 * 1024; \
+static void *select_enhancement_buf_ptr(psx_gpu_struct *psx_gpu, u32 x)
+{
+  u32 b;
+  for (b = 0; x >= psx_gpu->enhancement_x_threshold; b++)
+    x -= psx_gpu->enhancement_x_threshold;
+  return psx_gpu->enhancement_buf_ptr + b * 1024 * 1024;
 }
 
+#define select_enhancement_buf(psx_gpu) \
+  psx_gpu->enhancement_current_buf_ptr = \
+    select_enhancement_buf_ptr(psx_gpu, psx_gpu->saved_viewport_start_x + 8)
+
 #define enhancement_disable() { \
   psx_gpu->vram_out_ptr = psx_gpu->vram_ptr; \
   psx_gpu->viewport_start_x = psx_gpu->saved_viewport_start_x; \
@@ -772,8 +785,8 @@ breakloop:
   psx_gpu->vram_out_ptr = psx_gpu->enhancement_current_buf_ptr; \
   psx_gpu->viewport_start_x = psx_gpu->saved_viewport_start_x * 2; \
   psx_gpu->viewport_start_y = psx_gpu->saved_viewport_start_y * 2; \
-  psx_gpu->viewport_end_x = psx_gpu->saved_viewport_end_x * 2; \
-  psx_gpu->viewport_end_y = psx_gpu->saved_viewport_end_y * 2; \
+  psx_gpu->viewport_end_x = psx_gpu->saved_viewport_end_x * 2 + 1; \
+  psx_gpu->viewport_end_y = psx_gpu->saved_viewport_end_y * 2 + 1; \
   psx_gpu->uvrgb_phase = 0x1000; \
 }
 
@@ -800,6 +813,11 @@ breakloop:
 
 extern void scale2x_tiles8(void *dst, const void *src, int w8, int h);
 
+#ifndef NEON_BUILD
+// TODO?
+void scale2x_tiles8(void *dst, const void *src, int w8, int h) {}
+#endif
+
 static int disable_main_render;
 
 static void do_triangle_enhanced(psx_gpu_struct *psx_gpu,
@@ -1301,6 +1319,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c
         u32 dy = list_s16[5] & 0x1FF;
         u32 w = ((list_s16[6] - 1) & 0x3FF) + 1;
         u32 h = ((list_s16[7] - 1) & 0x1FF) + 1;
+        u16 *buf;
+
+        if (sx == dx && sy == dy && psx_gpu->mask_msb == 0)
+          break;
 
         render_block_move(psx_gpu, sx, sy, dx, dy, w, h);
         if (dy + h > 512)
@@ -1308,8 +1330,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c
         sx = sx & ~7; // FIXME?
         dx = dx * 2 & ~7;
         dy *= 2;
-        scale2x_tiles8(psx_gpu->enhancement_buf_ptr + dy * 1024 + dx,
-          psx_gpu->vram_ptr + sy * 1024 + sx, w / 8, h);
+        w = (w + 7) / 8;
+        buf = select_enhancement_buf_ptr(psx_gpu, dx / 2);
+        scale2x_tiles8(buf + dy * 1024 + dx,
+          psx_gpu->vram_ptr + sy * 1024 + sx, w, h);
         break;
       }
  
index 1b4dcc5..c303742 100644 (file)
@@ -41,7 +41,7 @@ int do_cmd_list(uint32_t *list, int count, int *last_cmd)
   return ret;
 }
 
-#define ENHANCEMENT_BUF_SIZE (1024 * 1024 * 2 * 4 + 4096)
+#define ENHANCEMENT_BUF_SIZE (1024 * 1024 * 2 * 4 + 4096 * 2)
 
 static void map_enhancement_buffer(void)
 {
@@ -51,6 +51,8 @@ static void map_enhancement_buffer(void)
   gpu.enhancement_bufer = gpu.mmap(ENHANCEMENT_BUF_SIZE);
   if (gpu.enhancement_bufer == NULL)
     fprintf(stderr, "failed to map enhancement buffer\n");
+  else
+    gpu.enhancement_bufer += 4096 / 2;
   egpu.enhancement_buf_ptr = gpu.enhancement_bufer;
 }
 
@@ -70,10 +72,13 @@ int renderer_init(void)
 
 void renderer_finish(void)
 {
-  if (gpu.enhancement_bufer != NULL)
+  if (gpu.enhancement_bufer != NULL) {
+    gpu.enhancement_bufer -= 4096 / 2;
     gpu.munmap(gpu.enhancement_bufer, ENHANCEMENT_BUF_SIZE);
+  }
   gpu.enhancement_bufer = NULL;
   egpu.enhancement_buf_ptr = NULL;
+  egpu.enhancement_current_buf_ptr = NULL;
   initialized = 0;
 }
 
index 5c74914..2116422 100644 (file)
@@ -77,8 +77,8 @@ static void blit(void)
       (x + 8) / stride * 1024 * 1024;
     x *= 2;
     y *= 2;
-    w = (w - 2) * 2;
-    h = (h * 2) - 1;
+    w = w * 2;
+    h = h * 2;
     stride *= 2;
     vram_mask = 1024 * 1024 - 1;
   }
@@ -130,6 +130,7 @@ void vout_update(void)
 
 void vout_blank(void)
 {
+  gpu.state.enhancement_active = 0;
   check_mode_change();
   if (cbs->pl_vout_raw_flip == NULL) {
     int bytespp = gpu.status.rgb24 ? 3 : 2;