diff --git a/DDrawCompat/DDraw/DirectDrawSurface.cpp b/DDrawCompat/DDraw/DirectDrawSurface.cpp index 5159540..0710e26 100644 --- a/DDrawCompat/DDraw/DirectDrawSurface.cpp +++ b/DDrawCompat/DDraw/DirectDrawSurface.cpp @@ -58,10 +58,8 @@ namespace SET_COMPAT_METHOD(Blt); SET_COMPAT_METHOD(BltFast); SET_COMPAT_METHOD(Flip); - SET_COMPAT_METHOD(GetBltStatus); SET_COMPAT_METHOD(GetCaps); SET_COMPAT_METHOD(GetDC); - SET_COMPAT_METHOD(GetFlipStatus); SET_COMPAT_METHOD(GetSurfaceDesc); SET_COMPAT_METHOD(IsLost); SET_COMPAT_METHOD(Lock); diff --git a/DDrawCompat/DDraw/RealPrimarySurface.cpp b/DDrawCompat/DDraw/RealPrimarySurface.cpp index e9ecd8d..9d56fc9 100644 --- a/DDrawCompat/DDraw/RealPrimarySurface.cpp +++ b/DDrawCompat/DDraw/RealPrimarySurface.cpp @@ -317,7 +317,6 @@ namespace DDraw updateNow(PrimarySurface::getPrimary(), flipInterval); } g_flipEndVsyncCount = D3dDdi::KernelModeThunks::getVsyncCounter() + flipInterval; - g_presentEndVsyncCount = g_flipEndVsyncCount; if (0 != flipInterval) { @@ -424,7 +423,7 @@ namespace DDraw } } - bool RealPrimarySurface::waitForFlip(Surface* surface, bool wait) + bool RealPrimarySurface::waitForFlip(Surface* surface) { auto primary(DDraw::PrimarySurface::getPrimary()); if (!surface || !primary || @@ -434,11 +433,6 @@ namespace DDraw return true; } - if (!wait) - { - return !isFlipPending(); - } - D3dDdi::KernelModeThunks::waitForVsyncCounter(g_flipEndVsyncCount); return true; } diff --git a/DDrawCompat/DDraw/RealPrimarySurface.h b/DDrawCompat/DDraw/RealPrimarySurface.h index f8b7117..10d01e7 100644 --- a/DDrawCompat/DDraw/RealPrimarySurface.h +++ b/DDrawCompat/DDraw/RealPrimarySurface.h @@ -28,6 +28,6 @@ namespace DDraw static void scheduleUpdate(); static HRESULT setGammaRamp(DDGAMMARAMP* rampData); static void update(); - static bool waitForFlip(Surface* surface, bool wait = true); + static bool waitForFlip(Surface* surface); }; } diff --git a/DDrawCompat/DDraw/Surfaces/PrimarySurfaceImpl.cpp b/DDrawCompat/DDraw/Surfaces/PrimarySurfaceImpl.cpp index 380aba9..210da24 100644 --- a/DDrawCompat/DDraw/Surfaces/PrimarySurfaceImpl.cpp +++ b/DDrawCompat/DDraw/Surfaces/PrimarySurfaceImpl.cpp @@ -120,11 +120,7 @@ namespace DDraw template HRESULT PrimarySurfaceImpl::Flip(TSurface* This, TSurface* lpDDSurfaceTargetOverride, DWORD dwFlags) { - if (!waitForFlip(This, dwFlags, DDFLIP_WAIT, DDFLIP_DONOTWAIT)) - { - return DDERR_WASSTILLDRAWING; - } - + DDraw::RealPrimarySurface::waitForFlip(m_data); auto surfaceTargetOverride(CompatPtr::from(lpDDSurfaceTargetOverride)); const bool isFlipEmulated = 0 != (PrimarySurface::getOrigCaps() & DDSCAPS_SYSTEMMEMORY); if (isFlipEmulated) diff --git a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.cpp b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.cpp index 7cba1a4..9727dbc 100644 --- a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.cpp +++ b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.cpp @@ -9,15 +9,6 @@ #include #include -namespace -{ - void* getSurface7VtablePtr(IUnknown* surface) - { - static void* vtable = CompatPtr::from(surface).get()->lpVtbl; - return vtable; - } -} - namespace DDraw { template @@ -36,10 +27,7 @@ namespace DDraw TSurface* This, LPRECT lpDestRect, TSurface* lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) { - if (!waitForFlip(This, dwFlags, DDBLT_WAIT, DDBLT_DONOTWAIT)) - { - return DDERR_WASSTILLDRAWING; - } + RealPrimarySurface::waitForFlip(m_data); DirectDrawClipper::update(); return getOrigVtable(This).Blt(This, lpDestRect, lpDDSrcSurface, lpSrcRect, dwFlags, lpDDBltFx); } @@ -48,10 +36,7 @@ namespace DDraw HRESULT SurfaceImpl::BltFast( TSurface* This, DWORD dwX, DWORD dwY, TSurface* lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) { - if (!waitForFlip(This, dwTrans, DDBLTFAST_WAIT, DDBLTFAST_DONOTWAIT)) - { - return DDERR_WASSTILLDRAWING; - } + RealPrimarySurface::waitForFlip(m_data); return getOrigVtable(This).BltFast(This, dwX, dwY, lpDDSrcSurface, lpSrcRect, dwTrans); } @@ -61,21 +46,6 @@ namespace DDraw return getOrigVtable(This).Flip(This, lpDDSurfaceTargetOverride, dwFlags); } - template - HRESULT SurfaceImpl::GetBltStatus(TSurface* This, DWORD dwFlags) - { - HRESULT result = getOrigVtable(This).GetBltStatus(This, dwFlags); - if (SUCCEEDED(result) && (dwFlags & DDGBS_CANBLT)) - { - const bool wait = false; - if (!RealPrimarySurface::waitForFlip(m_data, wait)) - { - return DDERR_WASSTILLDRAWING; - } - } - return result; - } - template HRESULT SurfaceImpl::GetCaps(TSurface* This, TDdsCaps* lpDDSCaps) { @@ -90,30 +60,15 @@ namespace DDraw template HRESULT SurfaceImpl::GetDC(TSurface* This, HDC* lphDC) { + RealPrimarySurface::waitForFlip(m_data); HRESULT result = getOrigVtable(This).GetDC(This, lphDC); if (SUCCEEDED(result)) { - RealPrimarySurface::waitForFlip(m_data); Dll::g_origProcs.ReleaseDDThreadLock(); } return result; } - template - HRESULT SurfaceImpl::GetFlipStatus(TSurface* This, DWORD dwFlags) - { - HRESULT result = getOrigVtable(This).GetFlipStatus(This, dwFlags); - if (SUCCEEDED(result)) - { - const bool wait = false; - if (!RealPrimarySurface::waitForFlip(m_data, wait)) - { - return DDERR_WASSTILLDRAWING; - } - } - return result; - } - template HRESULT SurfaceImpl::GetSurfaceDesc(TSurface* This, TSurfaceDesc* lpDDSurfaceDesc) { @@ -142,11 +97,7 @@ namespace DDraw TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) { - if (!waitForFlip(This, dwFlags, DDLOCK_WAIT, DDLOCK_DONOTWAIT)) - { - return DDERR_WASSTILLDRAWING; - } - + RealPrimarySurface::waitForFlip(m_data); HRESULT result = getOrigVtable(This).Lock(This, lpDestRect, lpDDSurfaceDesc, dwFlags, hEvent); if (SUCCEEDED(result)) { @@ -235,14 +186,6 @@ namespace DDraw } } - template - bool SurfaceImpl::waitForFlip(TSurface* This, DWORD flags, DWORD waitFlag, DWORD doNotWaitFlag) - { - const bool wait = (flags & waitFlag) || !(flags & doNotWaitFlag) && - getSurface7VtablePtr(reinterpret_cast(This)) == This->lpVtbl; - return DDraw::RealPrimarySurface::waitForFlip(m_data, wait); - } - template SurfaceImpl; template SurfaceImpl; template SurfaceImpl; diff --git a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h index 2ad3e5b..34b9592 100644 --- a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h +++ b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h @@ -27,10 +27,8 @@ namespace DDraw virtual HRESULT BltFast(TSurface* This, DWORD dwX, DWORD dwY, TSurface* lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans); virtual HRESULT Flip(TSurface* This, TSurface* lpDDSurfaceTargetOverride, DWORD dwFlags); - virtual HRESULT GetBltStatus(TSurface* This, DWORD dwFlags); virtual HRESULT GetCaps(TSurface* This, TDdsCaps* lpDDSCaps); virtual HRESULT GetDC(TSurface* This, HDC* lphDC); - virtual HRESULT GetFlipStatus(TSurface* This, DWORD dwFlags); virtual HRESULT GetSurfaceDesc(TSurface* This, TSurfaceDesc* lpDDSurfaceDesc); virtual HRESULT IsLost(TSurface* This); virtual HRESULT Lock(TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc, @@ -43,11 +41,9 @@ namespace DDraw virtual HRESULT Unlock(TSurface* This, TUnlockParam lpRect); protected: - bool waitForFlip(TSurface* This, DWORD flags, DWORD waitFlag, DWORD doNotWaitFlag); + Surface* m_data; private: void restoreOrigCaps(DWORD& caps); - - Surface* m_data; }; }