mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
renderer: Don't crash when trying to fallback to pixman
Pixman won't be chosen by default if the system has a valid render node but gles2 and vulkan creation failed.
This commit is contained in:
parent
4f92ecde82
commit
d817ebb80f
1 changed files with 18 additions and 9 deletions
|
@ -346,6 +346,23 @@ static void log_creation_failure(bool is_auto, const char *msg) {
|
||||||
wlr_log(is_auto ? WLR_DEBUG : WLR_ERROR, "%s%s", msg, is_auto ? ". Skipping!" : "");
|
wlr_log(is_auto ? WLR_DEBUG : WLR_ERROR, "%s%s", msg, is_auto ? ". Skipping!" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool has_render_node(struct wlr_backend *backend) {
|
||||||
|
if (!backend) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int backend_drm_fd = wlr_backend_get_drm_fd(backend);
|
||||||
|
if (backend_drm_fd < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *render_node = drmGetRenderDeviceNameFromFd(backend_drm_fd);
|
||||||
|
bool has_render_node = render_node != NULL;
|
||||||
|
free(render_node);
|
||||||
|
|
||||||
|
return has_render_node;
|
||||||
|
}
|
||||||
|
|
||||||
static struct wlr_renderer *renderer_autocreate(struct wlr_backend *backend, int drm_fd) {
|
static struct wlr_renderer *renderer_autocreate(struct wlr_backend *backend, int drm_fd) {
|
||||||
const char *renderer_options[] = {
|
const char *renderer_options[] = {
|
||||||
"auto",
|
"auto",
|
||||||
|
@ -396,15 +413,7 @@ static struct wlr_renderer *renderer_autocreate(struct wlr_backend *backend, int
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool has_render_node = false;
|
if ((is_auto && !has_render_node(backend)) || strcmp(renderer_name, "pixman") == 0) {
|
||||||
int backend_drm_fd = wlr_backend_get_drm_fd(backend);
|
|
||||||
if (is_auto && backend_drm_fd >= 0) {
|
|
||||||
char *render_node = drmGetRenderDeviceNameFromFd(backend_drm_fd);
|
|
||||||
has_render_node = render_node != NULL;
|
|
||||||
free(render_node);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((is_auto && !has_render_node) || strcmp(renderer_name, "pixman") == 0) {
|
|
||||||
renderer = wlr_pixman_renderer_create();
|
renderer = wlr_pixman_renderer_create();
|
||||||
if (renderer) {
|
if (renderer) {
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Loading…
Reference in a new issue