mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 15:40:11 +01:00
egl: add EGL_MESA_device_software support
Add a plain software device, which is always available. We can safely assign it as the first/initial device in _eglGlobals, although we ensure that's the case with a handful of _eglDeviceSupports checks throughout the code. v2: - s/_eglFindDevice/_eglAddDevice/ (Eric) - s/_eglLookupAllDevices/_eglRefreshDeviceList/ (Eric) - move ^^ helpers into a earlier patch (Eric, Mathias) - set the SW device on _eglGlobal init. (Eric) - add a number of _eglDeviceSupports checks (Mathias) - split Device/Display attach to a separate patch v3: - flip inverted asserts (Mathias) - s/on-stack/static/ (Mathias) Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
This commit is contained in:
parent
3f08e500c4
commit
f73c5d27c1
3 changed files with 31 additions and 1 deletions
|
|
@ -37,6 +37,8 @@ struct _egl_device {
|
||||||
_EGLDevice *Next;
|
_EGLDevice *Next;
|
||||||
|
|
||||||
const char *extensions;
|
const char *extensions;
|
||||||
|
|
||||||
|
EGLBoolean MESA_device_software;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -47,6 +49,12 @@ _eglFiniDevice(void)
|
||||||
/* atexit function is called with global mutex locked */
|
/* atexit function is called with global mutex locked */
|
||||||
|
|
||||||
dev_list = _eglGlobal.DeviceList;
|
dev_list = _eglGlobal.DeviceList;
|
||||||
|
|
||||||
|
/* The first device is static allocated SW device */
|
||||||
|
assert(dev_list);
|
||||||
|
assert(_eglDeviceSupports(dev_list, _EGL_DEVICE_SOFTWARE));
|
||||||
|
dev_list = dev_list->Next;
|
||||||
|
|
||||||
while (dev_list) {
|
while (dev_list) {
|
||||||
/* pop list head */
|
/* pop list head */
|
||||||
dev = dev_list;
|
dev = dev_list;
|
||||||
|
|
@ -74,6 +82,11 @@ _eglCheckDeviceHandle(EGLDeviceEXT device)
|
||||||
return (cur != NULL);
|
return (cur != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_EGLDevice _eglSoftwareDevice = {
|
||||||
|
.extensions = "EGL_MESA_device_software",
|
||||||
|
.MESA_device_software = EGL_TRUE,
|
||||||
|
};
|
||||||
|
|
||||||
/* Adds a device in DeviceList, if needed for the given fd.
|
/* Adds a device in DeviceList, if needed for the given fd.
|
||||||
*
|
*
|
||||||
* If a software device, the fd is ignored.
|
* If a software device, the fd is ignored.
|
||||||
|
|
@ -84,6 +97,13 @@ _eglAddDevice(int fd, bool software)
|
||||||
_EGLDevice *dev;
|
_EGLDevice *dev;
|
||||||
|
|
||||||
mtx_lock(_eglGlobal.Mutex);
|
mtx_lock(_eglGlobal.Mutex);
|
||||||
|
dev = _eglGlobal.DeviceList;
|
||||||
|
|
||||||
|
/* The first device is always software */
|
||||||
|
assert(dev);
|
||||||
|
assert(_eglDeviceSupports(dev, _EGL_DEVICE_SOFTWARE));
|
||||||
|
if (software)
|
||||||
|
goto out;
|
||||||
|
|
||||||
dev = NULL;
|
dev = NULL;
|
||||||
|
|
||||||
|
|
@ -96,6 +116,8 @@ EGLBoolean
|
||||||
_eglDeviceSupports(_EGLDevice *dev, _EGLDeviceExtension ext)
|
_eglDeviceSupports(_EGLDevice *dev, _EGLDeviceExtension ext)
|
||||||
{
|
{
|
||||||
switch (ext) {
|
switch (ext) {
|
||||||
|
case _EGL_DEVICE_SOFTWARE:
|
||||||
|
return dev->MESA_device_software;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
|
|
@ -140,6 +162,11 @@ _eglRefreshDeviceList(void)
|
||||||
|
|
||||||
dev = _eglGlobal.DeviceList;
|
dev = _eglGlobal.DeviceList;
|
||||||
|
|
||||||
|
/* The first device is always software */
|
||||||
|
assert(dev);
|
||||||
|
assert(_eglDeviceSupports(dev, _EGL_DEVICE_SOFTWARE));
|
||||||
|
count++;
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern _EGLDevice _eglSoftwareDevice;
|
||||||
|
|
||||||
void
|
void
|
||||||
_eglFiniDevice(void);
|
_eglFiniDevice(void);
|
||||||
|
|
||||||
|
|
@ -57,7 +59,7 @@ _EGLDevice *
|
||||||
_eglAddDevice(int fd, bool software);
|
_eglAddDevice(int fd, bool software);
|
||||||
|
|
||||||
enum _egl_device_extension {
|
enum _egl_device_extension {
|
||||||
EGL_FOOBAR, /* A temporary entry, since enum with zero entries is illegal */
|
_EGL_DEVICE_SOFTWARE,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum _egl_device_extension _EGLDeviceExtension;
|
typedef enum _egl_device_extension _EGLDeviceExtension;
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ struct _egl_global _eglGlobal =
|
||||||
{
|
{
|
||||||
.Mutex = &_eglGlobalMutex,
|
.Mutex = &_eglGlobalMutex,
|
||||||
.DisplayList = NULL,
|
.DisplayList = NULL,
|
||||||
|
.DeviceList = &_eglSoftwareDevice,
|
||||||
.NumAtExitCalls = 3,
|
.NumAtExitCalls = 3,
|
||||||
.AtExitCalls = {
|
.AtExitCalls = {
|
||||||
/* default AtExitCalls, called in reverse order */
|
/* default AtExitCalls, called in reverse order */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue