Advertise zwp_linux_dmabuf_v1 so Mesa EGL clients stop using llvmpipe

- Add zwp_linux_dmabuf_v1 (v4 feedback names the render node). Only linear ARGB8888 and XRGB8888 are accepted, because the compositor reads a buffer by mapping its dma-buf.
- Bracket dma-buf reads with DMA_BUF_IOCTL_SYNC in the compositor and in the wasm host, so the CPU sees the GPU's finished writes.
- Keep every wl_surface.frame callback since the last commit instead of only the last one. Zed and Mesa's EGL queue several and wait on all of them.
- rs_capture maps a dma-buf afresh on each capture rather than using the pool cache, which could hand a later buffer an earlier buffer's pixels.
- Restart xdg-desktop-portal in the background once the compositor socket exists, so the restart no longer delays compositor startup by about 30 s.
This commit is contained in:
nandi committed 2026-11-30 11:49:48 -08:00
1 parent d81003f176
commit 51852f0dac
5 files changed
+366 -16

No files matched your search

+11
View File
@@ -288,6 +288,15 @@ int32_t mp_pwrite_bytes(int32_t fd, moonbit_bytes_t buf, int32_t len, int32_t of
return w < 0 ? -1 : (int32_t)w;
}
#include <sys/ioctl.h>
#include <linux/dma-buf.h>
/* Wait for the GPU to finish writing a dma-buf before the CPU reads it; harmless on shm files. */
static void dmabuf_sync(int fd, int start) {
struct dma_buf_sync sync = { .flags = (start ? DMA_BUF_SYNC_START : DMA_BUF_SYNC_END) | DMA_BUF_SYNC_READ };
ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync);
}
MOONBIT_FFI_EXPORT
moonbit_bytes_t mp_mmap_read(int32_t fd, int32_t size) {
if (fd < 0 || size <= 0) {
@@ -302,7 +311,9 @@ moonbit_bytes_t mp_mmap_read(int32_t fd, int32_t size) {
return moonbit_make_bytes_raw(0);
}
moonbit_bytes_t out = moonbit_make_bytes_raw(size);
dmabuf_sync(fd, 1);
memcpy(out, ptr, (size_t)size);
dmabuf_sync(fd, 0);
munmap(ptr, (size_t)size);
return out;
}