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 // RENDERING | LINEAR: LINEAR forces DRM_FORMAT_MOD_LINEAR (0) so that any
// (screencopy) and display (layer surface attachment). LINEAR is intentionally // compositor accepting zwp_linux_buffer_params_v1 will import the buffer.
// 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.
let bo = match gbm.create_buffer_object::<()>( let bo = match gbm.create_buffer_object::<()>(
offer.width, offer.width,
offer.height, offer.height,
fmt, fmt,
BufferObjectFlags::RENDERING | BufferObjectFlags::SCANOUT, BufferObjectFlags::RENDERING | BufferObjectFlags::LINEAR,
) { ) {
Ok(b) => b, Ok(b) => b,
Err(e) => { Err(_) => return false,
eprintln!("blast: freeze: dmabuf: GBM alloc: {e}");
return false;
}
}; };
let stride = bo.stride(); let stride = bo.stride();
@ -569,7 +562,6 @@ fn alloc_dmabuf_capture(
return false; return false;
} }
}; };
let params = linux_dmabuf.create_params(qh, ()); let params = linux_dmabuf.create_params(qh, ());
params.add(dma_fd.as_fd(), 0, 0, stride, modifier_hi, modifier_lo); 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(). // dma_fd drops here; the compositor has already dup'd it inside add().