render: drop egl parameters from wlr_renderer_autocreate

This commit is contained in:
Simon Zeni 2021-01-13 22:49:07 -05:00 committed by Simon Ser
parent affc59454e
commit e128e6c08d
8 changed files with 35 additions and 15 deletions

View file

@ -29,8 +29,7 @@ bool init_drm_renderer(struct wlr_drm_backend *drm,
return false; return false;
} }
renderer->wlr_rend = wlr_renderer_autocreate(EGL_PLATFORM_GBM_KHR, renderer->wlr_rend = wlr_renderer_autocreate(&drm->backend);
renderer->gbm);
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");
goto error_gbm; goto error_gbm;

View file

@ -219,8 +219,7 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
goto error_dup; goto error_dup;
} }
struct wlr_renderer *renderer = wlr_renderer_autocreate( struct wlr_renderer *renderer = wlr_renderer_autocreate(&backend->backend);
EGL_PLATFORM_GBM_KHR, gbm_alloc->gbm_device);
if (!renderer) { if (!renderer) {
wlr_log(WLR_ERROR, "Failed to create renderer"); wlr_log(WLR_ERROR, "Failed to create renderer");
goto error_renderer; goto error_renderer;

View file

@ -437,8 +437,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
} }
wl->allocator = &gbm_alloc->base; wl->allocator = &gbm_alloc->base;
wl->renderer = wlr_renderer_autocreate(EGL_PLATFORM_GBM_KHR, wl->renderer = wlr_renderer_autocreate(&wl->backend);
gbm_alloc->gbm_device);
if (wl->renderer == NULL) { if (wl->renderer == NULL) {
wlr_log(WLR_ERROR, "Failed to create renderer"); wlr_log(WLR_ERROR, "Failed to create renderer");
goto error_allocator; goto error_allocator;

View file

@ -547,8 +547,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
} }
x11->allocator = &gbm_alloc->base; x11->allocator = &gbm_alloc->base;
x11->renderer = wlr_renderer_autocreate(EGL_PLATFORM_GBM_KHR, x11->renderer = wlr_renderer_autocreate(&x11->backend);
gbm_alloc->gbm_device);
if (x11->renderer == NULL) { if (x11->renderer == NULL) {
wlr_log(WLR_ERROR, "Failed to create renderer"); wlr_log(WLR_ERROR, "Failed to create renderer");
goto error_event; goto error_event;

View file

@ -41,6 +41,7 @@ struct wlr_egl {
EGLConfig config; // may be EGL_NO_CONFIG EGLConfig config; // may be EGL_NO_CONFIG
EGLContext context; EGLContext context;
EGLDeviceEXT device; // may be EGL_NO_DEVICE_EXT EGLDeviceEXT device; // may be EGL_NO_DEVICE_EXT
struct gbm_device *gbm_device;
struct { struct {
// Display extensions // Display extensions

View file

@ -11,6 +11,7 @@
#include <stdint.h> #include <stdint.h>
#include <wayland-server-protocol.h> #include <wayland-server-protocol.h>
#include <wlr/backend.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>
#include <wlr/render/wlr_texture.h> #include <wlr/render/wlr_texture.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
@ -33,8 +34,7 @@ struct wlr_renderer {
} events; } events;
}; };
struct wlr_renderer *wlr_renderer_autocreate(EGLenum platform, struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend);
void *remote_display);
void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height); void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height);
void wlr_renderer_end(struct wlr_renderer *r); void wlr_renderer_end(struct wlr_renderer *r);

View file

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <gbm.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wlr/util/region.h> #include <wlr/util/region.h>
@ -362,6 +363,10 @@ void wlr_egl_destroy(struct wlr_egl *egl) {
return; return;
} }
if (egl->gbm_device) {
gbm_device_destroy(egl->gbm_device);
}
wlr_drm_format_set_finish(&egl->dmabuf_render_formats); wlr_drm_format_set_finish(&egl->dmabuf_render_formats);
wlr_drm_format_set_finish(&egl->dmabuf_texture_formats); wlr_drm_format_set_finish(&egl->dmabuf_texture_formats);

View file

@ -1,6 +1,8 @@
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <gbm.h>
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h> #include <wlr/render/gles2.h>
#include <wlr/render/interface.h> #include <wlr/render/interface.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
@ -8,6 +10,7 @@
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "util/signal.h" #include "util/signal.h"
#include "render/wlr_renderer.h" #include "render/wlr_renderer.h"
#include "backend/backend.h"
void wlr_renderer_init(struct wlr_renderer *renderer, void wlr_renderer_init(struct wlr_renderer *renderer,
const struct wlr_renderer_impl *impl) { const struct wlr_renderer_impl *impl) {
@ -247,14 +250,29 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
return true; return true;
} }
struct wlr_renderer *wlr_renderer_autocreate(EGLenum platform, struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend) {
void *remote_display) { int fd = backend_get_drm_fd(backend);
struct wlr_egl *egl = wlr_egl_create(platform, remote_display, NULL); if (fd < 0) {
if (egl == NULL) { wlr_log(WLR_ERROR, "Failed to get DRM FD from backend");
wlr_log(WLR_ERROR, "Could not initialize EGL");
return NULL; return NULL;
} }
struct gbm_device *gbm_device = gbm_create_device(fd);
if (!gbm_device) {
wlr_log(WLR_ERROR, "Failed to create GBM device");
return NULL;
}
struct wlr_egl *egl = wlr_egl_create(EGL_PLATFORM_GBM_KHR, gbm_device,
NULL);
if (egl == NULL) {
wlr_log(WLR_ERROR, "Could not initialize EGL");
gbm_device_destroy(gbm_device);
return NULL;
}
egl->gbm_device = gbm_device;
struct wlr_renderer *renderer = wlr_gles2_renderer_create(egl); struct wlr_renderer *renderer = wlr_gles2_renderer_create(egl);
if (!renderer) { if (!renderer) {
wlr_log(WLR_ERROR, "Failed to create GLES2 renderer"); wlr_log(WLR_ERROR, "Failed to create GLES2 renderer");