From 5d935dcdbf514e0c8f2e5114b60bb4fab2b2e865 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 11 Oct 2023 20:13:51 +0300 Subject: [PATCH] If old and new mode has identical size, check also if render backend surface has not been freed. --- od-win32/direct3d.cpp | 14 ++++++++++++-- od-win32/direct3d11.cpp | 4 ++++ od-win32/gdirender.cpp | 4 ++++ od-win32/win32gfx.cpp | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index 969f34bb..263bcce5 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -2438,6 +2438,8 @@ static void invalidatedeviceobjects (struct d3dstruct *d3d) d3d->d3dswapchain = NULL; } d3d->locked = 0; + d3d->fulllocked = 0; + d3d->fakelock = 0; d3d->maskshift.x = d3d->maskshift.y = d3d->maskshift.z = d3d->maskshift.w = 0; d3d->maskmult.x = d3d->maskmult.y = d3d->maskmult.z = d3d->maskmult.w = 0; } @@ -3094,6 +3096,10 @@ static bool xD3D_alloctexture (int monid, int w, int h) { struct d3dstruct *d3d = &d3ddata[monid]; + if (w < 0 || h < 0) { + return d3d->texture1 != NULL; + } + d3d->tin_w = w * d3d->dmult; d3d->tin_h = h * d3d->dmult; @@ -3809,14 +3815,18 @@ static void xD3D_unlocktexture(int monid, int y_start, int y_end) struct d3dstruct *d3d = &d3ddata[monid]; HRESULT hr; - if (!isd3d(d3d) || !d3d->texture1) + if (!isd3d(d3d)) { return; - + } + if (d3d->fakelock) { d3d->fakelock--; return; } + if (!d3d->texture1) + return; + if (d3d->locked) { LPDIRECT3DTEXTURE9 tex = d3d->texture1; if (d3d->locked == 2) { diff --git a/od-win32/direct3d11.cpp b/od-win32/direct3d11.cpp index 68aa2be9..69692e55 100644 --- a/od-win32/direct3d11.cpp +++ b/od-win32/direct3d11.cpp @@ -5019,6 +5019,10 @@ static bool xD3D11_alloctexture(int monid, int w, int h) struct d3d11struct *d3d = &d3d11data[monid]; bool v; + if (w < 0 || h < 0) { + return d3d->texture2d != NULL; + } + recheck(d3d, monid); if (d3d->invalidmode) diff --git a/od-win32/gdirender.cpp b/od-win32/gdirender.cpp index 0a548e04..c19dea0e 100644 --- a/od-win32/gdirender.cpp +++ b/od-win32/gdirender.cpp @@ -233,6 +233,10 @@ static bool gdi_alloctexture(int monid, int w, int h) { struct gdistruct *gdi = &gdidata[monid]; + if (w < 0 || h < 0) { + return gdi->hdc != NULL; + } + freetexture(monid); gdi->hdc = GetDC(gdi->hwnd); diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 9e69592a..dd9177e4 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -4139,7 +4139,7 @@ bool target_graphics_buffer_update(int monid) h = vb->outheight; } - if (oldtex_w[monid] == w && oldtex_h[monid] == h && oldtex_rtg[monid] == mon->screen_is_picasso) + if (oldtex_w[monid] == w && oldtex_h[monid] == h && oldtex_rtg[monid] == mon->screen_is_picasso && D3D_alloctexture(mon->monitor_id, -1, -1)) return false; if (!w || !h) { -- 2.47.3