psx_gpu: switch to 1024 width again.
[pcsx_rearmed.git] / plugins / gpulib / gpu.c
index aefd53b..e133f07 100644 (file)
@@ -92,6 +92,12 @@ static noinline void decide_frameskip(void)
     gpu.frameskip.active = 1;
   else
     gpu.frameskip.active = 0;
+
+  if (!gpu.frameskip.active && gpu.frameskip.pending_fill[0] != 0) {
+    int dummy;
+    do_cmd_list(gpu.frameskip.pending_fill, 3, &dummy);
+    gpu.frameskip.pending_fill[0] = 0;
+  }
 }
 
 static noinline int decide_frameskip_allow(uint32_t cmd_e3)
@@ -144,6 +150,7 @@ long GPUinit(void)
 
 long GPUshutdown(void)
 {
+  renderer_finish();
   return vout_finish();
 }
 
@@ -201,6 +208,7 @@ void GPUwriteStatus(uint32_t data)
       gpu.screen.vres = vres[(gpu.status.reg >> 19) & 3];
       update_width();
       update_height();
+      renderer_notify_res_change();
       break;
     default:
       if ((cmd & 0xf0) == 0x10)
@@ -333,6 +341,9 @@ static noinline int do_cmd_list_skip(uint32_t *data, int count, int *last_cmd)
   int cmd = 0, pos = 0, len, dummy;
   int skip = 1;
 
+  gpu.frameskip.pending_fill[0] = 0;
+
+  // XXX: polylines are not properly handled
   while (pos < count && skip) {
     uint32_t *list = data + pos;
     cmd = list[0] >> 24;
@@ -341,7 +352,9 @@ static noinline int do_cmd_list_skip(uint32_t *data, int count, int *last_cmd)
     if (cmd == 0x02) {
       if ((list[2] & 0x3ff) > gpu.screen.w || ((list[2] >> 16) & 0x1ff) > gpu.screen.h)
         // clearing something large, don't skip
-        do_cmd_list(data + pos, 3, &dummy);
+        do_cmd_list(list, 3, &dummy);
+      else
+        memcpy(gpu.frameskip.pending_fill, list, 3 * 4);
     }
     else if ((cmd & 0xf4) == 0x24) {
       // flat textured prim
@@ -581,6 +594,7 @@ long GPUfreeze(uint32_t type, struct GPUFreeze *freeze)
       memcpy(gpu.regs, freeze->ulControl, sizeof(gpu.regs));
       memcpy(gpu.ex_regs, freeze->ulControl + 0xe0, sizeof(gpu.ex_regs));
       gpu.status.reg = freeze->ulStatus;
+      gpu.cmd_len = 0;
       for (i = 8; i > 0; i--) {
         gpu.regs[i] ^= 1; // avoid reg change detection
         GPUwriteStatus((i << 24) | (gpu.regs[i] ^ 1));
@@ -599,7 +613,16 @@ void GPUupdateLace(void)
     flush_cmd_buffer();
   renderer_flush_queues();
 
-  if (gpu.status.blanking || !gpu.state.fb_dirty)
+  if (gpu.status.blanking) {
+    if (!gpu.state.blanked) {
+      vout_blank();
+      gpu.state.blanked = 1;
+      gpu.state.fb_dirty = 1;
+    }
+    return;
+  }
+
+  if (!gpu.state.fb_dirty)
     return;
 
   if (gpu.frameskip.set) {
@@ -613,6 +636,7 @@ void GPUupdateLace(void)
 
   vout_update();
   gpu.state.fb_dirty = 0;
+  gpu.state.blanked = 0;
 }
 
 void GPUvBlank(int is_vblank, int lcf)
@@ -647,6 +671,7 @@ void GPUrearmedCallbacks(const struct rearmed_cbs *cbs)
   gpu.state.hcnt = cbs->gpu_hcnt;
   gpu.state.frame_count = cbs->gpu_frame_count;
   gpu.state.allow_interlace = cbs->gpu_neon.allow_interlace;
+  gpu.state.enhancement_enable = cbs->gpu_neon.enhancement_enable;
 
   if (cbs->pl_vout_set_raw_vram)
     cbs->pl_vout_set_raw_vram(gpu.vram);