Refresh rate updates

This commit is contained in:
Dimitris Panokostas 2020-08-16 22:57:49 +02:00
parent 92b7682a31
commit 3d7ec86ca2
5 changed files with 186 additions and 26 deletions

View file

@ -7775,7 +7775,7 @@ static void vsync_handler_pre (void)
frame_rendered = render_screen(false);
}
if (frame_rendered && !frame_shown) {
frame_shown = show_screen_maybe(true);
frame_shown = show_screen_maybe(isvsync_chipset() >= 0);
}
}
@ -8234,6 +8234,29 @@ STATIC_INLINE bool is_last_line (void)
return vpos + 1 == maxvpos + lof_store;
}
// called when extra CPU wait is done
void vsync_event_done(void)
{
if (!isvsync_chipset()) {
events_reset_syncline();
return;
}
//if (currprefs.gfx_display_sections <= 1) {
// if (vsync_vblank >= 85)
// linesync_beam_single_dual();
// else
// linesync_beam_single_single();
//}
//else {
// if (currprefs.gfx_variable_sync)
// linesync_beam_vrr();
// else if (vsync_vblank >= 85)
// linesync_beam_multi_dual();
// else
// linesync_beam_multi_single();
//}
}
// this prepares for new line
static void hsync_handler_post (bool onvsync)
{

View file

@ -64,6 +64,8 @@ static bool event_check_vsync(void)
events_reset_syncline();
return false;
}
// wait for vblank
audio_finish_pull();
}
else if (is_syncline == -10) {

View file

@ -132,6 +132,56 @@ void fixup_prefs_dimensions(struct uae_prefs* prefs)
if (prefs->gfx_apmode[1].gfx_vsync > 0)
prefs->gfx_apmode[1].gfx_vsyncmode = 1;
for (int i = 0; i < 2; i++) {
struct apmode* ap = &prefs->gfx_apmode[i];
if (ap->gfx_backbuffers < 1)
ap->gfx_backbuffers = 1;
ap->gfx_vflip = 0;
ap->gfx_strobo = false;
if (ap->gfx_vsync) {
if (ap->gfx_vsyncmode) {
if (ap->gfx_fullscreen != 0) {
ap->gfx_backbuffers = 1;
ap->gfx_strobo = prefs->lightboost_strobo;
}
else {
ap->gfx_vsyncmode = 0;
ap->gfx_vsync = 0;
}
}
else {
// legacy vsync: always wait for flip
ap->gfx_vflip = -1;
if (ap->gfx_vflip)
ap->gfx_strobo = prefs->lightboost_strobo;
}
}
else {
if (ap->gfx_backbuffers > 0 && (prefs->gfx_api > 1 || prefs->gfx_variable_sync))
ap->gfx_strobo = prefs->lightboost_strobo;
// no vsync: wait if triple bufferirng
if (ap->gfx_backbuffers >= 2)
ap->gfx_vflip = -1;
}
if (prefs->gf[i].gfx_filter == 0 && ((prefs->gf[i].gfx_filter_autoscale && !prefs->gfx_api) || (prefs->gfx_apmode[APMODE_NATIVE].gfx_vsyncmode))) {
prefs->gf[i].gfx_filter = 1;
}
if (i == 0) {
if (prefs->gf[i].gfx_filter == 0 && prefs->monitoremu) {
error_log(_T("Display port adapter emulation require at least null filter enabled."));
prefs->gf[i].gfx_filter = 1;
}
if (prefs->gf[i].gfx_filter == 0 && prefs->cs_cd32fmv) {
error_log(_T("CD32 MPEG module overlay support require at least null filter enabled."));
prefs->gf[i].gfx_filter = 1;
}
if (prefs->gf[i].gfx_filter == 0 && (prefs->genlock && prefs->genlock_image)) {
error_log(_T("Genlock emulation require at least null filter enabled."));
prefs->gf[i].gfx_filter = 1;
}
}
}
}
void fixup_cpu(struct uae_prefs* p)

View file

