mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 13:50:11 +01:00
egl: extract EGLDevice setup in dedicated function
Extract the logic responsible for populating disp->Device via _eglFindDevice(). This isn't much for now but will grow in a following commit. No functional changes. Signed-off-by: Simon Ser <contact@emersion.fr> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Reviewed-by: Leandro Ribeiro <leandro.ribeiro@collabora.com> Tested-by: Iago Toral Quiroga <itoral@igalia.com> Tested-by: Alejandro Piñeiro <apinheiro@igalia.com> Backport-to: 23.3 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26205>
This commit is contained in:
parent
dddab9fa77
commit
b4ec0b51ce
6 changed files with 31 additions and 42 deletions
|
|
@ -1075,6 +1075,20 @@ dri2_setup_extensions(_EGLDisplay *disp)
|
|||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
EGLBoolean
|
||||
dri2_setup_device(_EGLDisplay *disp, EGLBoolean software)
|
||||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
_EGLDevice *dev;
|
||||
|
||||
dev = _eglFindDevice(dri2_dpy->fd_render_gpu, software);
|
||||
if (!dev)
|
||||
return EGL_FALSE;
|
||||
|
||||
disp->Device = dev;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called via eglInitialize(), drv->Initialize().
|
||||
*
|
||||
|
|
|
|||
|
|
@ -483,6 +483,9 @@ dri2_create_screen(_EGLDisplay *disp);
|
|||
EGLBoolean
|
||||
dri2_setup_extensions(_EGLDisplay *disp);
|
||||
|
||||
EGLBoolean
|
||||
dri2_setup_device(_EGLDisplay *disp, EGLBoolean software);
|
||||
|
||||
__DRIdrawable *
|
||||
dri2_surface_get_dri_drawable(_EGLSurface *surf);
|
||||
|
||||
|
|
|
|||
|
|
@ -1476,7 +1476,6 @@ droid_open_device(_EGLDisplay *disp, bool swrast)
|
|||
EGLBoolean
|
||||
dri2_initialize_android(_EGLDisplay *disp)
|
||||
{
|
||||
_EGLDevice *dev;
|
||||
bool device_opened = false;
|
||||
struct dri2_egl_display *dri2_dpy;
|
||||
const char *err;
|
||||
|
|
@ -1505,14 +1504,11 @@ dri2_initialize_android(_EGLDisplay *disp)
|
|||
|
||||
dri2_dpy->fd_display_gpu = dri2_dpy->fd_render_gpu;
|
||||
|
||||
dev = _eglFindDevice(dri2_dpy->fd_render_gpu, false);
|
||||
if (!dev) {
|
||||
err = "DRI2: failed to find EGLDevice";
|
||||
if (!dri2_setup_device(disp, false)) {
|
||||
err = "DRI2: failed to setup EGLDevice";
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
disp->Device = dev;
|
||||
|
||||
if (!dri2_setup_extensions(disp)) {
|
||||
err = "DRI2: failed to setup extensions";
|
||||
goto cleanup;
|
||||
|
|
|
|||
|
|
@ -579,7 +579,6 @@ get_fd_render_gpu_drm(struct gbm_dri_device *gbm_dri, int fd_display_gpu)
|
|||
EGLBoolean
|
||||
dri2_initialize_drm(_EGLDisplay *disp)
|
||||
{
|
||||
_EGLDevice *dev;
|
||||
struct gbm_device *gbm;
|
||||
const char *err;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create();
|
||||
|
|
@ -640,14 +639,11 @@ dri2_initialize_drm(_EGLDisplay *disp)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
dev = _eglFindDevice(dri2_dpy->fd_render_gpu, dri2_dpy->gbm_dri->software);
|
||||
if (!dev) {
|
||||
err = "DRI2: failed to find EGLDevice";
|
||||
if (!dri2_setup_device(disp, dri2_dpy->gbm_dri->software)) {
|
||||
err = "DRI2: failed to setup EGLDevice";
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
disp->Device = dev;
|
||||
|
||||
dri2_dpy->driver_name = strdup(dri2_dpy->gbm_dri->driver_name);
|
||||
|
||||
if (!dri2_load_driver_dri3(disp)) {
|
||||
|
|
|
|||
|
|
@ -2161,7 +2161,6 @@ dri2_initialize_wayland_drm_extensions(struct dri2_egl_display *dri2_dpy)
|
|||
static EGLBoolean
|
||||
dri2_initialize_wayland_drm(_EGLDisplay *disp)
|
||||
{
|
||||
_EGLDevice *dev;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create();
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
|
|
@ -2205,14 +2204,11 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp)
|
|||
loader_get_user_preferred_fd(&dri2_dpy->fd_render_gpu,
|
||||
&dri2_dpy->fd_display_gpu);
|
||||
|
||||
dev = _eglFindDevice(dri2_dpy->fd_render_gpu, false);
|
||||
if (!dev) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
|
||||
if (!dri2_setup_device(disp, false)) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to setup EGLDevice");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
disp->Device = dev;
|
||||
|
||||
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu) {
|
||||
free(dri2_dpy->device_name);
|
||||
dri2_dpy->device_name =
|
||||
|
|
@ -2730,7 +2726,6 @@ static const __DRIextension *swrast_loader_extensions[] = {
|
|||
static EGLBoolean
|
||||
dri2_initialize_wayland_swrast(_EGLDisplay *disp)
|
||||
{
|
||||
_EGLDevice *dev;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create();
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
|
|
@ -2776,14 +2771,11 @@ dri2_initialize_wayland_swrast(_EGLDisplay *disp)
|
|||
if (disp->Options.Zink)
|
||||
dri2_initialize_wayland_drm_extensions(dri2_dpy);
|
||||
|
||||
dev = _eglFindDevice(dri2_dpy->fd_render_gpu, true);
|
||||
if (!dev) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
|
||||
if (!dri2_setup_device(disp, true)) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to setup EGLDevice");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
disp->Device = dev;
|
||||
|
||||
dri2_dpy->driver_name = strdup(disp->Options.Zink ? "zink" : "swrast");
|
||||
if (!dri2_load_driver_swrast(disp))
|
||||
goto cleanup;
|
||||
|
|
|
|||
|
|
@ -1505,7 +1505,6 @@ dri2_x11_setup_swap_interval(_EGLDisplay *disp)
|
|||
static EGLBoolean
|
||||
dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
||||
{
|
||||
_EGLDevice *dev;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create();
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
|
|
@ -1513,14 +1512,11 @@ dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
|||
if (!dri2_get_xcb_connection(disp, dri2_dpy))
|
||||
goto cleanup;
|
||||
|
||||
dev = _eglFindDevice(dri2_dpy->fd_render_gpu, true);
|
||||
if (!dev) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
|
||||
if (!dri2_setup_device(disp, true)) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to setup EGLDevice");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
disp->Device = dev;
|
||||
|
||||
/*
|
||||
* Every hardware driver_name is set using strdup. Doing the same in
|
||||
* here will allow is to simply free the memory at dri2_terminate().
|
||||
|
|
@ -1595,7 +1591,6 @@ static const __DRIextension *dri3_image_loader_extensions[] = {
|
|||
static EGLBoolean
|
||||
dri2_initialize_x11_dri3(_EGLDisplay *disp)
|
||||
{
|
||||
_EGLDevice *dev;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create();
|
||||
|
||||
if (!dri2_dpy)
|
||||
|
|
@ -1607,14 +1602,11 @@ dri2_initialize_x11_dri3(_EGLDisplay *disp)
|
|||
if (!dri3_x11_connect(dri2_dpy))
|
||||
goto cleanup;
|
||||
|
||||
dev = _eglFindDevice(dri2_dpy->fd_render_gpu, false);
|
||||
if (!dev) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
|
||||
if (!dri2_setup_device(disp, false)) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to setup EGLDevice");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
disp->Device = dev;
|
||||
|
||||
if (!dri2_load_driver_dri3(disp))
|
||||
goto cleanup;
|
||||
|
||||
|
|
@ -1705,7 +1697,6 @@ static const __DRIextension *dri2_loader_extensions[] = {
|
|||
static EGLBoolean
|
||||
dri2_initialize_x11_dri2(_EGLDisplay *disp)
|
||||
{
|
||||
_EGLDevice *dev;
|
||||
struct dri2_egl_display *dri2_dpy = dri2_display_create();
|
||||
if (!dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
|
|
@ -1716,14 +1707,11 @@ dri2_initialize_x11_dri2(_EGLDisplay *disp)
|
|||
if (!dri2_x11_connect(dri2_dpy))
|
||||
goto cleanup;
|
||||
|
||||
dev = _eglFindDevice(dri2_dpy->fd_render_gpu, false);
|
||||
if (!dev) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
|
||||
if (!dri2_setup_device(disp, false)) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to setup EGLDevice");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
disp->Device = dev;
|
||||
|
||||
if (!dri2_load_driver(disp))
|
||||
goto cleanup;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue