egl: unify dri2_egl_display creation

this is the same for all platforms

no functional changes

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25640>
This commit is contained in:
Mike Blumenkrantz
2023-10-10 07:47:23 -04:00
committed by Marge Bot
parent 05206f314c
commit 1d149575ea
7 changed files with 33 additions and 47 deletions

View File

@@ -1220,6 +1220,20 @@ dri2_display_destroy(_EGLDisplay *disp)
disp->DriverData = NULL;
}
struct dri2_egl_display *
dri2_display_create(void)
{
struct dri2_egl_display *dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_dpy) {
_eglError(EGL_BAD_ALLOC, "eglInitialize");
return NULL;
}
dri2_dpy->fd_render_gpu = -1;
dri2_dpy->fd_display_gpu = -1;
return dri2_dpy;
}
__DRIbuffer *
dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf,
unsigned int att, unsigned int format)

View File

@@ -644,6 +644,9 @@ dri2_set_WL_bind_wayland_display(_EGLDisplay *disp)
void
dri2_display_destroy(_EGLDisplay *disp);
struct dri2_egl_display *
dri2_display_create(void);
__DRIbuffer *
dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf,
unsigned int att, unsigned int format);

View File

@@ -341,18 +341,14 @@ EGLBoolean
dri2_initialize_device(_EGLDisplay *disp)
{
_EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
const char *err;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
struct dri2_egl_display *dri2_dpy = dri2_display_create();
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
return EGL_FALSE;
/* Extension requires a PlatformDisplay - the EGLDevice. */
dev = disp->PlatformDisplay;
dri2_dpy->fd_render_gpu = -1;
dri2_dpy->fd_display_gpu = -1;
disp->Device = dev;
disp->DriverData = (void *)dri2_dpy;
err = "DRI2: failed to load driver";

View File

@@ -580,16 +580,12 @@ EGLBoolean
dri2_initialize_drm(_EGLDisplay *disp)
{
_EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
struct gbm_device *gbm;
const char *err;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
struct dri2_egl_display *dri2_dpy = dri2_display_create();
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
return EGL_FALSE;
dri2_dpy->fd_render_gpu = -1;
dri2_dpy->fd_display_gpu = -1;
disp->DriverData = (void *)dri2_dpy;
gbm = disp->PlatformDisplay;

View File

@@ -308,16 +308,12 @@ surfaceless_probe_device_sw(_EGLDisplay *disp)
EGLBoolean
dri2_initialize_surfaceless(_EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy;
const char *err;
bool driver_loaded = false;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
struct dri2_egl_display *dri2_dpy = dri2_display_create();
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
return EGL_FALSE;
dri2_dpy->fd_render_gpu = -1;
dri2_dpy->fd_display_gpu = -1;
disp->DriverData = (void *)dri2_dpy;
/* When ForceSoftware is false, we try the HW driver. When ForceSoftware

View File

@@ -2162,14 +2162,10 @@ static EGLBoolean
dri2_initialize_wayland_drm(_EGLDisplay *disp)
{
_EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
struct dri2_egl_display *dri2_dpy = dri2_display_create();
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
return EGL_FALSE;
dri2_dpy->fd_render_gpu = -1;
dri2_dpy->fd_display_gpu = -1;
disp->DriverData = (void *)dri2_dpy;
if (dri2_wl_formats_init(&dri2_dpy->formats) < 0)
@@ -2731,14 +2727,10 @@ static EGLBoolean
dri2_initialize_wayland_swrast(_EGLDisplay *disp)
{
_EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
struct dri2_egl_display *dri2_dpy = dri2_display_create();
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
return EGL_FALSE;
dri2_dpy->fd_render_gpu = -1;
dri2_dpy->fd_display_gpu = -1;
disp->DriverData = (void *)dri2_dpy;
if (dri2_wl_formats_init(&dri2_dpy->formats) < 0)

View File

@@ -1506,14 +1506,10 @@ static EGLBoolean
dri2_initialize_x11_swrast(_EGLDisplay *disp)
{
_EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
struct dri2_egl_display *dri2_dpy = dri2_display_create();
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
return EGL_FALSE;
dri2_dpy->fd_render_gpu = -1;
dri2_dpy->fd_display_gpu = -1;
if (!dri2_get_xcb_connection(disp, dri2_dpy))
goto cleanup;
@@ -1600,14 +1596,11 @@ static EGLBoolean
dri2_initialize_x11_dri3(_EGLDisplay *disp)
{
_EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
struct dri2_egl_display *dri2_dpy = dri2_display_create();
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
return EGL_FALSE;
dri2_dpy->fd_render_gpu = -1;
dri2_dpy->fd_display_gpu = -1;
if (!dri2_get_xcb_connection(disp, dri2_dpy))
goto cleanup;
@@ -1713,14 +1706,10 @@ static EGLBoolean
dri2_initialize_x11_dri2(_EGLDisplay *disp)
{
_EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
struct dri2_egl_display *dri2_dpy = dri2_display_create();
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
return EGL_FALSE;
dri2_dpy->fd_render_gpu = -1;
dri2_dpy->fd_display_gpu = -1;
if (!dri2_get_xcb_connection(disp, dri2_dpy))
goto cleanup;