mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[client] main: don't include the swap into the render timings
If vsync is enabled the swap will block until vblank skewing the timing metrics.
This commit is contained in:
parent
0ec66ba210
commit
162b1b93db
@ -114,7 +114,7 @@ typedef bool (* LG_RendererOnFrameFormat)(void * opaque, const LG_Render
|
||||
typedef bool (* LG_RendererOnFrame )(void * opaque, const FrameBuffer * frame, int dmaFD, const FrameDamageRect * damage, int damageCount);
|
||||
typedef bool (* LG_RendererRenderStartup)(void * opaque, bool useDMA);
|
||||
typedef bool (* LG_RendererNeedsRender )(void * opaque);
|
||||
typedef bool (* LG_RendererRender )(void * opaque, LG_RendererRotate rotate, const bool newFrame, const bool invalidateWindow);
|
||||
typedef bool (* LG_RendererRender )(void * opaque, LG_RendererRotate rotate, const bool newFrame, const bool invalidateWindow, void (*preSwap)(void * udata), void * udata);
|
||||
|
||||
typedef struct LG_Renderer
|
||||
{
|
||||
|
@ -879,7 +879,7 @@ inline static void renderLetterBox(struct Inst * this)
|
||||
}
|
||||
|
||||
static bool egl_render(void * opaque, LG_RendererRotate rotate, const bool newFrame,
|
||||
const bool invalidateWindow)
|
||||
const bool invalidateWindow, void (*preSwap)(void * udata), void * udata)
|
||||
{
|
||||
struct Inst * this = (struct Inst *)opaque;
|
||||
EGLint bufferAge = egl_buffer_age(this);
|
||||
@ -1072,6 +1072,7 @@ static bool egl_render(void * opaque, LG_RendererRotate rotate, const bool newFr
|
||||
this->hadOverlay = hasOverlay;
|
||||
this->cursorLast = cursorState;
|
||||
|
||||
preSwap(udata);
|
||||
app_eglSwapBuffers(this->display, this->surface, damage, damageIdx);
|
||||
return true;
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ static bool opengl_needs_render(void * opaque)
|
||||
}
|
||||
|
||||
bool opengl_render(void * opaque, LG_RendererRotate rotate, const bool newFrame,
|
||||
const bool invalidateWindow)
|
||||
const bool invalidateWindow, void (*preSwap)(void * udata), void * udata)
|
||||
{
|
||||
struct Inst * this = (struct Inst *)opaque;
|
||||
if (!this)
|
||||
@ -503,6 +503,7 @@ bool opengl_render(void * opaque, LG_RendererRotate rotate, const bool newFrame,
|
||||
ImGui_ImplOpenGL2_RenderDrawData(igGetDrawData());
|
||||
}
|
||||
|
||||
preSwap(udata);
|
||||
if (this->opt.preventBuffer)
|
||||
{
|
||||
app_glSwapBuffers();
|
||||
|
@ -138,6 +138,13 @@ static bool fpsTimerFn(void * unused)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void preSwapCallback(void * udata)
|
||||
{
|
||||
const uint64_t * renderStart = (const uint64_t *)udata;
|
||||
ringbuffer_push(g_state.renderDuration,
|
||||
&(float) {(nanotime() - *renderStart) * 1e-6f});
|
||||
}
|
||||
|
||||
static int renderThread(void * unused)
|
||||
{
|
||||
if (!g_state.lgr->render_startup(g_state.lgrData, g_state.useDMA))
|
||||
@ -245,13 +252,12 @@ static int renderThread(void * unused)
|
||||
const uint64_t renderStart = nanotime();
|
||||
LG_LOCK(g_state.lgrLock);
|
||||
if (!g_state.lgr->render(g_state.lgrData, g_params.winRotate, newFrame,
|
||||
invalidate))
|
||||
invalidate, preSwapCallback, (void *)&renderStart))
|
||||
{
|
||||
LG_UNLOCK(g_state.lgrLock);
|
||||
break;
|
||||
}
|
||||
LG_UNLOCK(g_state.lgrLock);
|
||||
ringbuffer_push(g_state.renderDuration, &(float) {(nanotime() - renderStart) * 1e-6f});
|
||||
|
||||
const uint64_t t = nanotime();
|
||||
const uint64_t delta = t - g_state.lastRenderTime;
|
||||
|
Loading…
Reference in New Issue
Block a user