summaryrefslogtreecommitdiff
path: root/lib/mesa
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-01-29 11:04:23 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-01-29 11:04:23 +0000
commitb7e29d54c722d0c1ed6747b4108da9c0e9d29e26 (patch)
treee0f88da5f2d8b1d1da4df8ad3cc7dbf4dc0c711a /lib/mesa
parenta23eedfa09de961e85097e1170180959d0e879ca (diff)
Import Mesa 18.3.2
Diffstat (limited to 'lib/mesa')
-rw-r--r--lib/mesa/src/egl/main/egldevice.c101
1 files changed, 30 insertions, 71 deletions
diff --git a/lib/mesa/src/egl/main/egldevice.c b/lib/mesa/src/egl/main/egldevice.c
index ba7743081..4878039be 100644
--- a/lib/mesa/src/egl/main/egldevice.c
+++ b/lib/mesa/src/egl/main/egldevice.c
@@ -28,7 +28,6 @@
#ifdef HAVE_LIBDRM
#include <xf86drm.h>
#endif
-#include "util/compiler.h"
#include "util/macros.h"
#include "eglcurrent.h"
@@ -45,7 +44,6 @@ struct _egl_device {
EGLBoolean MESA_device_software;
EGLBoolean EXT_device_drm;
- EGLBoolean EXT_device_drm_render_node;
#ifdef HAVE_LIBDRM
drmDevicePtr device;
@@ -86,22 +84,20 @@ _eglCheckDeviceHandle(EGLDeviceEXT device)
{
_EGLDevice *cur;
- simple_mtx_lock(_eglGlobal.Mutex);
+ mtx_lock(_eglGlobal.Mutex);
cur = _eglGlobal.DeviceList;
while (cur) {
if (cur == (_EGLDevice *) device)
break;
cur = cur->Next;
}
- simple_mtx_unlock(_eglGlobal.Mutex);
+ mtx_unlock(_eglGlobal.Mutex);
return (cur != NULL);
}
_EGLDevice _eglSoftwareDevice = {
- /* TODO: EGL_EXT_device_drm support for KMS + llvmpipe */
- .extensions = "EGL_MESA_device_software EGL_EXT_device_drm_render_node",
+ .extensions = "EGL_MESA_device_software",
.MESA_device_software = EGL_TRUE,
- .EXT_device_drm_render_node = EGL_TRUE,
};
#ifdef HAVE_LIBDRM
@@ -146,12 +142,6 @@ _eglAddDRMDevice(drmDevicePtr device, _EGLDevice **out_dev)
dev->EXT_device_drm = EGL_TRUE;
dev->device = device;
- /* TODO: EGL_EXT_device_drm_render_node support for kmsro + renderonly */
- if (device->available_nodes & (1 << DRM_NODE_RENDER)) {
- dev->extensions = "EGL_EXT_device_drm EGL_EXT_device_drm_render_node";
- dev->EXT_device_drm_render_node = EGL_TRUE;
- }
-
if (out_dev)
*out_dev = dev;
@@ -168,7 +158,7 @@ _eglAddDevice(int fd, bool software)
{
_EGLDevice *dev;
- simple_mtx_lock(_eglGlobal.Mutex);
+ mtx_lock(_eglGlobal.Mutex);
dev = _eglGlobal.DeviceList;
/* The first device is always software */
@@ -194,7 +184,7 @@ _eglAddDevice(int fd, bool software)
#endif
out:
- simple_mtx_unlock(_eglGlobal.Mutex);
+ mtx_unlock(_eglGlobal.Mutex);
return dev;
}
@@ -206,21 +196,31 @@ _eglDeviceSupports(_EGLDevice *dev, _EGLDeviceExtension ext)
return dev->MESA_device_software;
case _EGL_DEVICE_DRM:
return dev->EXT_device_drm;
- case _EGL_DEVICE_DRM_RENDER_NODE:
- return dev->EXT_device_drm_render_node;
default:
assert(0);
return EGL_FALSE;
};
}
+/* Ideally we'll have an extension which passes the render node,
+ * instead of the card one + magic.
+ *
+ * Then we can move this in _eglQueryDeviceStringEXT below. Until then
+ * keep it separate.
+ */
+const char *
+_eglGetDRMDeviceRenderNode(_EGLDevice *dev)
+{
+ return dev->device->nodes[DRM_NODE_RENDER];
+}
+
EGLBoolean
_eglQueryDeviceAttribEXT(_EGLDevice *dev, EGLint attribute,
EGLAttrib *value)
{
switch (attribute) {
default:
- _eglError(EGL_BAD_ATTRIBUTE, "eglQueryDeviceAttribEXT");
+ _eglError(EGL_BAD_ATTRIBUTE, "eglQueryDeviceStringEXT");
return EGL_FALSE;
}
}
@@ -231,31 +231,16 @@ _eglQueryDeviceStringEXT(_EGLDevice *dev, EGLint name)
switch (name) {
case EGL_EXTENSIONS:
return dev->extensions;
- case EGL_DRM_DEVICE_FILE_EXT:
- if (!_eglDeviceSupports(dev, _EGL_DEVICE_DRM))
- break;
#ifdef HAVE_LIBDRM
- return dev->device->nodes[DRM_NODE_PRIMARY];
-#else
- /* This should never happen: we don't yet support EGL_DEVICE_DRM for the
- * software device, and physical devices are only exposed when libdrm is
- * available. */
- assert(0);
- break;
+ case EGL_DRM_DEVICE_FILE_EXT:
+ if (_eglDeviceSupports(dev, _EGL_DEVICE_DRM))
+ return dev->device->nodes[DRM_NODE_PRIMARY];
+ /* fall through */
#endif
- case EGL_DRM_RENDER_NODE_FILE_EXT:
- if (!_eglDeviceSupports(dev, _EGL_DEVICE_DRM_RENDER_NODE))
- break;
-#ifdef HAVE_LIBDRM
- return dev->device ? dev->device->nodes[DRM_NODE_RENDER] : NULL;
-#else
- /* Physical devices are only exposed when libdrm is available. */
- assert(_eglDeviceSupports(dev, _EGL_DEVICE_SOFTWARE));
+ default:
+ _eglError(EGL_BAD_PARAMETER, "eglQueryDeviceStringEXT");
return NULL;
-#endif
- }
- _eglError(EGL_BAD_PARAMETER, "eglQueryDeviceStringEXT");
- return NULL;
+ };
}
/* Do a fresh lookup for devices.
@@ -268,7 +253,7 @@ _eglQueryDeviceStringEXT(_EGLDevice *dev, EGLint name)
static int
_eglRefreshDeviceList(void)
{
- ASSERTED _EGLDevice *dev;
+ MAYBE_UNUSED _EGLDevice *dev;
int count = 0;
dev = _eglGlobal.DeviceList;
@@ -284,11 +269,6 @@ _eglRefreshDeviceList(void)
num_devs = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
for (int i = 0; i < num_devs; i++) {
- if (!(devices[i]->available_nodes & (1 << DRM_NODE_RENDER))) {
- drmFreeDevice(&devices[i]);
- continue;
- }
-
ret = _eglAddDRMDevice(devices[i], NULL);
/* Device is not added - error or already present */
@@ -308,27 +288,17 @@ _eglQueryDevicesEXT(EGLint max_devices,
_EGLDevice **devices,
EGLint *num_devices)
{
- _EGLDevice *dev, *devs, *swrast;
+ _EGLDevice *dev, *devs;
int i = 0, num_devs;
if ((devices && max_devices <= 0) || !num_devices)
return _eglError(EGL_BAD_PARAMETER, "eglQueryDevicesEXT");
- simple_mtx_lock(_eglGlobal.Mutex);
+ mtx_lock(_eglGlobal.Mutex);
num_devs = _eglRefreshDeviceList();
devs = _eglGlobal.DeviceList;
-#ifdef GALLIUM_SOFTPIPE
- swrast = devs;
-#else
- swrast = NULL;
- num_devs--;
-#endif
-
- /* The first device is swrast. Start with the non-swrast device. */
- devs = devs->Next;
-
/* bail early if we only care about the count */
if (!devices) {
*num_devices = num_devs;
@@ -337,24 +307,13 @@ _eglQueryDevicesEXT(EGLint max_devices,
*num_devices = MIN2(num_devs, max_devices);
- /* Add non-swrast devices first and add swrast last.
- *
- * By default, the user is likely to pick the first device so having the
- * software (aka least performant) one is not a good idea.
- */
- for (i = 0, dev = devs; dev && i < max_devices; i++) {
+ for (i = 0, dev = devs; i < *num_devices; i++) {
devices[i] = dev;
dev = dev->Next;
}
- /* User requested the full device list, add the sofware device. */
- if (max_devices >= num_devs && swrast) {
- assert(_eglDeviceSupports(swrast, _EGL_DEVICE_SOFTWARE));
- devices[num_devs - 1] = swrast;
- }
-
out:
- simple_mtx_unlock(_eglGlobal.Mutex);
+ mtx_unlock(_eglGlobal.Mutex);
return EGL_TRUE;
}