This is the final requirement from the base EGLDevice spec.
v2:
- split from another patch
- move wayland hunk after we have the fd
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
#include "eglconfig.h"
#include "eglcontext.h"
+#include "egldevice.h"
#include "egldisplay.h"
#include "egldriver.h"
#include "eglcurrent.h"
EGLBoolean
dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
const char *err;
int ret;
goto cleanup;
}
+ dev = _eglAddDevice(dri2_dpy->fd, false);
+ if (!dev) {
+ err = "DRI2: failed to find EGLDevice";
+ goto cleanup;
+ }
+
+ disp->Device = dev;
+
if (!dri2_setup_extensions(disp)) {
err = "DRI2: failed to setup extensions";
goto cleanup;
EGLBoolean
dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
struct gbm_device *gbm;
const char *err;
goto cleanup;
}
+ dev = _eglAddDevice(dri2_dpy->fd, false);
+ if (!dev) {
+ err = "DRI2: failed to find EGLDevice";
+ goto cleanup;
+ }
+
+ disp->Device = dev;
+
dri2_dpy->gbm_dri = gbm_dri_device(gbm);
dri2_dpy->driver_name = strdup(dri2_dpy->gbm_dri->driver_name);
}
dri2_dpy->fd = fd;
- if (dri2_load_driver_dri3(dpy))
+ if (dri2_load_driver_dri3(dpy)) {
+ _EGLDevice *dev = _eglAddDevice(dri2_dpy->fd, swrast);
+ if (!dev) {
+ dlclose(dri2_dpy->driver);
+ _eglLog(_EGL_WARNING, "DRI2: failed to find EGLDevice");
+ continue;
+ }
+ dpy->Device = dev;
return true;
+ }
close(fd);
dri2_dpy->fd = -1;
static EGLBoolean
dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
loader_set_logger(_eglLog);
dri2_dpy->fd = loader_get_user_preferred_fd(dri2_dpy->fd,
&dri2_dpy->is_different_gpu);
+ dev = _eglAddDevice(dri2_dpy->fd, false);
+ if (!dev) {
+ _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
+ goto cleanup;
+ }
+
+ disp->Device = dev;
+
if (dri2_dpy->is_different_gpu) {
free(dri2_dpy->device_name);
dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd);
static EGLBoolean
dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
loader_set_logger(_eglLog);
dri2_dpy->wl_dpy = disp->PlatformDisplay;
}
+ dev = _eglAddDevice(dri2_dpy->fd, true);
+ if (!dev) {
+ _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
+ goto cleanup;
+ }
+
+ disp->Device = dev;
+
dri2_dpy->wl_queue = wl_display_create_queue(dri2_dpy->wl_dpy);
dri2_dpy->wl_dpy_wrapper = wl_proxy_create_wrapper(dri2_dpy->wl_dpy);
static EGLBoolean
dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_get_xcb_connection(drv, disp, dri2_dpy))
goto cleanup;
+ dev = _eglAddDevice(dri2_dpy->fd, true);
+ if (!dev) {
+ _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find 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().
static EGLBoolean
dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri3_x11_connect(dri2_dpy))
goto cleanup;
+ dev = _eglAddDevice(dri2_dpy->fd, false);
+ if (!dev) {
+ _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
+ goto cleanup;
+ }
+
+ disp->Device = dev;
+
if (!dri2_load_driver_dri3(disp))
goto cleanup;
static EGLBoolean
dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_x11_connect(dri2_dpy))
goto cleanup;
+ dev = _eglAddDevice(dri2_dpy->fd, false);
+ if (!dev) {
+ _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
+ goto cleanup;
+ }
+
+ disp->Device = dev;
+
if (!dri2_load_driver(disp))
goto cleanup;
EGLBoolean
init_haiku(_EGLDriver *drv, _EGLDisplay *dpy)
{
+ _EGLDevice *dev;
CALLED();
+ dev = _eglAddDevice(-1, true);
+ if (!dev) {
+ _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice");
+ return EGL_FALSE;
+ }
+ disp->Device = dev;
+
TRACE("Add configs\n");
if (!haiku_add_configs_for_visuals(dpy))
return EGL_FALSE;