[client] egl: attempt DMABUF import and fallback if it fails

This should deal with drivers not supporting our DMABUF without attempting
to identify the drivers and blacklist them.
This commit is contained in:
Quantum 2021-08-07 19:49:55 -04:00 committed by Geoffrey McRae
parent 037b76750a
commit b822e255d8
2 changed files with 22 additions and 21 deletions

View File

@ -72,6 +72,9 @@ struct EGL_Desktop
// colorblind mode
int cbMode;
bool useDMA;
LG_RendererFormat format;
};
// forwards
@ -146,6 +149,7 @@ bool egl_desktop_init(EGL_Desktop ** desktop, EGLDisplay * display, bool useDMA,
(*desktop)->nvGain = option_get_int("egl", "nvGain" );
(*desktop)->cbMode = option_get_int("egl", "cbMode" );
(*desktop)->scaleAlgo = option_get_int("egl", "scale" );
(*desktop)->useDMA = useDMA;
return true;
}
@ -226,6 +230,8 @@ void egl_desktop_config_ui(EGL_Desktop * desktop)
bool egl_desktop_setup(EGL_Desktop * desktop, const LG_RendererFormat format)
{
memcpy(&desktop->format, &format, sizeof(LG_RendererFormat));
enum EGL_PixelFormat pixFmt;
switch(format.type)
{
@ -275,18 +281,26 @@ bool egl_desktop_setup(EGL_Desktop * desktop, const LG_RendererFormat format)
bool egl_desktop_update(EGL_Desktop * desktop, const FrameBuffer * frame, int dmaFd,
const FrameDamageRect * damageRects, int damageRectsCount)
{
if (dmaFd >= 0)
if (desktop->useDMA && dmaFd >= 0)
{
if (!egl_texture_update_from_dma(desktop->texture, frame, dmaFd))
return false;
}
else
if (egl_texture_update_from_dma(desktop->texture, frame, dmaFd))
return true;
DEBUG_WARN("DMA update failed, disabling DMABUF imports");
desktop->useDMA = false;
egl_texture_free(&desktop->texture);
if (!egl_texture_init(&desktop->texture, desktop->display, EGL_TEXTYPE_FRAMEBUFFER, true))
{
if (!egl_texture_update_from_frame(desktop->texture, frame, damageRects, damageRectsCount))
DEBUG_ERROR("Failed to initialize the desktop texture");
return false;
}
return true;
if (!egl_desktop_setup(desktop, desktop->format))
return false;
}
return egl_texture_update_from_frame(desktop->texture, frame, damageRects, damageRectsCount);
}
bool egl_desktop_render(EGL_Desktop * desktop, const float x, const float y,

View File

@ -749,20 +749,7 @@ static bool egl_render_startup(void * opaque, bool useDMA)
if (g_egl_dynProcs.glEGLImageTargetTexture2DOES)
{
if (util_hasGLExt(client_exts, "EGL_EXT_image_dma_buf_import"))
{
/*
* As of version 455.45.01 NVidia started advertising support for this
* feature, however even on the latest version 460.27.04 this is still
* broken and does not work, until this is fixed and we have way to detect
* this early just disable dma for all NVIDIA devices.
*
* ref: https://forums.developer.nvidia.com/t/egl-ext-image-dma-buf-import-broken-egl-bad-alloc-with-tons-of-free-ram/165552
*/
if (strstr(vendor, "NVIDIA") != NULL)
DEBUG_WARN("NVIDIA driver detected, ignoring broken DMA support");
else
this->dmaSupport = true;
}
else
DEBUG_INFO("EGL_EXT_image_dma_buf_import unavailable, DMA support disabled");
}