Remove wlr_create_renderer_func_t

This callback allowed compositors to customize the EGL config used by
the renderer. However with renderer v6 EGL configs aren't used anymore.
Instead, buffers are allocated via GBM and GL FBOs are rendered to. So
customizing the EGL config is a no-op.
This commit is contained in:
Simon Ser 2020-12-19 11:34:28 +01:00
parent bec1e6b149
commit 4b03bdc3ab
20 changed files with 43 additions and 76 deletions

View file

@ -87,9 +87,8 @@ static size_t parse_outputs_env(const char *name) {
return outputs; return outputs;
} }
static struct wlr_backend *attempt_wl_backend(struct wl_display *display, static struct wlr_backend *attempt_wl_backend(struct wl_display *display) {
wlr_renderer_create_func_t create_renderer_func) { struct wlr_backend *backend = wlr_wl_backend_create(display, NULL);
struct wlr_backend *backend = wlr_wl_backend_create(display, NULL, create_renderer_func);
if (backend == NULL) { if (backend == NULL) {
return NULL; return NULL;
} }
@ -104,8 +103,8 @@ static struct wlr_backend *attempt_wl_backend(struct wl_display *display,
#if WLR_HAS_X11_BACKEND #if WLR_HAS_X11_BACKEND
static struct wlr_backend *attempt_x11_backend(struct wl_display *display, static struct wlr_backend *attempt_x11_backend(struct wl_display *display,
const char *x11_display, wlr_renderer_create_func_t create_renderer_func) { const char *x11_display) {
struct wlr_backend *backend = wlr_x11_backend_create(display, x11_display, create_renderer_func); struct wlr_backend *backend = wlr_x11_backend_create(display, x11_display);
if (backend == NULL) { if (backend == NULL) {
return NULL; return NULL;
} }
@ -120,8 +119,8 @@ static struct wlr_backend *attempt_x11_backend(struct wl_display *display,
#endif #endif
static struct wlr_backend *attempt_headless_backend( static struct wlr_backend *attempt_headless_backend(
struct wl_display *display, wlr_renderer_create_func_t create_renderer_func) { struct wl_display *display) {
struct wlr_backend *backend = wlr_headless_backend_create(display, create_renderer_func); struct wlr_backend *backend = wlr_headless_backend_create(display);
if (backend == NULL) { if (backend == NULL) {
return NULL; return NULL;
} }
@ -149,8 +148,7 @@ static struct wlr_backend *attempt_noop_backend(struct wl_display *display) {
} }
static struct wlr_backend *attempt_drm_backend(struct wl_display *display, static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
struct wlr_backend *backend, struct wlr_session *session, struct wlr_backend *backend, struct wlr_session *session) {
wlr_renderer_create_func_t create_renderer_func) {
struct wlr_device *gpus[8]; struct wlr_device *gpus[8];
size_t num_gpus = wlr_session_find_gpus(session, 8, gpus); size_t num_gpus = wlr_session_find_gpus(session, 8, gpus);
struct wlr_backend *primary_drm = NULL; struct wlr_backend *primary_drm = NULL;
@ -158,7 +156,7 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
for (size_t i = 0; i < num_gpus; ++i) { for (size_t i = 0; i < num_gpus; ++i) {
struct wlr_backend *drm = wlr_drm_backend_create(display, session, struct wlr_backend *drm = wlr_drm_backend_create(display, session,
gpus[i], primary_drm, create_renderer_func); gpus[i], primary_drm);
if (!drm) { if (!drm) {
wlr_log(WLR_ERROR, "Failed to create DRM backend"); wlr_log(WLR_ERROR, "Failed to create DRM backend");
continue; continue;
@ -176,15 +174,15 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
static struct wlr_backend *attempt_backend_by_name(struct wl_display *display, static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
struct wlr_backend *backend, struct wlr_session **session, struct wlr_backend *backend, struct wlr_session **session,
const char *name, wlr_renderer_create_func_t create_renderer_func) { const char *name) {
if (strcmp(name, "wayland") == 0) { if (strcmp(name, "wayland") == 0) {
return attempt_wl_backend(display, create_renderer_func); return attempt_wl_backend(display);
#if WLR_HAS_X11_BACKEND #if WLR_HAS_X11_BACKEND
} else if (strcmp(name, "x11") == 0) { } else if (strcmp(name, "x11") == 0) {
return attempt_x11_backend(display, NULL, create_renderer_func); return attempt_x11_backend(display, NULL);
#endif #endif
} else if (strcmp(name, "headless") == 0) { } else if (strcmp(name, "headless") == 0) {
return attempt_headless_backend(display, create_renderer_func); return attempt_headless_backend(display);
} else if (strcmp(name, "noop") == 0) { } else if (strcmp(name, "noop") == 0) {
return attempt_noop_backend(display); return attempt_noop_backend(display);
} else if (strcmp(name, "drm") == 0 || strcmp(name, "libinput") == 0) { } else if (strcmp(name, "drm") == 0 || strcmp(name, "libinput") == 0) {
@ -200,7 +198,7 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
if (strcmp(name, "libinput") == 0) { if (strcmp(name, "libinput") == 0) {
return wlr_libinput_backend_create(display, *session); return wlr_libinput_backend_create(display, *session);
} else { } else {
return attempt_drm_backend(display, backend, *session, create_renderer_func); return attempt_drm_backend(display, backend, *session);
} }
} }
@ -208,8 +206,7 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
return NULL; return NULL;
} }
struct wlr_backend *wlr_backend_autocreate(struct wl_display *display, struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
wlr_renderer_create_func_t create_renderer_func) {
struct wlr_backend *backend = wlr_multi_backend_create(display); struct wlr_backend *backend = wlr_multi_backend_create(display);
struct wlr_multi_backend *multi = (struct wlr_multi_backend *)backend; struct wlr_multi_backend *multi = (struct wlr_multi_backend *)backend;
if (!backend) { if (!backend) {
@ -230,7 +227,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
char *name = strtok_r(names, ",", &saveptr); char *name = strtok_r(names, ",", &saveptr);
while (name != NULL) { while (name != NULL) {
struct wlr_backend *subbackend = attempt_backend_by_name(display, struct wlr_backend *subbackend = attempt_backend_by_name(display,
backend, &multi->session, name, create_renderer_func); backend, &multi->session, name);
if (subbackend == NULL) { if (subbackend == NULL) {
wlr_log(WLR_ERROR, "failed to start backend '%s'", name); wlr_log(WLR_ERROR, "failed to start backend '%s'", name);
wlr_session_destroy(multi->session); wlr_session_destroy(multi->session);
@ -255,8 +252,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
} }
if (getenv("WAYLAND_DISPLAY") || getenv("WAYLAND_SOCKET")) { if (getenv("WAYLAND_DISPLAY") || getenv("WAYLAND_SOCKET")) {
struct wlr_backend *wl_backend = attempt_wl_backend(display, struct wlr_backend *wl_backend = attempt_wl_backend(display);
create_renderer_func);
if (!wl_backend) { if (!wl_backend) {
goto error; goto error;
} }
@ -269,7 +265,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
const char *x11_display = getenv("DISPLAY"); const char *x11_display = getenv("DISPLAY");
if (x11_display) { if (x11_display) {
struct wlr_backend *x11_backend = struct wlr_backend *x11_backend =
attempt_x11_backend(display, x11_display, create_renderer_func); attempt_x11_backend(display, x11_display);
if (!x11_backend) { if (!x11_backend) {
goto error; goto error;
} }
@ -297,8 +293,8 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
} }
wlr_multi_backend_add(backend, libinput); wlr_multi_backend_add(backend, libinput);
struct wlr_backend *primary_drm = attempt_drm_backend(display, backend, struct wlr_backend *primary_drm =
multi->session, create_renderer_func); attempt_drm_backend(display, backend, multi->session);
if (!primary_drm) { if (!primary_drm) {
wlr_log(WLR_ERROR, "Failed to open any DRM device"); wlr_log(WLR_ERROR, "Failed to open any DRM device");
wlr_backend_destroy(libinput); wlr_backend_destroy(libinput);

View file

@ -128,8 +128,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
struct wlr_session *session, struct wlr_device *dev, struct wlr_session *session, struct wlr_device *dev,
struct wlr_backend *parent, struct wlr_backend *parent) {
wlr_renderer_create_func_t create_renderer_func) {
assert(display && session && dev); assert(display && session && dev);
assert(!parent || wlr_backend_is_drm(parent)); assert(!parent || wlr_backend_is_drm(parent));
@ -179,7 +178,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
goto error_event; goto error_event;
} }
if (!init_drm_renderer(drm, &drm->renderer, create_renderer_func)) { if (!init_drm_renderer(drm, &drm->renderer)) {
wlr_log(WLR_ERROR, "Failed to initialize renderer"); wlr_log(WLR_ERROR, "Failed to initialize renderer");
goto error_event; goto error_event;
} }

View file

@ -21,7 +21,7 @@
#include "render/wlr_renderer.h" #include "render/wlr_renderer.h"
bool init_drm_renderer(struct wlr_drm_backend *drm, bool init_drm_renderer(struct wlr_drm_backend *drm,
struct wlr_drm_renderer *renderer, wlr_renderer_create_func_t create_renderer_func) { struct wlr_drm_renderer *renderer) {
renderer->backend = drm; renderer->backend = drm;
renderer->gbm = gbm_create_device(drm->fd); renderer->gbm = gbm_create_device(drm->fd);
@ -30,11 +30,7 @@ bool init_drm_renderer(struct wlr_drm_backend *drm,
return false; return false;
} }
if (!create_renderer_func) { renderer->wlr_rend = wlr_renderer_autocreate(&renderer->egl,
create_renderer_func = wlr_renderer_autocreate;
}
renderer->wlr_rend = create_renderer_func(&renderer->egl,
EGL_PLATFORM_GBM_KHR, renderer->gbm, NULL, 0); EGL_PLATFORM_GBM_KHR, renderer->gbm, NULL, 0);
if (!renderer->wlr_rend) { if (!renderer->wlr_rend) {
wlr_log(WLR_ERROR, "Failed to create EGL/WLR renderer"); wlr_log(WLR_ERROR, "Failed to create EGL/WLR renderer");

View file

@ -184,8 +184,7 @@ out:
return fd; return fd;
} }
struct wlr_backend *wlr_headless_backend_create(struct wl_display *display, struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
wlr_renderer_create_func_t create_renderer_func) {
wlr_log(WLR_INFO, "Creating headless backend"); wlr_log(WLR_INFO, "Creating headless backend");
int drm_fd = open_drm_render_node(); int drm_fd = open_drm_render_node();
@ -207,11 +206,7 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display,
goto error_backend; goto error_backend;
} }
if (!create_renderer_func) { struct wlr_renderer *renderer = wlr_renderer_autocreate(&backend->priv_egl,
create_renderer_func = wlr_renderer_autocreate;
}
struct wlr_renderer *renderer = create_renderer_func(&backend->priv_egl,
EGL_PLATFORM_GBM_KHR, gbm_alloc->gbm_device, NULL, 0); EGL_PLATFORM_GBM_KHR, gbm_alloc->gbm_device, NULL, 0);
if (!renderer) { if (!renderer) {
wlr_log(WLR_ERROR, "Failed to create renderer"); wlr_log(WLR_ERROR, "Failed to create renderer");

View file

@ -260,7 +260,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
} }
struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
const char *remote, wlr_renderer_create_func_t create_renderer_func) { const char *remote) {
wlr_log(WLR_INFO, "Creating wayland backend"); wlr_log(WLR_INFO, "Creating wayland backend");
struct wlr_wl_backend *wl = calloc(1, sizeof(*wl)); struct wlr_wl_backend *wl = calloc(1, sizeof(*wl));
@ -315,11 +315,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
} }
wl_event_source_check(wl->remote_display_src); wl_event_source_check(wl->remote_display_src);
if (!create_renderer_func) { wl->renderer = wlr_renderer_autocreate(&wl->egl, EGL_PLATFORM_WAYLAND_EXT,
create_renderer_func = wlr_renderer_autocreate;
}
wl->renderer = create_renderer_func(&wl->egl, EGL_PLATFORM_WAYLAND_EXT,
wl->remote_display, NULL, 0); wl->remote_display, NULL, 0);
if (!wl->renderer) { if (!wl->renderer) {
wlr_log(WLR_ERROR, "Could not create renderer"); wlr_log(WLR_ERROR, "Could not create renderer");

View file

@ -322,8 +322,7 @@ static bool query_dri3_formats(struct wlr_x11_backend *x11) {
} }
struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
const char *x11_display, const char *x11_display) {
wlr_renderer_create_func_t create_renderer_func) {
struct wlr_x11_backend *x11 = calloc(1, sizeof(*x11)); struct wlr_x11_backend *x11 = calloc(1, sizeof(*x11));
if (!x11) { if (!x11) {
return NULL; return NULL;
@ -512,11 +511,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
} }
x11->allocator = &gbm_alloc->base; x11->allocator = &gbm_alloc->base;
if (!create_renderer_func) { x11->renderer = wlr_renderer_autocreate(&x11->egl, EGL_PLATFORM_GBM_KHR,
create_renderer_func = wlr_renderer_autocreate;
}
x11->renderer = create_renderer_func(&x11->egl, EGL_PLATFORM_GBM_KHR,
gbm_alloc->gbm_device, NULL, 0); gbm_alloc->gbm_device, NULL, 0);
if (x11->renderer == NULL) { if (x11->renderer == NULL) {
wlr_log(WLR_ERROR, "Failed to create renderer"); wlr_log(WLR_ERROR, "Failed to create renderer");

View file

@ -203,7 +203,7 @@ int main(int argc, char *argv[]) {
struct fullscreen_server server = {0}; struct fullscreen_server server = {0};
server.wl_display = wl_display_create(); server.wl_display = wl_display_create();
server.backend = wlr_backend_autocreate(server.wl_display, NULL); server.backend = wlr_backend_autocreate(server.wl_display);
server.renderer = wlr_backend_get_renderer(server.backend); server.renderer = wlr_backend_get_renderer(server.backend);
wlr_renderer_init_wl_display(server.renderer, server.wl_display); wlr_renderer_init_wl_display(server.renderer, server.wl_display);

View file

@ -271,7 +271,7 @@ int main(int argc, char *argv[]) {
.clear_color = { 0.25f, 0.25f, 0.25f, 1 }, .clear_color = { 0.25f, 0.25f, 0.25f, 1 },
.display = display, .display = display,
}; };
struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL); struct wlr_backend *wlr = wlr_backend_autocreate(display);
if (!wlr) { if (!wlr) {
exit(1); exit(1);
} }

View file

@ -267,7 +267,7 @@ int main(int argc, char *argv[]) {
state.layout = wlr_output_layout_create(); state.layout = wlr_output_layout_create();
clock_gettime(CLOCK_MONOTONIC, &state.ts_last); clock_gettime(CLOCK_MONOTONIC, &state.ts_last);
struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL); struct wlr_backend *wlr = wlr_backend_autocreate(display);
if (!wlr) { if (!wlr) {
exit(1); exit(1);
} }

View file

@ -333,7 +333,7 @@ int main(int argc, char *argv[]) {
.display = display .display = display
}; };
struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL); struct wlr_backend *wlr = wlr_backend_autocreate(display);
if (!wlr) { if (!wlr) {
exit(1); exit(1);
} }

View file

@ -241,7 +241,7 @@ int main(int argc, char *argv[]) {
}; };
wl_list_init(&state.outputs); wl_list_init(&state.outputs);
struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL); struct wlr_backend *wlr = wlr_backend_autocreate(display);
if (!wlr) { if (!wlr) {
exit(1); exit(1);
} }

View file

@ -173,7 +173,7 @@ int main(void) {
.last_frame = { 0 }, .last_frame = { 0 },
.display = display .display = display
}; };
struct wlr_backend *backend = wlr_backend_autocreate(display, NULL); struct wlr_backend *backend = wlr_backend_autocreate(display);
if (!backend) { if (!backend) {
exit(1); exit(1);
} }

View file

@ -356,7 +356,7 @@ int main(int argc, char *argv[]) {
}; };
wl_list_init(&state.tablet_pads); wl_list_init(&state.tablet_pads);
wl_list_init(&state.tablet_tools); wl_list_init(&state.tablet_tools);
struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL); struct wlr_backend *wlr = wlr_backend_autocreate(display);
if (!wlr) { if (!wlr) {
exit(1); exit(1);
} }

View file

@ -249,7 +249,7 @@ int main(int argc, char *argv[]) {
wl_list_init(&state.touch_points); wl_list_init(&state.touch_points);
wl_list_init(&state.touch); wl_list_init(&state.touch);
struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL); struct wlr_backend *wlr = wlr_backend_autocreate(display);
if (!wlr) { if (!wlr) {
exit(1); exit(1);
} }

View file

@ -41,7 +41,7 @@ struct wlr_drm_fb {
}; };
bool init_drm_renderer(struct wlr_drm_backend *drm, bool init_drm_renderer(struct wlr_drm_backend *drm,
struct wlr_drm_renderer *renderer, wlr_renderer_create_func_t create_render); struct wlr_drm_renderer *renderer);
void finish_drm_renderer(struct wlr_drm_renderer *renderer); void finish_drm_renderer(struct wlr_drm_renderer *renderer);
bool drm_surface_make_current(struct wlr_drm_surface *surf, int *buffer_age); bool drm_surface_make_current(struct wlr_drm_surface *surf, int *buffer_age);

View file

@ -28,20 +28,12 @@ struct wlr_backend {
} events; } events;
}; };
typedef struct wlr_renderer *(*wlr_renderer_create_func_t)(struct wlr_egl *egl, EGLenum platform,
void *remote_display, EGLint *config_attribs, EGLint visual_id);
/** /**
* Automatically initializes the most suitable backend given the environment. * Automatically initializes the most suitable backend given the environment.
* Will always return a multibackend. The backend is created but not started. * Will always return a multibackend. The backend is created but not started.
* Returns NULL on failure. * Returns NULL on failure.
*
* The compositor can request to initialize the backend's renderer by setting
* the create_render_func. The callback must initialize the given wlr_egl and
* return a valid wlr_renderer, or NULL if it has failed to initiaze it.
* Pass NULL as create_renderer_func to use the backend's default renderer.
*/ */
struct wlr_backend *wlr_backend_autocreate(struct wl_display *display, struct wlr_backend *wlr_backend_autocreate(struct wl_display *display);
wlr_renderer_create_func_t create_renderer_func);
/** /**
* Start the backend. This may signal new_input or new_output immediately, but * Start the backend. This may signal new_input or new_output immediately, but
* may also wait until the display's event loop begins. Returns false on * may also wait until the display's event loop begins. Returns false on

View file

@ -23,8 +23,7 @@
*/ */
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
struct wlr_session *session, struct wlr_device *dev, struct wlr_session *session, struct wlr_device *dev,
struct wlr_backend *parent, struct wlr_backend *parent);
wlr_renderer_create_func_t create_renderer_func);
bool wlr_backend_is_drm(struct wlr_backend *backend); bool wlr_backend_is_drm(struct wlr_backend *backend);
bool wlr_output_is_drm(struct wlr_output *output); bool wlr_output_is_drm(struct wlr_output *output);

View file

@ -17,8 +17,7 @@
* Creates a headless backend. A headless backend has no outputs or inputs by * Creates a headless backend. A headless backend has no outputs or inputs by
* default. * default.
*/ */
struct wlr_backend *wlr_headless_backend_create(struct wl_display *display, struct wlr_backend *wlr_headless_backend_create(struct wl_display *display);
wlr_renderer_create_func_t create_renderer_func);
/** /**
* Creates a headless backend with an existing renderer. * Creates a headless backend with an existing renderer.
*/ */

View file

@ -16,7 +16,7 @@
* default) * default)
*/ */
struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
const char *remote, wlr_renderer_create_func_t create_renderer_func); const char *remote);
/** /**
* Returns the remote wl_display used by the Wayland backend. * Returns the remote wl_display used by the Wayland backend.

View file

@ -17,7 +17,7 @@
* to NULL for the default behaviour of XOpenDisplay. * to NULL for the default behaviour of XOpenDisplay.
*/ */
struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
const char *x11_display, wlr_renderer_create_func_t create_renderer_func); const char *x11_display);
/** /**
* Adds a new output to this backend. You may remove outputs by destroying them. * Adds a new output to this backend. You may remove outputs by destroying them.