When faking GLsync with EGL insert eglSwapBuffers

Change-Id: I5db86b4b0d695e74c14d48c9c29464dade2af442
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412636
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
This commit is contained in:
Brian Salomon 2021-05-26 10:31:23 -04:00 committed by Skia Commit-Bot
parent 3ef2c61c50
commit 3af709f71a

View File

@ -277,12 +277,20 @@ void EGLGLTestContext::setupFenceSync(sk_sp<const GrGLInterface> interface) {
};
glInt->fFunctions.fClientWaitSync =
[grEGLClientWaitSyncKHR, display = fDisplay] (GrGLsync sync, GrGLbitfield flags,
GrGLuint64 timeout) -> GrGLenum {
[grEGLClientWaitSyncKHR, display = fDisplay, surface = fSurface] (
GrGLsync sync,
GrGLbitfield flags,
GrGLuint64 timeout) -> GrGLenum {
EGLSyncKHR eglSync = reinterpret_cast<EGLSyncKHR>(sync);
EGLint egl_flags = 0;
// It seems that, at least on the 2012 N7, later render passes will be reordered before a
// fence. This really messes up benchmark timings where a large fraction of the work for
// sample N can occur before the fence for sample N-1 signals. This causes sample N-1 to be
// artificially slow and N artificially fast. Inserting a swap buffers (to the unused
// display surface) blocks that reordering.
eglSwapBuffers(display, surface);
EGLint egl_flags = 0;
if (flags & GR_GL_SYNC_FLUSH_COMMANDS_BIT) {
egl_flags |= EGL_SYNC_FLUSH_COMMANDS_BIT_KHR;
}