Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit 2b4c4f9

Browse files
committed
Revert "egl/android: Update color_buffers querying for buffer age"
This reverts commit 87efbe4. We got one PnP regression with 87efbe4. When we run Gfxbenchmark, there will be 50% drop(from ~60 to ~30) for case Manhattan. Let's revert this for a hot fix, which won't block the code integration. We will continue to debug this issue with upstream mesa. Signed-off-by: Chenglei Ren <[email protected]> Tracked-On: OAM-OAM-88862
1 parent 74ae967 commit 2b4c4f9

File tree

2 files changed

+6
-31
lines changed

2 files changed

+6
-31
lines changed

src/egl/drivers/dri2/egl_dri2.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,13 @@ struct dri2_egl_surface
333333
__DRIimage *dri_image_front;
334334

335335
/* Used to record all the buffers created by ANativeWindow and their ages.
336-
* Allocate number of color_buffers based on query to android bufferqueue
337-
* and save color_buffers_count.
336+
* Usually Android uses at most triple buffers in ANativeWindow
337+
* so hardcode the number of color_buffers to 3.
338338
*/
339-
int color_buffers_count;
340339
struct {
341340
struct ANativeWindowBuffer *buffer;
342341
int age;
343-
} *color_buffers, *back;
342+
} color_buffers[3], *back;
344343
#endif
345344

346345
#if defined(HAVE_SURFACELESS_PLATFORM)

src/egl/drivers/dri2/platform_android.c

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
249249
* for updating buffer's age in swap_buffers.
250250
*/
251251
EGLBoolean updated = EGL_FALSE;
252-
for (int i = 0; i < dri2_surf->color_buffers_count; i++) {
252+
for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
253253
if (!dri2_surf->color_buffers[i].buffer) {
254254
dri2_surf->color_buffers[i].buffer = dri2_surf->buffer;
255255
}
@@ -264,7 +264,7 @@ droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
264264
/* In case of all the buffers were recreated by ANativeWindow, reset
265265
* the color_buffers
266266
*/
267-
for (int i = 0; i < dri2_surf->color_buffers_count; i++) {
267+
for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
268268
dri2_surf->color_buffers[i].buffer = NULL;
269269
dri2_surf->color_buffers[i].age = 0;
270270
}
@@ -419,7 +419,6 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
419419

420420
if (type == EGL_WINDOW_BIT) {
421421
int format;
422-
int buffer_count;
423422

424423
if (window->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
425424
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
@@ -430,26 +429,6 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
430429
goto cleanup_surface;
431430
}
432431

433-
/* Query ANativeWindow for MIN_UNDEQUEUED_BUFFER, set buffer count
434-
* and allocate color_buffers.
435-
*/
436-
if (window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
437-
&buffer_count)) {
438-
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
439-
goto cleanup_surface;
440-
}
441-
if (native_window_set_buffer_count(window, buffer_count+1)) {
442-
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
443-
goto cleanup_surface;
444-
}
445-
dri2_surf->color_buffers = calloc(buffer_count+1,
446-
sizeof(*dri2_surf->color_buffers));
447-
if (!dri2_surf->color_buffers) {
448-
_eglError(EGL_BAD_ALLOC, "droid_create_surface");
449-
goto cleanup_surface;
450-
}
451-
dri2_surf->color_buffers_count = buffer_count+1;
452-
453432
if (format != dri2_conf->base.NativeVisualID) {
454433
_eglLog(_EGL_WARNING, "Native format mismatch: 0x%x != 0x%x",
455434
format, dri2_conf->base.NativeVisualID);
@@ -477,8 +456,6 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
477456
return &dri2_surf->base;
478457

479458
cleanup_surface:
480-
if (dri2_surf->color_buffers_count)
481-
free(dri2_surf->color_buffers);
482459
free(dri2_surf);
483460

484461
return NULL;
@@ -531,7 +508,6 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
531508
dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable);
532509

533510
dri2_fini_surface(surf);
534-
free(dri2_surf->color_buffers);
535511
free(dri2_surf);
536512

537513
return EGL_TRUE;
@@ -780,7 +756,7 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
780756
return EGL_TRUE;
781757
}
782758

783-
for (int i = 0; i < dri2_surf->color_buffers_count; i++) {
759+
for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
784760
if (dri2_surf->color_buffers[i].age > 0)
785761
dri2_surf->color_buffers[i].age++;
786762
}

0 commit comments

Comments
 (0)