mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
backend: stop using renderer to get the buffer type
When picking a format, the backend needs to know whether the buffers allocated by the allocator will be DMA-BUFs or shared memory. So far, the backend used the renderer's supported buffer types to guess this information. This is pretty fragile: renderers in general don't care about the SHM cap (they only care about the DATA_PTR one). Additionally, nothing stops a renderer from supporting both DMA-BUFs and shared memory, but this would break the backend's guess. Instead, use wlr_allocator.buffer_caps. This is more reliable since the buffers created with the allocator are guaranteed to have these caps.
This commit is contained in:
parent
766a24fa77
commit
ce3e819b33
2 changed files with 6 additions and 8 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "backend/backend.h"
|
||||
#include "backend/wayland.h"
|
||||
#include "render/allocator.h"
|
||||
#include "render/drm_format_set.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/wlr_renderer.h"
|
||||
|
@ -451,11 +452,10 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
|||
goto error_drm_fd;
|
||||
}
|
||||
|
||||
uint32_t caps = renderer_get_render_buffer_caps(renderer);
|
||||
const struct wlr_drm_format_set *remote_formats;
|
||||
if ((caps & WLR_BUFFER_CAP_DMABUF) && wl->zwp_linux_dmabuf_v1) {
|
||||
if ((allocator->buffer_caps & WLR_BUFFER_CAP_DMABUF) && wl->zwp_linux_dmabuf_v1) {
|
||||
remote_formats = &wl->linux_dmabuf_v1_formats;
|
||||
} else if ((caps & WLR_BUFFER_CAP_DATA_PTR) && wl->shm) {
|
||||
} else if ((allocator->buffer_caps & WLR_BUFFER_CAP_SHM) && wl->shm) {
|
||||
remote_formats = &wl->shm_formats;
|
||||
} else {
|
||||
wlr_log(WLR_ERROR,
|
||||
|
|
|
@ -32,9 +32,8 @@
|
|||
|
||||
#include "backend/backend.h"
|
||||
#include "backend/x11.h"
|
||||
#include "render/allocator.h"
|
||||
#include "render/drm_format_set.h"
|
||||
#include "render/gbm_allocator.h"
|
||||
#include "render/shm_allocator.h"
|
||||
#include "render/wlr_renderer.h"
|
||||
#include "types/wlr_buffer.h"
|
||||
#include "util/signal.h"
|
||||
|
@ -619,11 +618,10 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
|||
goto error_event;
|
||||
}
|
||||
|
||||
uint32_t caps = renderer_get_render_buffer_caps(renderer);
|
||||
const struct wlr_drm_format_set *pixmap_formats;
|
||||
if (x11->have_dri3 && (caps & WLR_BUFFER_CAP_DMABUF)) {
|
||||
if (x11->have_dri3 && (allocator->buffer_caps & WLR_BUFFER_CAP_DMABUF)) {
|
||||
pixmap_formats = &x11->dri3_formats;
|
||||
} else if (x11->have_shm && (caps & WLR_BUFFER_CAP_DATA_PTR)) {
|
||||
} else if (x11->have_shm && (allocator->buffer_caps & WLR_BUFFER_CAP_SHM)) {
|
||||
pixmap_formats = &x11->shm_formats;
|
||||
} else {
|
||||
wlr_log(WLR_ERROR,
|
||||
|
|
Loading…
Reference in a new issue