[client] main: let the renderer know if it's rendering a whole new frame

While the renderer can internally track this it would be better to
simply provide this information to the renderer directly so it can make
better decisions on how best to update the screen.
This commit is contained in:
Geoffrey McRae 2021-07-21 17:26:48 +10:00
parent 8cf444ef31
commit 6389a06903
4 changed files with 10 additions and 4 deletions
client
include/interface
renderers
EGL
OpenGL
src

View file

@ -116,7 +116,7 @@ typedef bool (* LG_RendererOnFrame )(void * opaque, const FrameBuff
typedef void (* LG_RendererOnAlert )(void * opaque, const LG_MsgAlert alert, const char * message, bool ** closeFlag);
typedef void (* LG_RendererOnHelp )(void * opaque, const char * message);
typedef bool (* LG_RendererRenderStartup)(void * opaque);
typedef bool (* LG_RendererRender )(void * opaque, LG_RendererRotate rotate);
typedef bool (* LG_RendererRender )(void * opaque, LG_RendererRotate rotate, const bool newFrame);
typedef struct LG_Renderer
{

View file

@ -923,7 +923,7 @@ bool egl_render_startup(void * opaque)
return true;
}
bool egl_render(void * opaque, LG_RendererRotate rotate)
bool egl_render(void * opaque, LG_RendererRotate rotate, const bool newFrame)
{
struct Inst * this = (struct Inst *)opaque;

View file

@ -584,7 +584,7 @@ bool opengl_render_startup(void * opaque)
return true;
}
bool opengl_render(void * opaque, LG_RendererRotate rotate)
bool opengl_render(void * opaque, LG_RendererRotate rotate, const bool newFrame)
{
struct Inst * this = (struct Inst *)opaque;
if (!this)

View file

@ -191,8 +191,14 @@ static int renderThread(void * unused)
atomic_compare_exchange_weak(&g_state.lgrResize, &resize, 0);
}
static uint64_t lastFrameCount = 0;
const uint64_t frameCount =
atomic_load_explicit(&g_state.frameCount, memory_order_relaxed);
const bool newFrame = frameCount != lastFrameCount;
lastFrameCount = frameCount;
LG_LOCK(g_state.lgrLock);
if (!g_state.lgr->render(g_state.lgrData, g_params.winRotate))
if (!g_state.lgr->render(g_state.lgrData, g_params.winRotate, newFrame))
{
LG_UNLOCK(g_state.lgrLock);
break;