Module: Mesa Branch: staging/19.3 Commit: fbb906ee8c45e310cc7a91bf5deaeb0ae1b5f498 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fbb906ee8c45e310cc7a91bf5deaeb0ae1b5f498
Author: Tapani Pälli <[email protected]> Date: Tue Jan 21 13:01:51 2020 +0200 egl/android: fix buffer_count for applications setting max count Problem with previous solution was that it did not take account that some applications may set a max count for buffers. Therefore we need to query both min and max and clamp our setting based on that. Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2373 Fixes: be08e6a4496 ("egl/android: Restrict minimum triple buffering for android color_buffers") Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3480> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3480> (cherry picked from commit 39e7492d33c89ee7049d5bc07267d131cc6a1ff9) --- .pick_status.json | 2 +- src/egl/drivers/dri2/platform_android.c | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index b68173bb782..ca319e16abf 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -166,7 +166,7 @@ "description": "egl/android: fix buffer_count for applications setting max count", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "be08e6a4496aad219df1fd829fca3e4f7b322538" }, diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index d1b50a3fa72..da90c44d601 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -375,7 +375,10 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, if (type == EGL_WINDOW_BIT) { int format; int buffer_count; - const int min_buffers = 3; + int min_buffer_count, max_buffer_count; + + /* Prefer triple buffering for performance reasons. */ + const int preferred_buffer_count = 3; if (window->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) { _eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface"); @@ -386,17 +389,30 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, goto cleanup_surface; } - /* Query ANativeWindow for MIN_UNDEQUEUED_BUFFER, set buffer count - * and allocate color_buffers. + /* Query ANativeWindow for MIN_UNDEQUEUED_BUFFER, minimum amount + * of undequeued buffers. */ if (window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, - &buffer_count)) { + &min_buffer_count)) { + _eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface"); + goto cleanup_surface; + } + + /* Query for maximum buffer count, application can set this + * to limit the total amount of buffers. + */ + if (window->query(window, NATIVE_WINDOW_MAX_BUFFER_COUNT, + &max_buffer_count)) { _eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface"); goto cleanup_surface; } - if (buffer_count < min_buffers) - buffer_count = min_buffers; + /* Clamp preferred between minimum (min undequeued + 1 dequeued) + * and maximum. + */ + buffer_count = CLAMP(preferred_buffer_count, min_buffer_count + 1, + max_buffer_count); + if (native_window_set_buffer_count(window, buffer_count)) { _eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface"); goto cleanup_surface; _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
