From fe78a1c514e6d2589355b838e02c6b7bd82c84b3 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 9 May 2018 20:14:11 +0300 Subject: [PATCH] 4000b9 --- custom.cpp | 285 ++++++++++++++++++++++++----------- od-win32/direct3d11.cpp | 8 +- od-win32/win32.h | 4 +- od-win32/winuaechangelog.txt | 8 + 4 files changed, 216 insertions(+), 89 deletions(-) diff --git a/custom.cpp b/custom.cpp index 528283e4..2e140888 100644 --- a/custom.cpp +++ b/custom.cpp @@ -699,7 +699,7 @@ static void decide_diw (int hpos) if (lhdiw >= diw_hstrt && last_hdiw < diw_hstrt && hdiwstate == DIW_waiting_start) { if (thisline_decision.diwfirstword < 0) - thisline_decision.diwfirstword = diwfirstword < 0 ? PIXEL_XPOS(0) : diwfirstword; + thisline_decision.diwfirstword = diwfirstword < 0 ? min_diwlastword : diwfirstword; hdiwstate = DIW_waiting_stop; } if (((hpos >= maxhpos && HARD_DDF_LIMITS_DISABLED) || (lhdiw >= diw_hstop && last_hdiw < diw_hstop)) && hdiwstate == DIW_waiting_stop) { @@ -8258,8 +8258,10 @@ static void scanlinesleep(int currline, int nextline) target_spin(nextline - currline - 1); return; } - if (busywait) + if (busywait) { + target_spin(1); return; + } if (currprefs.m68k_speed < 0) sleep_millis_main(1); else @@ -8421,7 +8423,8 @@ static bool linesync_beam_multi_dual(void) return input_read_done; } -static bool linesync_beam_multi_single(void) + +static bool linesync_beam_vrr(void) { frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase; bool input_read_done = false; @@ -8459,17 +8462,6 @@ static bool linesync_beam_multi_single(void) do_render_slice(1, display_slice_cnt, vpos - 1); display_rendered = true; } - // if 2 slices: make sure we are out of vblank. - if (display_slices <= 2 && !currprefs.gfx_variable_sync) { - while (!currprefs.turbo_emulation && sync_timeout_check(maxtime)) { - int vp = target_get_display_scanline(-1); - if (vp != -1) - break; - maybe_process_pull_audio(); - target_spin(0); - } - vsync_clear(); - } while (!currprefs.turbo_emulation && sync_timeout_check(maxtime)) { int vp = target_get_display_scanline(-1); @@ -8498,96 +8490,213 @@ static bool linesync_beam_multi_single(void) // topmost/first slice? if (display_slice_cnt == 0) { - // variable sync: use read_processor_time() for vblank timing - if (currprefs.gfx_variable_sync) { - - if (!currprefs.turbo_emulation) { + if (!currprefs.turbo_emulation) { - frame_time_t rpt; - for (;;) { - rpt = read_processor_time(); - if ((int)rpt - (int)(vsyncmintime - vsynctimebase / 2) >= 0 || (int)rpt - (int)vsyncmintime < -2 * vsynctimebase) - break; - maybe_process_pull_audio(); - if (currprefs.m68k_speed < 0 && !was_syncline) { - is_syncline = -1; - return 0; - } - target_spin(0); + frame_time_t rpt; + for (;;) { + rpt = read_processor_time(); + if ((int)rpt - (int)(vsyncmintime - vsynctimebase * 2 / 3) >= 0 || (int)rpt - (int)vsyncmintime < -2 * vsynctimebase) + break; + maybe_process_pull_audio(); + if (currprefs.m68k_speed < 0 && !was_syncline) { + is_syncline = -1; + return 0; } + target_spin(0); + } + + if (!was_syncline) { + do_render_slice(2, display_slice_cnt, vpos - 1); + display_rendered = true; + } - if (!was_syncline) { - do_render_slice(2, display_slice_cnt, vpos - 1); - display_rendered = true; + for (;;) { + rpt = read_processor_time(); + if ((int)rpt - (int)vsyncmintime >= 0 || (int)rpt - (int)vsyncmintime < -2 * vsynctimebase) + break; + maybe_process_pull_audio(); + if (currprefs.m68k_speed < 0 && !was_syncline) { + is_syncline = -1; + return 0; } + target_spin(0); + } + if ((int)rpt - (int)vsyncmintime < vsynctimebase && (int)rpt - (int)vsyncmintime > -vsynctimebase) { + vsyncmintime += vsynctimebase; + } else { + vsyncmintime = rpt + vsynctimebase; + } + do_display_slice(); + display_rendered = false; + input_read_done = true; + } - for(;;) { - rpt = read_processor_time(); - if ((int)rpt - (int)vsyncmintime >= 0 || (int)rpt - (int)vsyncmintime < -2 * vsynctimebase) - break; + } else { + + if (!currprefs.turbo_emulation) { + if (!was_syncline && !display_rendered) { + do_render_slice(0, display_slice_cnt, vpos - 1); + display_rendered = true; + } + while (sync_timeout_check(maxtime)) { + int vp = target_get_display_scanline(-1); + // We are still in vblank and second slice? Poll until vblank ends. + if (display_slice_cnt == 1 && vp == -1) { maybe_process_pull_audio(); - if (currprefs.m68k_speed < 0 && !was_syncline) { - is_syncline = -1; - return 0; - } target_spin(0); +#if LLV_DEBUG + write_log(_T("3:%d:%d:%d:%d."), vpos, vp, nextwaitvpos, vsyncnextscanline); +#endif + continue; } - if ((int)rpt - (int)vsyncmintime < vsynctimebase && (int)rpt - (int)vsyncmintime > -vsynctimebase) { - vsyncmintime += vsynctimebase; - } else { - vsyncmintime = rpt + vsynctimebase; + if (vp < 0 || vp >= vsyncnextscanline) + break; + maybe_process_pull_audio(); + if (currprefs.m68k_speed < 0 && !was_syncline) { + is_syncline = vsyncnextscanline; + return 0; } - do_display_slice(); - display_rendered = false; - input_read_done = true; + scanlinesleep(vp, vsyncnextscanline); +#if LLV_DEBUG + write_log(_T("4:%d:%d:%d:%d."), vpos, vp, nextwaitvpos, vsyncnextscanline); +#endif } + do_display_slice(); + input_read_done = true; + display_rendered = false; + } + vsyncnextscanline += vsyncnextscanline_add; + vsync_clear(); + } + nextwaitvpos += display_slice_lines; + display_slice_cnt++; +#if LLV_DEBUG + write_log("\n"); +#endif + } - } else { + return input_read_done; +} - // non-variable: poll vblank - if (!currprefs.turbo_emulation) { - if (!was_syncline) { - do_render_slice(2, display_slice_cnt, vpos - 1); - display_rendered = true; - } - // flip slightly early because flip regularly gets delayed if done during vblank - int lastflipline = vsync_activeheight - vsyncnextscanline_add / 3; - while (sync_timeout_check(maxtime)) { - int vp = target_get_display_scanline(-1); - maybe_process_pull_audio(); - if (vp < vsync_activeheight / 2 || vp >= lastflipline) - break; - if (currprefs.m68k_speed < 0 && !was_syncline) { - is_syncline_end = lastflipline; - is_syncline = -2; - return 0; - } - target_spin(0); +static bool linesync_beam_multi_single(void) +{ + frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase; + bool input_read_done = false; + bool was_syncline = is_syncline != 0; + + is_syncline = 0; + if (vpos == 0 && !was_syncline) { + int firstline, lastline; + linesync_first_last_line(&firstline, &lastline); + + display_slices = currprefs.gfx_display_sections; + if (!display_slices) + display_slices = 1; + display_slice_cnt = 0; + vsyncnextscanline = vsync_activeheight / display_slices + 1; + vsyncnextscanline_add = vsync_activeheight / display_slices; + display_slice_lines = (lastline - firstline) / display_slices + 1; + nextwaitvpos = firstline + display_slice_lines + display_slice_lines / 2; + if (display_slices <= 1) + nextwaitvpos = lastline + 1; + if (display_slices <= 2 && vsyncnextscanline > vsync_activeheight * 2 / 3) + vsyncnextscanline = vsync_activeheight * 2 / 3; + + display_rendered = false; + frame_rendered = true; + frame_shown = true; + } + + if (!display_slices) + return false; + + if (is_last_line()) { + + if (!was_syncline && !display_rendered) { + do_render_slice(1, display_slice_cnt, vpos - 1); + display_rendered = true; + } + // if 2 slices: make sure we are out of vblank. + if (display_slices <= 2) { + while (!currprefs.turbo_emulation && sync_timeout_check(maxtime)) { + int vp = target_get_display_scanline(-1); + if (vp != -1) + break; + maybe_process_pull_audio(); + target_spin(0); + } + vsync_clear(); + } + + while (!currprefs.turbo_emulation && sync_timeout_check(maxtime)) { + int vp = target_get_display_scanline(-1); + if (vp < 0 || vp >= vsyncnextscanline) + break; + maybe_process_pull_audio(); + if (currprefs.m68k_speed < 0 && !was_syncline) { + is_syncline = vsyncnextscanline; + return 0; + } + scanlinesleep(vp, vsyncnextscanline); #if LLV_DEBUG - write_log(_T("2:%d:%d:%d:%d."), vpos, vp, nextwaitvpos, vsyncnextscanline); + write_log(_T("1:%d:%d:%d:%d."), vpos, vp, nextwaitvpos, vsyncnextscanline); +#endif + } + do_display_slice(); + input_read_done = true; + display_slice_cnt = -1; + display_rendered = false; +#if LLV_DEBUG + write_log("\n"); #endif - } - do_display_slice(); - display_rendered = false; - input_read_done = true; -#if 1 - // if flipped before vblank, wait for vblank - while (sync_timeout_check(maxtime)) { - int vp = target_get_display_scanline(-1); - if (vp < vsync_activeheight / 2) - break; - if (currprefs.m68k_speed < 0 && !was_syncline) { - is_syncline = -1; - return 0; - } - maybe_process_pull_audio(); - target_spin(0); + } else if (vpos >= nextwaitvpos) { + + // topmost/first slice? + if (display_slice_cnt == 0) { + + if (!currprefs.turbo_emulation) { + if (!was_syncline) { + do_render_slice(2, display_slice_cnt, vpos - 1); + display_rendered = true; + } + + // flip slightly early because flip regularly gets delayed if done during vblank + int lastflipline = vsync_activeheight - vsyncnextscanline_add / 3; + while (sync_timeout_check(maxtime)) { + int vp = target_get_display_scanline(-1); + maybe_process_pull_audio(); + if (vp < vsync_activeheight / 2 || vp >= lastflipline) + break; + if (currprefs.m68k_speed < 0 && !was_syncline) { + is_syncline_end = lastflipline; + is_syncline = -2; + return 0; } + target_spin(0); +#if LLV_DEBUG + write_log(_T("2:%d:%d:%d:%d."), vpos, vp, nextwaitvpos, vsyncnextscanline); #endif } + do_display_slice(); + display_rendered = false; + input_read_done = true; +#if 1 + // if flipped before vblank, wait for vblank + while (sync_timeout_check(maxtime)) { + int vp = target_get_display_scanline(-1); + if (vp < vsync_activeheight / 2) + break; + if (currprefs.m68k_speed < 0 && !was_syncline) { + is_syncline = -1; + return 0; + } + maybe_process_pull_audio(); + target_spin(0); + } +#endif } } else { @@ -8649,7 +8758,9 @@ void vsync_event_done(void) if (currprefs.gfx_display_sections <= 1) { linesync_beam_single(); } else { - if (vsync_vblank >= 85 && !currprefs.gfx_variable_sync) + if (currprefs.gfx_variable_sync) + linesync_beam_vrr(); + else if (vsync_vblank >= 85) linesync_beam_multi_dual(); else linesync_beam_multi_single(); @@ -8807,7 +8918,9 @@ static void hsync_handler_post (bool onvsync) if (currprefs.gfx_display_sections <= 1) { input_read_done = linesync_beam_single(); } else { - if (vsync_vblank >= 85 && !currprefs.gfx_variable_sync) + if (currprefs.gfx_variable_sync) + input_read_done = linesync_beam_vrr(); + else if (vsync_vblank >= 85) input_read_done = linesync_beam_multi_dual(); else input_read_done = linesync_beam_multi_single(); diff --git a/od-win32/direct3d11.cpp b/od-win32/direct3d11.cpp index a1e80c93..d79af430 100644 --- a/od-win32/direct3d11.cpp +++ b/od-win32/direct3d11.cpp @@ -4569,7 +4569,7 @@ static uae_u8 *xD3D11_locktexture(int monid, int *pitch, int *height, bool fullu { struct d3d11struct *d3d = &d3d11data[monid]; - recheck(d3d); + // texture allocation must not cause side-effects if (d3d->invalidmode || !d3d->texture2d) return NULL; @@ -4810,6 +4810,8 @@ static bool xD3D_setcursor(int monid, int x, int y, int width, int height, bool { struct d3d11struct *d3d = &d3d11data[monid]; + //write_log(_T("setcursor %d %dx%d %dx%d %d %d\n"), monid, x, y, width, height, visible, noscale); + if (width < 0 || height < 0) return true; @@ -4823,6 +4825,8 @@ static bool xD3D_setcursor(int monid, int x, int y, int width, int height, bool d3d->cursor_offset2_x = d3d->cursor_offset2_y = 0; } + //write_log(_T("%.1fx%.1f %dx%d\n"), d3d->cursor_x, d3d->cursor_y, d3d->cursor_offset2_x, d3d->cursor_offset2_y); + float multx = 1.0; float multy = 1.0; if (d3d->cursor_scale) { @@ -4834,6 +4838,8 @@ static bool xD3D_setcursor(int monid, int x, int y, int width, int height, bool d3d->hwsprite.x = d3d->cursor_x * multx + d3d->cursor_offset2_x * multx; d3d->hwsprite.y = d3d->cursor_y * multy + d3d->cursor_offset2_y * multy; + //write_log(_T("-> %.1fx%.1f %.1f %.1f\n"), d3d->hwsprite.x, d3d->hwsprite.y, multx, multy); + d3d->cursor_scale = !noscale; d3d->cursor_v = visible; d3d->hwsprite.enabled = visible; diff --git a/od-win32/win32.h b/od-win32/win32.h index 14fe9b69..1f1e3b33 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -20,12 +20,12 @@ #define LANG_DLL_FULL_VERSION_MATCH 1 #if WINUAEPUBLICBETA -#define WINUAEBETA _T("8") +#define WINUAEBETA _T("9") #else #define WINUAEBETA _T("") #endif -#define WINUAEDATE MAKEBD(2018, 5, 5) +#define WINUAEDATE MAKEBD(2018, 5, 9) //#define WINUAEEXTRA _T("AmiKit Preview") //#define WINUAEEXTRA _T("Amiga Forever Edition") diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 9ad1a749..c9b22226 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,4 +1,12 @@ +Beta 9: + +- D3D11 mode screen was not fully refreshed when returning back to fullscreen RTG mode with ALT-TAB/GUI exit +- Inserting or removing USB device with very long internal device name caused a crash. +- Inserting USB device may have also logged some other already connected device as newly inserted. +- Fixed JIT FPU FETOXM1. +- If D3D11 mode with level 9.x hardware: test in init phase if main texture creation succeeds, fallback to D3D9 if it fails. It may unexpectedly fail with some old and broken drivers. Previously it would have caused blank screen. +- RTG screen was not updated if only hardware mouse cursor moved and RTG OSD was not enabled or multithreaded RTG was not enabled. (b8) Beta 8: -- 2.47.3