mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-15 10:40:39 +01:00
egl/android: only apply front rendering usage in shared buffer mode
When EGL_KHR_mutable_render_buffer extension is enabled, advertised configs unconditionally include EGL_MUTABLE_RENDER_BUFFER_BIT_KHR bit. However,f61337b5starts requesting front rendering usage bit when EGL_MUTABLE_RENDER_BUFFER_BIT_KHR is seen on the SurfaceType, which essentially forces linear usage on all winsys BOs for gallium dri and i965 drivers on Android when cros gralloc is in use. This patch dynamically appends or strips the front rendering usage bit depends on whether EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER or EGL_BACK_BUFFER. The next dequeuBuffer call will switch the buffer sharing mode while re-allocating winsys BOs given the updated gralloc usage bits if necessary. v2: handle ANativeWindow_setUsage on error Fixes:f61337b5("egl/android: check front rendering support for cros gralloc") Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Rob Clark <robdclark@chromium.org> (v1) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11787>
This commit is contained in:
parent
d0fa4933b7
commit
d677120cae
2 changed files with 22 additions and 4 deletions
|
|
@ -346,6 +346,7 @@ struct dri2_egl_surface
|
|||
struct ANativeWindowBuffer *buffer;
|
||||
int age;
|
||||
} *color_buffers, *back;
|
||||
uint32_t gralloc_usage;
|
||||
#endif
|
||||
|
||||
/* surfaceless and device */
|
||||
|
|
|
|||
|
|
@ -549,6 +549,7 @@ static bool
|
|||
droid_set_shared_buffer_mode(_EGLDisplay *disp, _EGLSurface *surf, bool mode)
|
||||
{
|
||||
#if ANDROID_API_LEVEL >= 24
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
|
||||
struct ANativeWindow *window = dri2_surf->window;
|
||||
|
||||
|
|
@ -563,6 +564,18 @@ droid_set_shared_buffer_mode(_EGLDisplay *disp, _EGLSurface *surf, bool mode)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mode)
|
||||
dri2_surf->gralloc_usage |= dri2_dpy->front_rendering_usage;
|
||||
else
|
||||
dri2_surf->gralloc_usage &= ~dri2_dpy->front_rendering_usage;
|
||||
|
||||
if (ANativeWindow_setUsage(window, dri2_surf->gralloc_usage)) {
|
||||
_eglLog(_EGL_WARNING,
|
||||
"failed ANativeWindow_setUsage(window=%p, usage=%u)", window,
|
||||
dri2_surf->gralloc_usage);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
_eglLog(_EGL_FATAL, "%s:%d: internal error: unreachable", __FILE__, __LINE__);
|
||||
|
|
@ -632,14 +645,18 @@ droid_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
|
|||
ANativeWindow_query(window, ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT,
|
||||
&dri2_surf->base.Height);
|
||||
|
||||
uint32_t usage = strcmp(dri2_dpy->driver_name, "kms_swrast") == 0
|
||||
dri2_surf->gralloc_usage =
|
||||
strcmp(dri2_dpy->driver_name, "kms_swrast") == 0
|
||||
? GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN
|
||||
: GRALLOC_USAGE_HW_RENDER;
|
||||
|
||||
if (conf->SurfaceType & EGL_MUTABLE_RENDER_BUFFER_BIT_KHR)
|
||||
usage |= dri2_dpy->front_rendering_usage;
|
||||
if (dri2_surf->base.ActiveRenderBuffer == EGL_SINGLE_BUFFER)
|
||||
dri2_surf->gralloc_usage |= dri2_dpy->front_rendering_usage;
|
||||
|
||||
ANativeWindow_setUsage(window, usage);
|
||||
if (ANativeWindow_setUsage(window, dri2_surf->gralloc_usage)) {
|
||||
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
|
||||
goto cleanup_surface;
|
||||
}
|
||||
}
|
||||
|
||||
config = dri2_get_dri_config(dri2_conf, type,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue