Fix Freeze: If the driver can't do LINEAR (NVIDIA), return false so the caller falls back to the SHM path

This commit is contained in:
entailz 2026-04-09 15:20:29 -07:00
parent 83c2145fb1
commit fa28415c7a

View file

@ -538,23 +538,16 @@ fn alloc_dmabuf_capture(
}
};
// RENDERING | SCANOUT: we need a buffer the compositor can both write into
// (screencopy) and display (layer surface attachment). LINEAR is intentionally
// omitted - drivers may not support it for a given format, causing EINVAL.
// Instead we read the actual modifier back from the allocated BO and forward
// it to zwp_linux_buffer_params_v1 so the compositor interprets the tiling
// correctly.
// RENDERING | LINEAR: LINEAR forces DRM_FORMAT_MOD_LINEAR (0) so that any
// compositor accepting zwp_linux_buffer_params_v1 will import the buffer.
let bo = match gbm.create_buffer_object::<()>(
offer.width,
offer.height,
fmt,
BufferObjectFlags::RENDERING | BufferObjectFlags::SCANOUT,
BufferObjectFlags::RENDERING | BufferObjectFlags::LINEAR,
) {
Ok(b) => b,
Err(e) => {
eprintln!("blast: freeze: dmabuf: GBM alloc: {e}");
return false;
}
Err(_) => return false,
};
let stride = bo.stride();
@ -569,7 +562,6 @@ fn alloc_dmabuf_capture(
return false;
}
};
let params = linux_dmabuf.create_params(qh, ());
params.add(dma_fd.as_fd(), 0, 0, stride, modifier_hi, modifier_lo);
// dma_fd drops here; the compositor has already dup'd it inside add().