loki5100

09-02-2017, 11:45 AM

I do not understand, I took the source code of delphi to see how it is performed with OpenGL (under android). so on every paint delphi do :

eglSwapBuffers(TCustomAndroidContext.SharedDisplay , TCustomAndroidContext.SharedSurface)

so this make OpenGL swapping the back buffer with the display buffer (if i understand well), waiting for the vsync signal first (is this really true?). So as the vsync signal is fired every 16.6 ms I must have between every eglSwapBuffers a multiple of 16.6 (ex 16.6 or 33.2 or 49.8, etc).

To measure it I do like this :

I replace

procedure ContextFlip;

begin

if eglSwapBuffers(TCustomAndroidContext.SharedDisplay , TCustomAndroidContext.SharedSurface) = 0 then

glGetError;

end;

with

var vSyncStopWatch: TstopWatch;

procedure ContextFlip;

begin

if eglSwapBuffers(TCustomAndroidContext.SharedDisplay , TCustomAndroidContext.SharedSurface) = 0 then

glGetError;

vSyncStopWatch.Stop;

if vSyncStopWatch.Elapsed.TotalMilliseconds > 16.6 then allog('VSYNC deadline missed', floattostr(vSyncStopWatch.Elapsed.TotalMillisecond s), tallogType.WARN);

vSyncStopWatch := TstopWatch.StartNew;

end;

but what I don't understand, is why I have value like 18ms, 22ms, 24ms, 28ms, 27ms, etc.. instead of only 16.6 or 33.2 or 49.8, etc ? how is it possible ? does eglSwapBuffers really wait for the vsync signal ?

eglSwapBuffers(TCustomAndroidContext.SharedDisplay , TCustomAndroidContext.SharedSurface)

so this make OpenGL swapping the back buffer with the display buffer (if i understand well), waiting for the vsync signal first (is this really true?). So as the vsync signal is fired every 16.6 ms I must have between every eglSwapBuffers a multiple of 16.6 (ex 16.6 or 33.2 or 49.8, etc).

To measure it I do like this :

I replace

procedure ContextFlip;

begin

if eglSwapBuffers(TCustomAndroidContext.SharedDisplay , TCustomAndroidContext.SharedSurface) = 0 then

glGetError;

end;

with

var vSyncStopWatch: TstopWatch;

procedure ContextFlip;

begin

if eglSwapBuffers(TCustomAndroidContext.SharedDisplay , TCustomAndroidContext.SharedSurface) = 0 then

glGetError;

vSyncStopWatch.Stop;

if vSyncStopWatch.Elapsed.TotalMilliseconds > 16.6 then allog('VSYNC deadline missed', floattostr(vSyncStopWatch.Elapsed.TotalMillisecond s), tallogType.WARN);

vSyncStopWatch := TstopWatch.StartNew;

end;

but what I don't understand, is why I have value like 18ms, 22ms, 24ms, 28ms, 27ms, etc.. instead of only 16.6 or 33.2 or 49.8, etc ? how is it possible ? does eglSwapBuffers really wait for the vsync signal ?