From 2d3f31d37e24507276ffc37854fae284a2d04b3f Mon Sep 17 00:00:00 2001 From: nillerusr Date: Fri, 18 Aug 2023 15:40:38 +0300 Subject: [PATCH] android: reset vsync after minimizing window --- appframework/sdlmgr.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/appframework/sdlmgr.cpp b/appframework/sdlmgr.cpp index dd5ee2c2..53ca92d5 100644 --- a/appframework/sdlmgr.cpp +++ b/appframework/sdlmgr.cpp @@ -404,6 +404,9 @@ private: int m_MouseButtonDownX; int m_MouseButtonDownY; + bool m_bResetVsync; + int m_nFramesToSkip; + double m_flPrevGLSwapWindowTime; }; @@ -584,6 +587,9 @@ InitReturnVal_t CSDLMgr::Init() m_nWarpDelta = 0; m_bRawInput = false; + m_nFramesToSkip = 0; + m_bResetVsync = false; + m_flPrevGLSwapWindowTime = 0.0f; memset(m_pixelFormatAttribs, '\0', sizeof (m_pixelFormatAttribs)); @@ -1431,7 +1437,20 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params ) m_flPrevGLSwapWindowTime = tm.GetDurationInProgress().GetMillisecondsF(); - +#ifdef ANDROID + // ADRENO GPU MOMENT, SKIP 5 FRAMES + if( m_bResetVsync ) + { + if( m_nFramesToSkip <= 0 ) + { + SDL_GL_SetSwapInterval(swapInterval); + m_bResetVsync = false; + } + else + m_nFramesToSkip--; + } +#endif + CheckGLError( __LINE__ ); } #endif // DX_TO_GL_ABSTRACTION @@ -1887,6 +1906,7 @@ void CSDLMgr::PumpWindowsMessageLoop() } case SDL_WINDOWEVENT_FOCUS_GAINED: { + m_bResetVsync = true; m_nFramesToSkip = 3; m_bHasFocus = true; SDL_ShowCursor( m_bCursorVisible ? 1 : 0 ); CCocoaEvent theEvent;