diff options
author | Leonardo Hernández Hernández <leohdz172@proton.me> | 2024-05-03 11:03:18 -0600 |
---|---|---|
committer | Leonardo Hernández Hernández <leohdz172@proton.me> | 2024-06-20 16:58:31 -0600 |
commit | a8403d7b4d54e30699424586784cc0265b29d08d (patch) | |
tree | 5a607cf802a12e6d6f67ddd376ba7d30511bb7f6 | |
parent | 57b5e41063d27087d3a651b28f1ae6c7d9e2a6da (diff) |
handle gpu resets
Fixes: https://codeberg.org/dwl/dwl/issues/601
-rw-r--r-- | dwl.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -289,6 +289,7 @@ static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); +static void gpureset(struct wl_listener *listener, void *data); static void handlesig(int signo); static void incnmaster(const Arg *arg); static void inputdevice(struct wl_listener *listener, void *data); @@ -1455,6 +1456,30 @@ fullscreennotify(struct wl_listener *listener, void *data) } void +gpureset(struct wl_listener *listener, void *data) +{ + struct wlr_renderer *old_drw = drw; + struct wlr_allocator *old_alloc = alloc; + struct Monitor *m; + if (!(drw = wlr_renderer_autocreate(backend))) + die("couldn't recreate renderer"); + + if (!(alloc = wlr_allocator_autocreate(backend, drw))) + die("couldn't recreate allocator"); + + LISTEN_STATIC(&drw->events.lost, gpureset); + + wlr_compositor_set_renderer(compositor, drw); + + wl_list_for_each(m, &mons, link) { + wlr_output_init_render(m->wlr_output, alloc, drw); + } + + wlr_allocator_destroy(old_alloc); + wlr_renderer_destroy(old_drw); +} + +void handlesig(int signo) { if (signo == SIGCHLD) { @@ -2394,6 +2419,7 @@ setup(void) * supports for shared memory, this configures that for clients. */ if (!(drw = wlr_renderer_autocreate(backend))) die("couldn't create renderer"); + LISTEN_STATIC(&drw->events.lost, gpureset); /* Create shm, drm and linux_dmabuf interfaces by ourselves. * The simplest way is call: |