backend: replace get_buffer_caps hook with a struct field

Do the same as wlr_renderer: the supported buffer capabilities are
static for the lifetime of the backend.
This commit is contained in:
Simon Ser 2024-10-29 19:18:18 +01:00 committed by Kirill Primak
parent 9fdffba170
commit b908d865b1
14 changed files with 44 additions and 87 deletions

View file

@ -2,13 +2,13 @@
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <wlr/backend.h>
#include <wlr/config.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/render/allocator.h>
#include <wlr/util/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "backend/backend.h"
#include "render/allocator/drm_dumb.h"
#include "render/allocator/shm.h"
#include "render/wlr_renderer.h"
@ -96,7 +96,7 @@ static int reopen_drm_node(int drm_fd, bool allow_render_node) {
struct wlr_allocator *wlr_allocator_autocreate(struct wlr_backend *backend,
struct wlr_renderer *renderer) {
uint32_t backend_caps = backend_get_buffer_caps(backend);
uint32_t backend_caps = backend->buffer_caps;
uint32_t renderer_caps = renderer->render_buffer_caps;
// Note, drm_fd may be negative if unavailable

View file

@ -3,6 +3,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <wlr/backend.h>
#include <wlr/render/interface.h>
#include <wlr/render/pixman.h>
#include <wlr/render/wlr_renderer.h>
@ -24,7 +25,6 @@
#include <wlr/render/vulkan.h>
#endif // WLR_HAS_VULKAN_RENDERER
#include "backend/backend.h"
#include "render/pixel_format.h"
#include "render/wlr_renderer.h"
#include "util/env.h"
@ -180,8 +180,7 @@ static bool open_preferred_drm_fd(struct wlr_backend *backend, int *drm_fd_ptr,
// If the backend hasn't picked a DRM FD, but accepts DMA-BUFs, pick an
// arbitrary render node
uint32_t backend_caps = backend_get_buffer_caps(backend);
if (backend_caps & WLR_BUFFER_CAP_DMABUF) {
if (backend->buffer_caps & WLR_BUFFER_CAP_DMABUF) {
int drm_fd = open_drm_render_node();
if (drm_fd < 0) {
return false;