Add new struct wlr_multi_gpu

For development to continue on systems (such as optimus laptops) that
have multiple GPUs, we need a way to reference all of the renderers
that have been created for devices in the system. A wlr_multi_gpu
struct holds renderers coming from two different sources:
1. the primary renderer (given to us by the compositor)
2. drm sub backends, each of which has a renderer created for
   cross-GPU copies.

This change provides a way to access all of these from the same
place.
This commit is contained in:
Austin Shafer 2022-07-27 16:07:21 -04:00
parent ed8961b309
commit 5a38cc57c8
7 changed files with 142 additions and 4 deletions

View file

@ -107,6 +107,7 @@ struct wlr_drm_backend {
/* Only initialized on multi-GPU setups */
struct wlr_drm_renderer mgpu_renderer;
struct wlr_multi_gpu *multi_gpu;
struct wlr_session *session;

View file

@ -4,10 +4,31 @@
#include <wayland-util.h>
#include <wlr/backend/interface.h>
#include <wlr/backend/multi.h>
#include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
struct wlr_multi_gpu_device {
struct wlr_renderer *renderer;
struct wlr_allocator *allocator;
struct wl_list link;
};
/*
* Helper struct for tracking multiple renderers. This solves the
* problem of us having many renderers (primary, plus individual
* secondary GPU drm renderers) but not tracking them in one location.
* We can use this struct to access renderers for each GPU in
* the system all from one place. Will be populated by the renderer
* the compositor makes, plus every time a drm mgpu renderer is made.
*/
struct wlr_multi_gpu {
struct wl_list devices;
};
struct wlr_multi_backend {
struct wlr_backend backend;
struct wlr_multi_gpu *multi_gpu;
struct wl_list backends;
struct wl_listener event_loop_destroy;

View file

@ -32,4 +32,7 @@ bool wlr_multi_is_empty(struct wlr_backend *backend);
void wlr_multi_for_each_backend(struct wlr_backend *backend,
void (*callback)(struct wlr_backend *backend, void *data), void *data);
struct wlr_multi_gpu *wlr_multi_gpu_create(void);
void wlr_multi_gpu_destroy(struct wlr_multi_gpu *multi_gpu);
#endif

View file

@ -14,13 +14,10 @@
#include <wlr/render/pass.h>
#include <wlr/render/wlr_texture.h>
#include <wlr/util/box.h>
#include <wlr/backend/multi.h>
struct wlr_backend;
struct wlr_renderer_impl;
struct wlr_drm_format_set;
struct wlr_buffer;
struct wlr_box;
struct wlr_fbox;
/**
* A renderer for basic 2D operations.
@ -39,6 +36,9 @@ struct wlr_renderer {
// private state
const struct wlr_renderer_impl *impl;
/* The GPU list we are a part of, may be null if not created from multi backend */
struct wlr_multi_gpu *multi_gpu;
};
/**