summaryrefslogtreecommitdiffstats
path: root/src/egl/drivers
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2018-09-04 11:20:03 +0100
committerEmil Velikov <[email protected]>2018-11-01 00:05:43 +0000
commit00992700c9a812a545637ec409099682ca9cc79a (patch)
tree0f819782b50d7ee32acdeb4f5e2f2395a76b59aa /src/egl/drivers
parentdbb4457d9858fa977246aa5e9cabe83455022dfe (diff)
egl: set the EGLDevice when creating a display
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 <[email protected]> Reviewed-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/egl/drivers')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h1
-rw-r--r--src/egl/drivers/dri2/platform_android.c9
-rw-r--r--src/egl/drivers/dri2/platform_drm.c9
-rw-r--r--src/egl/drivers/dri2/platform_surfaceless.c10
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c18
-rw-r--r--src/egl/drivers/dri2/platform_x11.c27
-rw-r--r--src/egl/drivers/haiku/egl_haiku.cpp8
7 files changed, 81 insertions, 1 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 349f66a3506..4abe1ba1952 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -71,6 +71,7 @@ struct zwp_linux_dmabuf_v1;
#include "eglconfig.h"
#include "eglcontext.h"
+#include "egldevice.h"
#include "egldisplay.h"
#include "egldriver.h"
#include "eglcurrent.h"
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 7413b8dfe02..1e93ab4d4d2 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1526,6 +1526,7 @@ droid_open_device(_EGLDisplay *disp)
EGLBoolean
dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
const char *err;
int ret;
@@ -1559,6 +1560,14 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
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;
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index da56064cbde..68ec8322e97 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -694,6 +694,7 @@ static const struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
EGLBoolean
dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
struct gbm_device *gbm;
const char *err;
@@ -736,6 +737,14 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
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);
diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c
index 1fd5925ae3c..1edfca246db 100644
--- a/src/egl/drivers/dri2/platform_surfaceless.c
+++ b/src/egl/drivers/dri2/platform_surfaceless.c
@@ -304,8 +304,16 @@ surfaceless_probe_device(_EGLDisplay *dpy, bool swrast)
}
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;
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 03a3e0993b0..eb9f5e2b1e2 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1320,6 +1320,7 @@ dri2_wl_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
static EGLBoolean
dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
loader_set_logger(_eglLog);
@@ -1374,6 +1375,14 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
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);
@@ -1974,6 +1983,7 @@ static const __DRIextension *swrast_loader_extensions[] = {
static EGLBoolean
dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp)
{
+ _EGLDevice *dev;
struct dri2_egl_display *dri2_dpy;
loader_set_logger(_eglLog);
@@ -1993,6 +2003,14 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp)
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);
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 88040bda6e6..4684c9f0825 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1271,6 +1271,7 @@ disconnect:
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);
@@ -1281,6 +1282,14 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp)
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().
@@ -1349,6 +1358,7 @@ static const __DRIextension *dri3_image_loader_extensions[] = {
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);
@@ -1362,6 +1372,14 @@ dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay *disp)
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;
@@ -1447,6 +1465,7 @@ static const __DRIextension *dri2_loader_extensions[] = {
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);
@@ -1460,6 +1479,14 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
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;
diff --git a/src/egl/drivers/haiku/egl_haiku.cpp b/src/egl/drivers/haiku/egl_haiku.cpp
index 0b56653395a..a9c5cf8d29b 100644
--- a/src/egl/drivers/haiku/egl_haiku.cpp
+++ b/src/egl/drivers/haiku/egl_haiku.cpp
@@ -207,8 +207,16 @@ extern "C"
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;