mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
egl: hoist dri2 display creation up a level
this is always created for dri2 devices, and it can now be consolidated in one place instead of duplicated all over Acked-by: Daniel Stone <daniels@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33891>
This commit is contained in:
parent
c4c07136e6
commit
5466ff3a43
7 changed files with 21 additions and 39 deletions
|
|
@ -874,6 +874,9 @@ dri2_initialize(_EGLDisplay *disp)
|
|||
p_atomic_inc(&dri2_dpy->ref_count);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
dri2_dpy = dri2_display_create(disp);
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
|
||||
loader_set_logger(_eglLog);
|
||||
|
||||
|
|
@ -902,8 +905,10 @@ dri2_initialize(_EGLDisplay *disp)
|
|||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
dri2_display_destroy(disp);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if (_eglGetArraySize(disp->Configs) == 0) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "failed to add any EGLConfigs");
|
||||
|
|
|
|||
|
|
@ -1181,13 +1181,9 @@ EGLBoolean
|
|||
dri2_initialize_android(_EGLDisplay *disp)
|
||||
{
|
||||
bool device_opened = false;
|
||||
struct dri2_egl_display *dri2_dpy;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
const char *err;
|
||||
|
||||
dri2_dpy = dri2_display_create(disp);
|
||||
if (!dri2_dpy)
|
||||
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
|
||||
|
||||
dri2_dpy->gralloc = u_gralloc_create(U_GRALLOC_TYPE_AUTO);
|
||||
if (dri2_dpy->gralloc == NULL) {
|
||||
err = "DRI2: failed to get gralloc";
|
||||
|
|
@ -1309,6 +1305,5 @@ dri2_initialize_android(_EGLDisplay *disp)
|
|||
return EGL_TRUE;
|
||||
|
||||
cleanup:
|
||||
dri2_display_destroy(disp);
|
||||
return _eglError(EGL_NOT_INITIALIZED, err);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -336,9 +336,7 @@ EGLBoolean
|
|||
dri2_initialize_device(_EGLDisplay *disp)
|
||||
{
|
||||
const char *err;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create(disp);
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
|
||||
/* Extension requires a PlatformDisplay - the EGLDevice. */
|
||||
disp->Device = disp->PlatformDisplay;
|
||||
|
|
@ -378,6 +376,5 @@ dri2_initialize_device(_EGLDisplay *disp)
|
|||
return EGL_TRUE;
|
||||
|
||||
cleanup:
|
||||
dri2_display_destroy(disp);
|
||||
return _eglError(EGL_NOT_INITIALIZED, err);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -560,9 +560,7 @@ dri2_initialize_drm(_EGLDisplay *disp)
|
|||
{
|
||||
struct gbm_device *gbm;
|
||||
const char *err;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create(disp);
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
|
||||
gbm = disp->PlatformDisplay;
|
||||
if (gbm == NULL) {
|
||||
|
|
@ -681,7 +679,6 @@ dri2_initialize_drm(_EGLDisplay *disp)
|
|||
return EGL_TRUE;
|
||||
|
||||
cleanup:
|
||||
dri2_display_destroy(disp);
|
||||
return _eglError(EGL_NOT_INITIALIZED, err);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -361,9 +361,7 @@ dri2_initialize_surfaceless(_EGLDisplay *disp)
|
|||
{
|
||||
const char *err;
|
||||
bool driver_loaded = false;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create(disp);
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
|
||||
/* When ForceSoftware is false, we try the HW driver. When ForceSoftware
|
||||
* is true, we try kms_swrast and swrast in order.
|
||||
|
|
@ -397,6 +395,5 @@ dri2_initialize_surfaceless(_EGLDisplay *disp)
|
|||
return EGL_TRUE;
|
||||
|
||||
cleanup:
|
||||
dri2_display_destroy(disp);
|
||||
return _eglError(EGL_NOT_INITIALIZED, err);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2242,9 +2242,7 @@ dri2_initialize_wayland_drm_extensions(struct dri2_egl_display *dri2_dpy)
|
|||
static EGLBoolean
|
||||
dri2_initialize_wayland_drm(_EGLDisplay *disp)
|
||||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create(disp);
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
|
||||
if (dri2_wl_formats_init(&dri2_dpy->formats) < 0)
|
||||
goto cleanup;
|
||||
|
|
@ -2362,7 +2360,6 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp)
|
|||
return EGL_TRUE;
|
||||
|
||||
cleanup:
|
||||
dri2_display_destroy(disp);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -2991,9 +2988,7 @@ static const __DRIextension *kopper_swrast_loader_extensions[] = {
|
|||
static EGLBoolean
|
||||
dri2_initialize_wayland_swrast(_EGLDisplay *disp)
|
||||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create(disp);
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
|
||||
if (dri2_wl_formats_init(&dri2_dpy->formats) < 0)
|
||||
goto cleanup;
|
||||
|
|
@ -3099,7 +3094,6 @@ dri2_initialize_wayland_swrast(_EGLDisplay *disp)
|
|||
return EGL_TRUE;
|
||||
|
||||
cleanup:
|
||||
dri2_display_destroy(disp);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1764,9 +1764,7 @@ dri2_x11_check_multibuffers(_EGLDisplay *disp)
|
|||
static EGLBoolean
|
||||
dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
||||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create(disp);
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
|
||||
if (!dri2_get_xcb_connection(disp, dri2_dpy))
|
||||
goto cleanup;
|
||||
|
|
@ -1842,7 +1840,6 @@ dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
|||
return EGL_TRUE;
|
||||
|
||||
cleanup:
|
||||
dri2_display_destroy(disp);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1857,10 +1854,8 @@ static const __DRIextension *dri3_image_loader_extensions[] = {
|
|||
static enum dri2_egl_driver_fail
|
||||
dri2_initialize_x11_dri3(_EGLDisplay *disp)
|
||||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create(disp);
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
enum dri2_egl_driver_fail status = DRI2_EGL_DRIVER_FAILED;
|
||||
if (!dri2_dpy)
|
||||
return DRI2_EGL_DRIVER_FAILED;
|
||||
|
||||
if (!dri2_get_xcb_connection(disp, dri2_dpy))
|
||||
goto cleanup;
|
||||
|
|
@ -1916,7 +1911,6 @@ dri2_initialize_x11_dri3(_EGLDisplay *disp)
|
|||
return DRI2_EGL_DRIVER_LOADED;
|
||||
|
||||
cleanup:
|
||||
dri2_display_destroy(disp);
|
||||
return status == DRI2_EGL_DRIVER_PREFER_ZINK ?
|
||||
DRI2_EGL_DRIVER_PREFER_ZINK :
|
||||
DRI2_EGL_DRIVER_FAILED;
|
||||
|
|
@ -1957,9 +1951,7 @@ static const __DRIextension *dri2_loader_extensions[] = {
|
|||
static EGLBoolean
|
||||
dri2_initialize_x11_dri2(_EGLDisplay *disp)
|
||||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create(disp);
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
|
||||
if (!dri2_get_xcb_connection(disp, dri2_dpy))
|
||||
goto cleanup;
|
||||
|
|
@ -2011,7 +2003,6 @@ dri2_initialize_x11_dri2(_EGLDisplay *disp)
|
|||
return EGL_TRUE;
|
||||
|
||||
cleanup:
|
||||
dri2_display_destroy(disp);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2035,6 +2026,12 @@ dri2_initialize_x11(_EGLDisplay *disp)
|
|||
#ifdef HAVE_X11_DRI2
|
||||
if (!debug_get_bool_option("LIBGL_DRI2_DISABLE", false) &&
|
||||
status != DRI2_EGL_DRIVER_PREFER_ZINK)
|
||||
/* this is a fallthrough using the same dri2_dpy from dri3,
|
||||
* so the existing one must be destroyed and a new one created
|
||||
* the caller will switch to the new display automatically
|
||||
*/
|
||||
dri2_display_destroy(disp);
|
||||
dri2_display_create(disp);
|
||||
if (dri2_initialize_x11_dri2(disp))
|
||||
return EGL_TRUE;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue