mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 04:40:09 +01:00
egl/x11: unify swrast/kopper/dri3 paths a bit
most of this was duplicated, but there were a couple hard conditionals that made it less obvious Acked-by: Daniel Stone <daniels@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33891>
This commit is contained in:
parent
0bb1c5e24b
commit
c00701c83a
1 changed files with 52 additions and 75 deletions
|
|
@ -1761,14 +1761,56 @@ dri2_x11_check_multibuffers(_EGLDisplay *disp)
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
platform_x11_finalize(_EGLDisplay *disp)
|
||||||
|
{
|
||||||
|
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||||
|
|
||||||
|
if (!dri2_x11_check_multibuffers(disp))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!dri2_create_screen(disp))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!dri2_setup_device(disp, disp->Options.ForceSoftware || dri2_dpy->kopper_without_modifiers)) {
|
||||||
|
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to setup EGLDevice");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dri2_setup_screen(disp);
|
||||||
|
|
||||||
|
if (!dri2_dpy->swrast) {
|
||||||
|
dri2_x11_setup_swap_interval(disp);
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND_PLATFORM
|
||||||
|
if (dri2_dpy->kopper)
|
||||||
|
dri2_dpy->device_name = strdup("zink");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dri2_dpy->swap_available = true;
|
||||||
|
if (dri2_dpy->fd_render_gpu == dri2_dpy->fd_display_gpu)
|
||||||
|
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
|
||||||
|
disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE;
|
||||||
|
disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
|
||||||
|
#ifdef HAVE_LIBDRM
|
||||||
|
if (dri2_dpy->multibuffers_available)
|
||||||
|
dri2_set_WL_bind_wayland_display(disp);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
disp->Extensions.ANGLE_sync_control_rate = EGL_TRUE;
|
||||||
|
disp->Extensions.EXT_buffer_age = EGL_TRUE;
|
||||||
|
disp->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE;
|
||||||
|
|
||||||
|
dri2_x11_add_configs_for_visuals(dri2_dpy, disp, !dri2_dpy->kopper);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static EGLBoolean
|
static EGLBoolean
|
||||||
dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
||||||
{
|
{
|
||||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||||
|
|
||||||
if (!dri2_load_driver(disp))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (disp->Options.Zink && !disp->Options.ForceSoftware) {
|
if (disp->Options.Zink && !disp->Options.ForceSoftware) {
|
||||||
dri2_dpy->loader_extensions = kopper_loader_extensions;
|
dri2_dpy->loader_extensions = kopper_loader_extensions;
|
||||||
} else if (check_xshm(dri2_dpy)) {
|
} else if (check_xshm(dri2_dpy)) {
|
||||||
|
|
@ -1777,41 +1819,8 @@ dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
||||||
dri2_dpy->loader_extensions = swrast_loader_extensions;
|
dri2_dpy->loader_extensions = swrast_loader_extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dri2_x11_check_multibuffers(disp))
|
if (!platform_x11_finalize(disp))
|
||||||
goto cleanup;
|
return EGL_FALSE;
|
||||||
|
|
||||||
if (!dri2_create_screen(disp))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!dri2_setup_device(disp, disp->Options.ForceSoftware || dri2_dpy->kopper_without_modifiers)) {
|
|
||||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to setup EGLDevice");
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
dri2_setup_screen(disp);
|
|
||||||
|
|
||||||
if (disp->Options.Zink) {
|
|
||||||
/* kopper */
|
|
||||||
#ifdef HAVE_WAYLAND_PLATFORM
|
|
||||||
dri2_dpy->device_name = strdup("zink");
|
|
||||||
#endif
|
|
||||||
dri2_dpy->swap_available = EGL_TRUE;
|
|
||||||
dri2_x11_setup_swap_interval(disp);
|
|
||||||
if (dri2_dpy->fd_render_gpu == dri2_dpy->fd_display_gpu)
|
|
||||||
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
|
|
||||||
disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE;
|
|
||||||
disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
|
||||||
if (dri2_dpy->multibuffers_available)
|
|
||||||
dri2_set_WL_bind_wayland_display(disp);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
disp->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE;
|
|
||||||
disp->Extensions.EXT_buffer_age = EGL_TRUE;
|
|
||||||
disp->Extensions.ANGLE_sync_control_rate = EGL_TRUE;
|
|
||||||
|
|
||||||
dri2_x11_add_configs_for_visuals(dri2_dpy, disp, !disp->Options.Zink);
|
|
||||||
|
|
||||||
/* Fill vtbl last to prevent accidentally calling virtual function during
|
/* Fill vtbl last to prevent accidentally calling virtual function during
|
||||||
* initialization.
|
* initialization.
|
||||||
|
|
@ -1822,9 +1831,6 @@ dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
||||||
dri2_dpy->vtbl = &dri2_x11_swrast_display_vtbl;
|
dri2_dpy->vtbl = &dri2_x11_swrast_display_vtbl;
|
||||||
|
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return EGL_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LIBDRM
|
||||||
|
|
@ -1840,39 +1846,10 @@ dri2_initialize_x11_dri3(_EGLDisplay *disp)
|
||||||
{
|
{
|
||||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||||
|
|
||||||
if (!dri2_load_driver(disp))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
dri2_dpy->loader_extensions = dri3_image_loader_extensions;
|
dri2_dpy->loader_extensions = dri3_image_loader_extensions;
|
||||||
|
|
||||||
dri2_dpy->swap_available = true;
|
if (!platform_x11_finalize(disp))
|
||||||
|
return EGL_FALSE;
|
||||||
if (!dri2_x11_check_multibuffers(disp))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!dri2_create_screen(disp))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!dri2_setup_device(disp, false)) {
|
|
||||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to setup EGLDevice");
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
dri2_setup_screen(disp);
|
|
||||||
|
|
||||||
dri2_x11_setup_swap_interval(disp);
|
|
||||||
|
|
||||||
if (dri2_dpy->fd_render_gpu == dri2_dpy->fd_display_gpu)
|
|
||||||
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
|
|
||||||
disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE;
|
|
||||||
disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
|
|
||||||
disp->Extensions.ANGLE_sync_control_rate = EGL_TRUE;
|
|
||||||
disp->Extensions.EXT_buffer_age = EGL_TRUE;
|
|
||||||
disp->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE;
|
|
||||||
|
|
||||||
dri2_set_WL_bind_wayland_display(disp);
|
|
||||||
|
|
||||||
dri2_x11_add_configs_for_visuals(dri2_dpy, disp, false);
|
|
||||||
|
|
||||||
loader_init_screen_resources(&dri2_dpy->screen_resources, dri2_dpy->conn,
|
loader_init_screen_resources(&dri2_dpy->screen_resources, dri2_dpy->conn,
|
||||||
dri2_dpy->screen);
|
dri2_dpy->screen);
|
||||||
|
|
@ -1885,9 +1862,6 @@ dri2_initialize_x11_dri3(_EGLDisplay *disp)
|
||||||
_eglLog(_EGL_INFO, "Using DRI3");
|
_eglLog(_EGL_INFO, "Using DRI3");
|
||||||
|
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return EGL_FALSE;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -2020,6 +1994,9 @@ dri2_initialize_x11(_EGLDisplay *disp, bool *allow_dri2)
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (!dri2_load_driver(disp))
|
||||||
|
return EGL_FALSE;
|
||||||
|
|
||||||
if (disp->Options.ForceSoftware || dri2_dpy->kopper)
|
if (disp->Options.ForceSoftware || dri2_dpy->kopper)
|
||||||
return dri2_initialize_x11_swrast(disp);
|
return dri2_initialize_x11_swrast(disp);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue