Fix eglPresentationTimeANDROID is no effective (flutter/engine#30182)
* Fix eglPresentationTimeANDROID is no effective * Update android_environment_gl.cc Co-authored-by: Dan Field <dfield@gmail.com>
This commit is contained in:
@@ -20,11 +20,24 @@ AndroidEnvironmentGL::AndroidEnvironmentGL()
|
||||
return;
|
||||
}
|
||||
|
||||
// See if we can use the EGL_ANDROID_presentation_time extension. This
|
||||
// extension may be available from API18 onward.
|
||||
// If this extension is available, it will be invoked with the target vsync
|
||||
// for the current frame before calling eglSwapBuffers. This helps when the
|
||||
// engine over-stuffs the buffer queue. This can happen when a frame goes over
|
||||
// budget into the next vsync period, and a subsequent frame is quickly
|
||||
// submitted in the same vsync period. Dequeuing buffers will then be slow
|
||||
// until the engine stops submitting frames and lets the GPU catch up.
|
||||
// However, using this extension means the SurfaceFlinger will only use the
|
||||
// newest buffer for the current vsync, and the GPU and CPU will stay more
|
||||
// in sync.
|
||||
// See https://developer.android.com/games/sdk/frame-pacing for more
|
||||
// details and diagrams.
|
||||
auto* extensions = eglQueryString(display_, EGL_EXTENSIONS);
|
||||
if (strstr(extensions, "EGL_ANDROID_presentation_time")) {
|
||||
presentation_time_proc_ =
|
||||
reinterpret_cast<PFNEGLPRESENTATIONTIMEANDROIDPROC>(
|
||||
eglGetProcAddress("sEGL_ANDROID_presentation_time"));
|
||||
eglGetProcAddress("eglPresentationTimeANDROID"));
|
||||
}
|
||||
|
||||
valid_ = true;
|
||||
|
||||
Reference in New Issue
Block a user