egl: inline fallback for swap_buffers_with_damage
[mesa.git] / src / egl / drivers / dri2 / platform_drm.c
index 7b13129ee3aa2c85ac8c190878ea10e42ec39b72..ce0bd1b137f2cc79d0c280cea8957e6ba0dc6f26 100644 (file)
@@ -36,6 +36,8 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#include "util/os_file.h"
+
 #include "egl_dri2.h"
 #include "egl_dri2_fallbacks.h"
 #include "loader.h"
@@ -122,11 +124,13 @@ dri2_drm_config_is_compatible(struct dri2_egl_display *dri2_dpy,
    if (shifts[0] != visual->rgba_shifts.red ||
        shifts[1] != visual->rgba_shifts.green ||
        shifts[2] != visual->rgba_shifts.blue ||
-       (shifts[3] > -1 && shifts[3] != visual->rgba_shifts.alpha) ||
+       (shifts[3] > -1 && visual->rgba_shifts.alpha > -1 &&
+        shifts[3] != visual->rgba_shifts.alpha) ||
        sizes[0] != visual->rgba_sizes.red ||
        sizes[1] != visual->rgba_sizes.green ||
        sizes[2] != visual->rgba_sizes.blue ||
-       (sizes[3] > 0 && sizes[3] != visual->rgba_sizes.alpha) ||
+       (sizes[3] > 0 && visual->rgba_sizes.alpha > 0 &&
+        sizes[3] != visual->rgba_sizes.alpha) ||
        is_float != visual->is_float) {
       return false;
    }
@@ -671,11 +675,9 @@ static const struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
    .authenticate = dri2_drm_authenticate,
    .create_window_surface = dri2_drm_create_window_surface,
    .create_pixmap_surface = dri2_drm_create_pixmap_surface,
-   .create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
    .destroy_surface = dri2_drm_destroy_surface,
    .create_image = dri2_drm_create_image_khr,
    .swap_buffers = dri2_drm_swap_buffers,
-   .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
    .swap_buffers_region = dri2_fallback_swap_buffers_region,
    .post_sub_buffer = dri2_fallback_post_sub_buffer,
    .copy_buffers = dri2_fallback_copy_buffers,
@@ -693,10 +695,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
    struct gbm_device *gbm;
    const char *err;
 
-   /* Not supported yet */
-   if (disp->Options.ForceSoftware)
-      return EGL_FALSE;
-
    dri2_dpy = calloc(1, sizeof *dri2_dpy);
    if (!dri2_dpy)
       return _eglError(EGL_BAD_ALLOC, "eglInitialize");
@@ -717,7 +715,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
       }
       dri2_dpy->own_device = true;
    } else {
-      dri2_dpy->fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3);
+      dri2_dpy->fd = os_dupfd_cloexec(gbm_device_get_fd(gbm));
       if (dri2_dpy->fd < 0) {
          err = "DRI2: failed to fcntl() existing gbm device";
          goto cleanup;
@@ -730,7 +728,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
       goto cleanup;
    }
 
-   dev = _eglAddDevice(dri2_dpy->fd, false);
+   dev = _eglAddDevice(dri2_dpy->fd, disp->Options.ForceSoftware);
    if (!dev) {
       err = "DRI2: failed to find EGLDevice";
       goto cleanup;