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:
1 parent
d81003f176
commit
51852f0dac
5 files changed
+366
-16
No files matched your search
@@ -498,3 +498,61 @@ test "swapchain pools sent in one message all keep their fds, and a bare commit
|
||||
@sys.close_fd(c.fd)
|
||||
comp.close()
|
||||
}
|
||||
|
||||
///|
|
||||
test "a linear zwp_linux_dmabuf_v1 buffer is shown like an shm one" {
|
||||
// Without this global Mesa's Wayland EGL falls back to llvmpipe and Zed warns about it.
|
||||
let socket_path = "/tmp/wayland-moon-dmabuf-" + @sys.getpid().to_string() + ".sock"
|
||||
let theme = @scene.ThemeTokens::moon_night()
|
||||
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
|
||||
let (c, _shm, surf, xdg, _tl, _deco) = open_and_configure_client(
|
||||
comp, socket_path, "Zed", "dev.zed.Zed",
|
||||
)
|
||||
match c.configure_serial {
|
||||
Some(ser) => {
|
||||
let ack = @wayland.WireWriter::new()
|
||||
ack.u32(ser)
|
||||
c.send(ack.finish_msg(xdg, 4U))
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
assert_true(c.globals.contains("zwp_linux_dmabuf_v1"))
|
||||
let dmabuf = bind_global(c, 2U, "zwp_linux_dmabuf_v1", 4U)
|
||||
let params = c.alloc_id()
|
||||
let cp = @wayland.WireWriter::new()
|
||||
cp.u32(params)
|
||||
c.send(cp.finish_msg(dmabuf, 1U))
|
||||
let w = c.configured_w
|
||||
let h = c.configured_h
|
||||
let fd = solid_memfd(w, h, b'\x00', b'\xff', b'\x00')
|
||||
// add(fd, plane 0, offset 0, stride, modifier LINEAR) and create_immed in one flush.
|
||||
let msg : Array[Byte] = []
|
||||
let add = @wayland.WireWriter::new()
|
||||
add.u32(0U)
|
||||
add.u32(0U)
|
||||
add.u32((w * 4).reinterpret_as_uint())
|
||||
add.u32(0U)
|
||||
add.u32(0U)
|
||||
for b in add.finish_msg(params, 1U) {
|
||||
msg.push(b)
|
||||
}
|
||||
let buf = c.alloc_id()
|
||||
let ci = @wayland.WireWriter::new()
|
||||
ci.u32(buf)
|
||||
ci.i32(w)
|
||||
ci.i32(h)
|
||||
ci.u32(0x34325241U)
|
||||
ci.u32(0U)
|
||||
for b in ci.finish_msg(params, 3U) {
|
||||
msg.push(b)
|
||||
}
|
||||
assert_true(@sys.sendmsg_fds(c.fd, Bytes::from_array(msg), [fd]) > 0)
|
||||
let win = comp.windows.get(1UL).unwrap()
|
||||
let cx = win.geometry.x + win.geometry.w / 2
|
||||
let cy = win.geometry.y + win.geometry.h / 2
|
||||
attach_commit(comp, c, surf, Some(buf))
|
||||
assert_eq(comp.compose_frame().pixel(cx, cy), Some(@scene.Rgba::new(0, 0xff, 0, 0xff)))
|
||||
@sys.close_fd(fd)
|
||||
@sys.close_fd(c.fd)
|
||||
comp.close()
|
||||
}
|
||||
Reference in new issue
Block a user