From: Toni Wilen Date: Sun, 22 Apr 2018 16:09:53 +0000 (+0300) Subject: Lagless vsync debug color update. X-Git-Tag: 4000~97 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=2c186995bb251188e6c4a9dd62946b035ca1e42f;p=francis%2Fwinuae.git Lagless vsync debug color update. --- diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index c3eb571c..7eb734b0 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -47,6 +47,12 @@ static struct gfx_filterdata *filterd3d; static int filterd3didx; static bool showoverlay = true; +static int slicecnt; +static int clearcnt; +static bool debugcolors; +static bool noclear; +static bool cannoclear; + int fakemodewaitms; static int leds[LED_MAX]; @@ -204,12 +210,6 @@ struct d3dstruct int ddraw_fs; int ddraw_fs_attempt; LPDIRECTDRAW7 ddraw; - - int slicecnt; - int clearcnt; - bool debugcolors; - bool noclear; - bool cannoclear; }; static struct d3dstruct d3ddata[MAX_AMIGAMONITORS]; @@ -2718,7 +2718,7 @@ static const TCHAR *D3D_init2 (struct d3dstruct *d3d, HWND ahwnd, int w_w, int w } d3d->variablerefresh = false; - d3d->cannoclear = ap.gfx_vsyncmode != 0; + cannoclear = ap.gfx_vsyncmode != 0; memset (&d3d->dpp, 0, sizeof (d3d->dpp)); d3d->dpp.Windowed = isfullscreen () <= 0; @@ -3315,10 +3315,10 @@ static void xD3D_led(int led, int on, int brightness) static int xD3D_debug(int monid, int mode) { struct d3dstruct *d3d = &d3ddata[monid]; - int old = d3d->debugcolors ? 1 : 0; - d3d->debugcolors = (mode & 1) != 0; - d3d->noclear = d3d->debugcolors ? false : true; - d3d->clearcnt = 0; + int old = debugcolors ? 1 : 0; + debugcolors = (mode & 1) != 0; + noclear = debugcolors ? false : true; + clearcnt = 0; return old; } @@ -3327,14 +3327,14 @@ static void clearrt(struct d3dstruct *d3d) HRESULT hr; uae_u8 color[4] = { 0, 0, 0, 0 }; - if (d3d->noclear && d3d->cannoclear) { - if (d3d->clearcnt > 3) + if (noclear && cannoclear) { + if (clearcnt > 3) return; - d3d->clearcnt++; + clearcnt++; } - if (!d3d->noclear && d3d->debugcolors && d3d->slicecnt > 0) { - int cnt = d3d->slicecnt - 1; + if (!noclear && debugcolors && slicecnt > 0) { + int cnt = slicecnt - 1; int v = cnt % 3; if (cnt / 3 == 1) color[(v + 1) % 3] = 80; @@ -3357,13 +3357,13 @@ static void D3D_render2(struct d3dstruct *d3d, int mode) bool normalrender = mode < 0 || (mode & 1); if (mode > 0 && (mode & 2)) - d3d->slicecnt = 0; + slicecnt = 0; else if (mode < 0) - d3d->slicecnt = d3d->slicecnt == 2 ? 0 : d3d->slicecnt; + slicecnt = slicecnt == 2 ? 0 : slicecnt; clearrt(d3d); - d3d->slicecnt++; + slicecnt++; if (FAILED (hr = d3d->d3ddev->BeginScene ())) { write_log (_T("%s: BeginScene: %s\n"), D3DHEAD, D3D_ErrorString (hr)); diff --git a/od-win32/direct3d11.cpp b/od-win32/direct3d11.cpp index fa816fc3..705a771f 100644 --- a/od-win32/direct3d11.cpp +++ b/od-win32/direct3d11.cpp @@ -71,6 +71,11 @@ static HMODULE hd3d11, hdxgi, hd3dcompiler, dwmapi; static struct gfx_filterdata *filterd3d; static int filterd3didx; static int leds[LED_MAX]; +static int debugcolors; +static bool cannoclear; +static bool noclear; +static int clearcnt; +static int slicecnt; static const TCHAR *overlayleds[] = { _T("power"), @@ -293,12 +298,6 @@ struct d3d11struct ID3DX11EffectTechnique *technique; ID3DX11EffectPass *effectpass; - bool debugcolors; - bool cannoclear; - bool noclear; - int clearcnt; - int slicecnt; - #ifndef NDEBUG ID3D11InfoQueue *m_debugInfoQueue; ID3D11Debug *m_debug; @@ -3152,7 +3151,7 @@ static void do_present(struct d3d11struct *d3d, int black) } write_log(_T("D3D11 Present %08x\n"), hr); } - d3d->slicecnt++; + slicecnt++; } static float xD3D_getrefreshrate(int monid) @@ -3520,10 +3519,9 @@ static int xxD3D11_init2(HWND ahwnd, int monid, int w_w, int w_h, int t_w, int t } d3d->vblankintervals = 1; - d3d->debugcolors = false; - d3d->cannoclear = false; + cannoclear = false; if (apm->gfx_vsyncmode) { - d3d->cannoclear = true; + cannoclear = true; d3d->vblankintervals = 0; } @@ -3579,7 +3577,7 @@ static int xxD3D11_init2(HWND ahwnd, int monid, int w_w, int w_h, int t_w, int t d3d->invalidmode = false; d3d->fsmode = 0; - d3d->clearcnt = 0; + clearcnt = 0; write_log(_T("D3D11 %d %08x %08x\n"), d3d->swapChainDesc.BufferCount, d3d->swapChainDesc.Flags, d3d->swapChainDesc.Format); @@ -3976,10 +3974,10 @@ static void xD3D11_led(int led, int on, int brightness) static int xD3D11_debug(int monid, int mode) { struct d3d11struct *d3d = &d3d11data[monid]; - int old = d3d->debugcolors ? 1 : 0; - d3d->debugcolors = (mode & 1) != 0; - d3d->noclear = d3d->debugcolors ? false : true; - d3d->clearcnt = 0; + int old = debugcolors ? 1 : 0; + debugcolors = (mode & 1) != 0; + noclear = debugcolors ? false : true; + clearcnt = 0; return old; } @@ -3992,14 +3990,14 @@ static void clearrt(struct d3d11struct *d3d) color[2] = 0; color[3] = 0; - if (d3d->noclear && d3d->cannoclear) { - if (d3d->clearcnt > 3) + if (noclear && cannoclear) { + if (clearcnt > 3) return; - d3d->clearcnt++; + clearcnt++; } - if (!d3d->noclear && d3d->debugcolors && d3d->slicecnt > 0) { - int cnt = d3d->slicecnt - 1; + if (!noclear && debugcolors && slicecnt > 0) { + int cnt = slicecnt - 1; int v = cnt % 3; if (cnt / 3 == 1) color[(v + 1) % 3] = 0.3; @@ -4315,9 +4313,9 @@ static bool xD3D11_renderframe(int monid, int mode, bool immediate) d3d->frames_since_init++; if (mode > 0 && (mode & 2)) - d3d->slicecnt = 0; + slicecnt = 0; else if (mode < 0) - d3d->slicecnt = d3d->slicecnt == 2 ? 0 : d3d->slicecnt; + slicecnt = slicecnt == 2 ? 0 : slicecnt; if (!d3d->m_swapChain) return false; @@ -4388,7 +4386,7 @@ static void xD3D11_clear(int monid) // Clear the back buffer. d3d->m_deviceContext->ClearRenderTargetView(d3d->m_renderTargetView, color); d3d->m_deviceContext->Flush(); - d3d->clearcnt = 0; + clearcnt = 0; } @@ -4417,7 +4415,7 @@ static void xD3D11_refresh(int monid) if (xD3D11_renderframe(monid, true, true)) { xD3D11_showframe(monid); } - d3d->clearcnt = 0; + clearcnt = 0; } @@ -4600,7 +4598,7 @@ static int xD3D11_goodenough(void) static void xD3D11_change(int monid, int temp) { struct d3d11struct *d3d = &d3d11data[monid]; - d3d->clearcnt = 0; + clearcnt = 0; } static void resizemode(struct d3d11struct *d3d) diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 839bd534..3aff5215 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -4095,10 +4095,6 @@ retry: if (isfullscreen () != 0) setmouseactive(mon->monitor_id, -1); - if (D3D_debug) { - D3D_debug(0, beamracer_debug); - } - return 1; oops: