|
14 | 14 | #include "wayfire/config-backend.hpp"
|
15 | 15 | #include "core/plugin-loader.hpp"
|
16 | 16 | #include "core/core-impl.hpp"
|
| 17 | +#include <wayfire/nonstd/wlroots.hpp> |
17 | 18 |
|
18 | 19 | static void print_version()
|
19 | 20 | {
|
@@ -382,27 +383,40 @@ int main(int argc, char *argv[])
|
382 | 383 | core.ev_loop = wl_display_get_event_loop(core.display);
|
383 | 384 | core.backend = wlr_backend_autocreate(core.ev_loop, &core.session);
|
384 | 385 |
|
385 |
| - int drm_fd = wlr_backend_get_drm_fd(core.backend); |
386 |
| - if (drm_fd < 0) |
| 386 | + int drm_fd = -1; |
| 387 | + char *drm_device = getenv("WLR_RENDER_DRM_DEVICE"); |
| 388 | + if (drm_device) |
387 | 389 | {
|
388 |
| - char *drm_device = getenv("WLR_RENDER_DRM_DEVICE"); |
389 |
| - if (drm_device) |
390 |
| - { |
391 |
| - drm_fd = open(drm_device, O_RDWR | O_CLOEXEC); |
392 |
| - } |
| 390 | + drm_fd = open(drm_device, O_RDWR | O_CLOEXEC); |
| 391 | + } else |
| 392 | + { |
| 393 | + drm_fd = wlr_backend_get_drm_fd(core.backend); |
| 394 | + } |
393 | 395 |
|
394 |
| - if (drm_fd < 0) |
395 |
| - { |
396 |
| - LOGE("Failed to get DRM file descriptor,", |
397 |
| - " try specifying a valid WLR_RENDER_DRM_DEVICE!"); |
398 |
| - wl_display_destroy_clients(core.display); |
399 |
| - wl_display_destroy(core.display); |
400 |
| - return EXIT_FAILURE; |
401 |
| - } |
| 396 | + if (drm_fd < 0) |
| 397 | + { |
| 398 | +#if WLR_HAS_UDMABUF_ALLOCATOR == 1 |
| 399 | + LOGW("Failed to open DRM render device, consider specifying WLR_RENDER_DRM_DEVICE." |
| 400 | + "Trying SW rendering instead."); |
| 401 | +#else |
| 402 | + LOGE("Failed to open DRM render device, consider specifying WLR_RENDER_DRM_DEVICE." |
| 403 | + "If you want to use software rendering, ensure that wlroots has been compiled with udmabuf " |
| 404 | + "allocator support (available in wlroots >= 0.19.0) and recompile Wayfire."); |
| 405 | + wl_display_destroy_clients(core.display); |
| 406 | + wl_display_destroy(core.display); |
| 407 | + return EXIT_FAILURE; |
| 408 | +#endif |
402 | 409 | }
|
403 | 410 |
|
404 | 411 | core.renderer = wlr_gles2_renderer_create_with_drm_fd(drm_fd);
|
405 |
| - assert(core.renderer); |
| 412 | + if (!core.renderer) |
| 413 | + { |
| 414 | + LOGE("Failed to create renderer"); |
| 415 | + wl_display_destroy_clients(core.display); |
| 416 | + wl_display_destroy(core.display); |
| 417 | + return EXIT_FAILURE; |
| 418 | + } |
| 419 | + |
406 | 420 | core.allocator = wlr_allocator_autocreate(core.backend, core.renderer);
|
407 | 421 | assert(core.allocator);
|
408 | 422 | core.egl = wlr_gles2_renderer_get_egl(core.renderer);
|
|
0 commit comments