浏览代码

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 <emil.velikov@collabora.com>
Reviewed-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
tags/18.3-branchpoint
Emil Velikov 6 年前
父节点
当前提交
00992700c9

+ 1
- 0
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"

+ 9
- 0
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;

+ 9
- 0
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);


+ 9
- 1
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;

+ 18
- 0
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);

+ 27
- 0
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;


+ 8
- 0
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;

正在加载...
取消
保存