gpu_neon: frameskip: skip blits until flipped
[pcsx_rearmed.git] / plugins / gpu_neon / vout_fb.c
... / ...
CommitLineData
1/*
2 * (C) GraÅžvydas "notaz" Ignotas, 2011
3 *
4 * This work is licensed under the terms of any of these licenses
5 * (at your option):
6 * - GNU GPL, version 2 or later.
7 * - GNU LGPL, version 2.1 or later.
8 * See the COPYING file in the top-level directory.
9 */
10
11#include "gpu.h"
12#include "../../frontend/plugin_lib.h"
13#include "../../frontend/arm_utils.h"
14
15static const struct rearmed_cbs *cbs;
16static void *screen_buf;
17
18int vout_init(void)
19{
20 return 0;
21}
22
23int vout_finish(void)
24{
25 return 0;
26}
27
28static void blit(void)
29{
30 static uint32_t old_status, old_h;
31 int x = gpu.screen.x & ~1; // alignment needed by blitter
32 int y = gpu.screen.y;
33 int w = gpu.screen.w;
34 int h = gpu.screen.h;
35 int stride = gpu.screen.hres;
36 int doffs;
37 uint16_t *srcs;
38 uint8_t *dest;
39
40 srcs = &gpu.vram[y * 1024 + x];
41
42 if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) // width|rgb24 change?
43 {
44 old_status = gpu.status.reg;
45 old_h = h;
46 screen_buf = cbs->pl_vout_set_mode(stride, h, gpu.status.rgb24 ? 24 : 16);
47 }
48
49 dest = screen_buf;
50
51 // only do centering, at least for now
52 doffs = (stride - w) / 2 & ~1;
53
54 if (gpu.status.rgb24)
55 {
56#ifndef MAEMO
57 dest += (doffs / 8) * 24;
58 for (; h-- > 0; dest += stride * 3, srcs += 1024)
59 {
60 bgr888_to_rgb888(dest, srcs, w * 3);
61 }
62#else
63 dest += doffs * 2;
64 for (; h-- > 0; dest += stride * 2, srcs += 1024)
65 {
66 bgr888_to_rgb565(dest, srcs, w * 3);
67 }
68#endif
69 }
70 else
71 {
72 dest += doffs * 2;
73 for (; h-- > 0; dest += stride * 2, srcs += 1024)
74 {
75 bgr555_to_rgb565(dest, srcs, w * 2);
76 }
77 }
78
79 screen_buf = cbs->pl_vout_flip();
80}
81
82void GPUupdateLace(void)
83{
84 if (gpu.status.blanking || !gpu.state.fb_dirty)
85 return;
86
87 if (gpu.frameskip.enabled) {
88 if (!gpu.frameskip.frame_ready && gpu.frameskip.skipped_blits < 6) {
89 gpu.frameskip.skipped_blits++;
90 return;
91 }
92 gpu.frameskip.frame_ready = 0;
93 gpu.frameskip.skipped_blits = 0;
94 }
95
96 renderer_flush_queues();
97 blit();
98 gpu.state.fb_dirty = 0;
99}
100
101long GPUopen(void)
102{
103 gpu.frameskip.enabled = cbs->frameskip;
104 gpu.frameskip.advice = &cbs->fskip_advice;
105 gpu.frameskip.active = 0;
106 gpu.frameskip.frame_ready = 1;
107
108 cbs->pl_vout_open();
109 screen_buf = cbs->pl_vout_flip();
110 return 0;
111}
112
113long GPUclose(void)
114{
115 cbs->pl_vout_close();
116 return 0;
117}
118
119void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_)
120{
121 cbs = cbs_;
122}
123
124// vim:shiftwidth=2:expandtab