summaryrefslogtreecommitdiff
path: root/src/egl/drivers/dri2/platform_android.c
diff options
context:
space:
mode:
authorYiwei Zhang <zzyiwei@chromium.org>2021-06-06 06:31:58 +0000
committerMarge Bot <eric+marge@anholt.net>2021-06-09 21:07:53 +0000
commit1ea949429ceeb6061e7aab1cada1d7dfc20f7d8b (patch)
treec2af00d3f5f64c2f5f29d888ebc3343622048533 /src/egl/drivers/dri2/platform_android.c
parenta4dc2021b89d7f70a5486aea9c3b59d7a05cc458 (diff)
egl/android: fix cached buffer slots for EGL Android winsys
Android WSI api contract requires to allocate min_undequeued_buffers + 2 to achieve "triple buffering" effect, which is when the composer backend acquired the allowed max numbder of buffers, the producer still has 2 buffers to rotate. ANativeWindow either belongs to SurfaceView which presents directly to SurfaceFlinger or belongs to other surfaces from the UI framework. For the former, SurfaceFlinger hardcodes triple buffering for EGL. For the latter, the surface caps decide the buffer limits or HWUI intercepts and adjusts the min_undequeued_buffers to hint the EGL implementation to prepare enough buffer cache slots while HWUI sets the max dequeued buffer count accordingly. Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11206>
Diffstat (limited to 'src/egl/drivers/dri2/platform_android.c')
-rw-r--r--src/egl/drivers/dri2/platform_android.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 585c4432a37..480b69bf2a5 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -573,7 +573,7 @@ droid_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
if (type == EGL_WINDOW_BIT) {
int format;
int buffer_count;
- int min_buffer_count, max_buffer_count;
+ int min_undequeued_buffers;
/* Prefer triple buffering for performance reasons. */
const int preferred_buffer_count = 3;
@@ -591,30 +591,14 @@ droid_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
* of undequeued buffers.
*/
if (window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
- &min_buffer_count)) {
+ &min_undequeued_buffers)) {
_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;
- }
+ /* Required buffer caching slots. */
+ buffer_count = min_undequeued_buffers + 2;
- /* 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;
- }
dri2_surf->color_buffers = calloc(buffer_count,
sizeof(*dri2_surf->color_buffers));
if (!dri2_surf->color_buffers) {