From ebef710746a0ba5b116a44035959fae9ca8232b6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 21 Mar 2024 12:28:10 +0100 Subject: [PATCH] renderer: replace get_render_buffer_caps() with struct field --- include/render/wlr_renderer.h | 6 ------ include/wlr/render/interface.h | 3 +-- include/wlr/render/wlr_renderer.h | 4 ++++ render/allocator/allocator.c | 2 +- render/gles2/renderer.c | 7 +------ render/pixman/renderer.c | 7 +------ render/vulkan/renderer.c | 7 +------ render/wlr_renderer.c | 9 +++------ types/output/render.c | 2 +- 9 files changed, 13 insertions(+), 34 deletions(-) diff --git a/include/render/wlr_renderer.h b/include/render/wlr_renderer.h index a8777bc0..d9823dc8 100644 --- a/include/render/wlr_renderer.h +++ b/include/render/wlr_renderer.h @@ -13,11 +13,5 @@ struct wlr_renderer *renderer_autocreate_with_drm_fd(int drm_fd); */ const struct wlr_drm_format_set *wlr_renderer_get_render_formats( struct wlr_renderer *renderer); -/** - * Get the supported buffer capabilities. - * - * This functions returns a bitfield of supported wlr_buffer_cap. - */ -uint32_t renderer_get_render_buffer_caps(struct wlr_renderer *renderer); #endif diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index b6e424ab..89f6de97 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -26,7 +26,6 @@ struct wlr_renderer_impl { struct wlr_renderer *renderer); void (*destroy)(struct wlr_renderer *renderer); int (*get_drm_fd)(struct wlr_renderer *renderer); - uint32_t (*get_render_buffer_caps)(struct wlr_renderer *renderer); struct wlr_texture *(*texture_from_buffer)(struct wlr_renderer *renderer, struct wlr_buffer *buffer); struct wlr_render_pass *(*begin_buffer_pass)(struct wlr_renderer *renderer, @@ -35,7 +34,7 @@ struct wlr_renderer_impl { }; void wlr_renderer_init(struct wlr_renderer *renderer, - const struct wlr_renderer_impl *impl); + const struct wlr_renderer_impl *impl, uint32_t render_buffer_caps); struct wlr_texture_impl { bool (*update_from_buffer)(struct wlr_texture *texture, diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h index fb6d62a3..62da0761 100644 --- a/include/wlr/render/wlr_renderer.h +++ b/include/wlr/render/wlr_renderer.h @@ -26,6 +26,10 @@ struct wlr_fbox; * A renderer for basic 2D operations. */ struct wlr_renderer { + // Capabilities required for the buffer used as a render target (bitmask of + // enum wlr_buffer_cap) + uint32_t render_buffer_caps; + struct { struct wl_signal destroy; /** diff --git a/render/allocator/allocator.c b/render/allocator/allocator.c index 639b52be..27b08fc8 100644 --- a/render/allocator/allocator.c +++ b/render/allocator/allocator.c @@ -94,7 +94,7 @@ static int reopen_drm_node(int drm_fd, bool allow_render_node) { struct wlr_allocator *allocator_autocreate_with_drm_fd( uint32_t backend_caps, struct wlr_renderer *renderer, int drm_fd) { - uint32_t renderer_caps = renderer_get_render_buffer_caps(renderer); + uint32_t renderer_caps = renderer->render_buffer_caps; struct wlr_allocator *alloc = NULL; diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index acdc7615..7bb9cf34 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -194,10 +194,6 @@ static int gles2_get_drm_fd(struct wlr_renderer *wlr_renderer) { return renderer->drm_fd; } -static uint32_t gles2_get_render_buffer_caps(struct wlr_renderer *wlr_renderer) { - return WLR_BUFFER_CAP_DMABUF; -} - struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *wlr_renderer) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); @@ -361,7 +357,6 @@ static const struct wlr_renderer_impl renderer_impl = { .get_texture_formats = gles2_get_texture_formats, .get_render_formats = gles2_get_render_formats, .get_drm_fd = gles2_get_drm_fd, - .get_render_buffer_caps = gles2_get_render_buffer_caps, .texture_from_buffer = gles2_texture_from_buffer, .begin_buffer_pass = gles2_begin_buffer_pass, .render_timer_create = gles2_render_timer_create, @@ -530,7 +525,7 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) { if (renderer == NULL) { return NULL; } - wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl); + wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl, WLR_BUFFER_CAP_DMABUF); wl_list_init(&renderer->buffers); wl_list_init(&renderer->textures); diff --git a/render/pixman/renderer.c b/render/pixman/renderer.c index 927906aa..552c9bf9 100644 --- a/render/pixman/renderer.c +++ b/render/pixman/renderer.c @@ -292,10 +292,6 @@ static void pixman_destroy(struct wlr_renderer *wlr_renderer) { free(renderer); } -static uint32_t pixman_get_render_buffer_caps(struct wlr_renderer *renderer) { - return WLR_BUFFER_CAP_DATA_PTR; -} - static struct wlr_render_pass *pixman_begin_buffer_pass(struct wlr_renderer *wlr_renderer, struct wlr_buffer *wlr_buffer, const struct wlr_buffer_pass_options *options) { struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer); @@ -320,7 +316,6 @@ static const struct wlr_renderer_impl renderer_impl = { .get_render_formats = pixman_get_render_formats, .texture_from_buffer = pixman_texture_from_buffer, .destroy = pixman_destroy, - .get_render_buffer_caps = pixman_get_render_buffer_caps, .begin_buffer_pass = pixman_begin_buffer_pass, }; @@ -331,7 +326,7 @@ struct wlr_renderer *wlr_pixman_renderer_create(void) { } wlr_log(WLR_INFO, "Creating pixman renderer"); - wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl); + wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl, WLR_BUFFER_CAP_DATA_PTR); wl_list_init(&renderer->buffers); wl_list_init(&renderer->textures); diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c index 17a4b47d..ffb685f6 100644 --- a/render/vulkan/renderer.c +++ b/render/vulkan/renderer.c @@ -1299,10 +1299,6 @@ static int vulkan_get_drm_fd(struct wlr_renderer *wlr_renderer) { return renderer->dev->drm_fd; } -static uint32_t vulkan_get_render_buffer_caps(struct wlr_renderer *wlr_renderer) { - return WLR_BUFFER_CAP_DMABUF; -} - static struct wlr_render_pass *vulkan_begin_buffer_pass(struct wlr_renderer *wlr_renderer, struct wlr_buffer *buffer, const struct wlr_buffer_pass_options *options) { struct wlr_vk_renderer *renderer = vulkan_get_renderer(wlr_renderer); @@ -1327,7 +1323,6 @@ static const struct wlr_renderer_impl renderer_impl = { .get_render_formats = vulkan_get_render_formats, .destroy = vulkan_destroy, .get_drm_fd = vulkan_get_drm_fd, - .get_render_buffer_caps = vulkan_get_render_buffer_caps, .texture_from_buffer = vulkan_texture_from_buffer, .begin_buffer_pass = vulkan_begin_buffer_pass, }; @@ -2151,7 +2146,7 @@ struct wlr_renderer *vulkan_renderer_create_for_device(struct wlr_vk_device *dev } renderer->dev = dev; - wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl); + wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl, WLR_BUFFER_CAP_DMABUF); wl_list_init(&renderer->stage.buffers); wl_list_init(&renderer->foreign_textures); wl_list_init(&renderer->textures); diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index 0b120ea5..590372eb 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -30,13 +30,14 @@ #include "util/env.h" void wlr_renderer_init(struct wlr_renderer *renderer, - const struct wlr_renderer_impl *impl) { + const struct wlr_renderer_impl *impl, uint32_t render_buffer_caps) { assert(impl->begin_buffer_pass); assert(impl->get_texture_formats); - assert(impl->get_render_buffer_caps); + assert(render_buffer_caps != 0); *renderer = (struct wlr_renderer){ .impl = impl, + .render_buffer_caps = render_buffer_caps, }; wl_signal_init(&renderer->events.destroy); @@ -70,10 +71,6 @@ const struct wlr_drm_format_set *wlr_renderer_get_render_formats( return r->impl->get_render_formats(r); } -uint32_t renderer_get_render_buffer_caps(struct wlr_renderer *r) { - return r->impl->get_render_buffer_caps(r); -} - bool wlr_renderer_init_wl_shm(struct wlr_renderer *r, struct wl_display *wl_display) { return wlr_shm_create_with_renderer(wl_display, 1, r) != NULL; diff --git a/types/output/render.c b/types/output/render.c index c5e86e1c..709646a1 100644 --- a/types/output/render.c +++ b/types/output/render.c @@ -18,7 +18,7 @@ bool wlr_output_init_render(struct wlr_output *output, assert(allocator != NULL && renderer != NULL); uint32_t backend_caps = backend_get_buffer_caps(output->backend); - uint32_t renderer_caps = renderer_get_render_buffer_caps(renderer); + uint32_t renderer_caps = renderer->render_buffer_caps; if (!(backend_caps & allocator->buffer_caps)) { wlr_log(WLR_ERROR, "output backend and allocator buffer capabilities "