@ -508,25 +508,13 @@ void target_default_options(struct uae_prefs* p, int type)
p->floatingJoystick = 0;
p->disableMenuVKeyb = 0;
#endif
p->cr[CHIPSET_REFRESH_PAL].locked = true;
p->cr[CHIPSET_REFRESH_PAL].vsync = 1;
p->cr[CHIPSET_REFRESH_NTSC].locked = true;
p->cr[CHIPSET_REFRESH_NTSC].vsync = 1;
p->cr[0].index = 0;
p->cr[0].horiz = -1;
p->cr[0].vert = -1;
p->cr[0].lace = -1;
p->cr[0].resolution = 0;
p->cr[0].vsync = -1;
p->cr[0].rate = 60.0;
p->cr[0].ntsc = 1;
p->cr[0].locked = true;
p->cr[0].rtg = true;
_tcscpy(p->cr[0].label, _T("RTG"));
//for (auto& i : p->gfx_apmode)
//{
// i.gfx_vsync = 1;
//}
//todo remove this when it's added in the GUI
for (auto& floppyslot : p->floppyslots)
{
floppyslot.dfxclick = 1;

View file

@ -1476,8 +1476,13 @@ unsigned long target_lastsynctime()
bool show_screen_maybe(const bool show)
{
if (show)
show_screen(0);
struct amigadisplay* ad = &adisplays;
struct apmode* ap = ad->picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
if (!ap->gfx_vflip || ap->gfx_vsyncmode == 0 || ap->gfx_vsync <= 0) {
if (show)
show_screen(0);
return false;
}
return false;
}
@ -1752,16 +1757,33 @@ static int save_thumb(char* path)
static int currVSyncRate = 0;
bool vsync_switchmode(int hz)
{
static struct PicassoResolution* oldmode;
static int oldhz;
int w = screen->w;
int h = screen->h;
struct PicassoResolution* found;
int newh, i, cnt;
bool preferdouble = false, preferlace = false;
bool lace = false;
if (currprefs.gfx_apmode[APMODE_NATIVE].gfx_refreshrate > 85) {
preferdouble = true;
}
else if (currprefs.gfx_apmode[APMODE_NATIVE].gfx_interlaced) {
preferlace = true;
}
if (hz >= 55)
hz = 60;
else
hz = 50;
#ifdef USE_DISPMANX
if (hz != currVSyncRate)
{
currVSyncRate = hz;
fpscounter_reset();
#ifdef USE_DISPMANX
time_per_frame = 1000 * 1000 / (hz);
if (hz == host_hz)
@ -1770,10 +1792,85 @@ bool vsync_switchmode(int hz)
vsync_modulo = 6; // Amiga draws 6 frames while host has 5 vsyncs -> sync every 6th Amiga frame
else
vsync_modulo = 5; // Amiga draws 5 frames while host has 6 vsyncs -> sync every 5th Amiga frame
#endif
}
return true;
#else
newh = h * (currprefs.ntscmode ? 60 : 50) / hz;
found = NULL;
for (cnt = 0; cnt <= abs(newh - h) + 1 && !found; cnt++) {
for (int dbl = 0; dbl < 2 && !found; dbl++) {
bool doublecheck = false;
bool lacecheck = false;
if (preferdouble && dbl == 0)
doublecheck = true;
else if (preferlace && dbl == 0)
lacecheck = true;
for (int extra = 1; extra >= -1 && !found; extra--) {
for (i = 0; DisplayModes[i].depth >= 0 && !found; i++) {
struct PicassoResolution* r = &DisplayModes[i];
if (r->res.width == w && (r->res.height == newh + cnt || r->res.height == newh - cnt)) {
int j;
for (j = 0; r->refresh[j] > 0; j++) {
if (doublecheck) {
if (r->refreshtype[j] & REFRESH_RATE_LACE)
continue;
if (r->refresh[j] == hz * 2 + extra) {
found = r;
hz = r->refresh[j];
break;
}
}
else if (lacecheck) {
if (!(r->refreshtype[j] & REFRESH_RATE_LACE))
continue;
if (r->refresh[j] * 2 == hz + extra) {
found = r;
lace = true;
hz = r->refresh[j];
break;
}
}
else {
if (r->refresh[j] == hz + extra) {
found = r;
hz = r->refresh[j];
break;
}
}
}
}
}
}
}
}
if (found == oldmode && hz == oldhz)
return true;
oldmode = found;
oldhz = hz;
if (!found) {
changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_vsync = 0;
if (currprefs.gfx_apmode[APMODE_NATIVE].gfx_vsync != changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_vsync) {
set_config_changed();
}
write_log(_T("refresh rate changed to %d%s but no matching screenmode found, vsync disabled\n"), hz, lace ? _T("i") : _T("p"));
return false;
}
else {
newh = found->res.height;
changed_prefs.gfx_monitor.gfx_size_fs.height = newh;
changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_refreshrate = hz;
changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_interlaced = lace;
if (changed_prefs.gfx_monitor.gfx_size_fs.height != currprefs.gfx_monitor.gfx_size_fs.height ||
changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_refreshrate != currprefs.gfx_apmode[APMODE_NATIVE].gfx_refreshrate) {
write_log(_T("refresh rate changed to %d%s, new screenmode %dx%d\n"), hz, lace ? _T("i") : _T("p"), w, newh);
set_config_changed();
}
return true;
}
#endif
}
bool target_graphics_buffer_update()