refactor(wayland): reenable dmabuf

This commit is contained in:
Nova
2025-07-28 14:55:43 -07:00
parent 28613f8585
commit c6754bd689
3 changed files with 18 additions and 25 deletions

View File

@@ -77,14 +77,14 @@ impl Registry {
) )
.await?; .await?;
// self.global( self.global(
// client, client,
// sender_id, sender_id,
// RegistryGlobals::DMABUF, RegistryGlobals::DMABUF,
// crate::wayland::dmabuf::Dmabuf::INTERFACE.to_string(), crate::wayland::dmabuf::Dmabuf::INTERFACE.to_string(),
// Dmabuf::VERSION, Dmabuf::VERSION,
// ) )
// .await?; .await?;
Ok(()) Ok(())
} }

View File

@@ -1,5 +1,5 @@
use super::buffer_params::BufferParams; use super::buffer_params::BufferParams;
use crate::wayland::{MessageSink, RENDER_DEVICE}; use crate::wayland::RENDER_DEVICE;
use bevy::{ use bevy::{
asset::{Assets, Handle}, asset::{Assets, Handle},
image::Image, image::Image,
@@ -17,19 +17,17 @@ use waynest::server::protocol::stable::linux_dmabuf_v1::zwp_linux_buffer_params_
/// Parameters for a shared memory buffer /// Parameters for a shared memory buffer
pub struct DmabufBacking { pub struct DmabufBacking {
message_sink: Option<MessageSink>,
params: Arc<BufferParams>, params: Arc<BufferParams>,
size: Vector2<u32>, size: Vector2<u32>,
format: DrmFourcc, format: DrmFourcc,
_flags: Flags, _flags: Flags,
tex: OnceLock<Handle<Image>>, tex: OnceLock<Handle<Image>>,
// pending_imported_dmatex: Mutex<Option<ImportedTexture>>, pending_imported_dmatex: Mutex<Option<ImportedTexture>>,
} }
impl std::fmt::Debug for DmabufBacking { impl std::fmt::Debug for DmabufBacking {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("DmabufBacking") f.debug_struct("DmabufBacking")
.field("message_sink", &self.message_sink)
.field("params", &self.params) .field("params", &self.params)
.field("size", &self.size) .field("size", &self.size)
.field("format", &self.format) .field("format", &self.format)
@@ -43,7 +41,6 @@ impl DmabufBacking {
#[tracing::instrument(level = "debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn new( pub fn new(
params: Arc<BufferParams>, params: Arc<BufferParams>,
message_sink: Option<MessageSink>,
size: Vector2<u32>, size: Vector2<u32>,
format: DrmFourcc, format: DrmFourcc,
flags: Flags, flags: Flags,
@@ -68,12 +65,11 @@ impl DmabufBacking {
Ok(Self { Ok(Self {
params, params,
message_sink,
size, size,
format, format,
_flags: flags, _flags: flags,
tex: OnceLock::new(), tex: OnceLock::new(),
// pending_imported_dmatex: Mutex::new(Some(imported_tex)), pending_imported_dmatex: Mutex::new(Some(imported_tex)),
}) })
} }
@@ -84,14 +80,13 @@ impl DmabufBacking {
images: &mut Assets<Image>, images: &mut Assets<Image>,
) -> Option<Handle<Image>> { ) -> Option<Handle<Image>> {
info!("updating dmabuf tex"); info!("updating dmabuf tex");
// self.pending_imported_dmatex self.pending_imported_dmatex
// .lock() .lock()
// .take() .take()
// .map(|tex| dmatexes.insert_imported_dmatex(images, tex)) .map(|tex| dmatexes.insert_imported_dmatex(images, tex))
// .inspect(|handle| { .inspect(|handle| {
// _ = self.tex.set(handle.clone()); _ = self.tex.set(handle.clone());
// }) })
None
} }
pub fn is_transparent(&self) -> bool { pub fn is_transparent(&self) -> bool {

View File

@@ -106,7 +106,6 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
let size = [width as u32, height as u32].into(); let size = [width as u32, height as u32].into();
let buffer = DmabufBacking::new( let buffer = DmabufBacking::new(
client.get::<Self>(self.id).unwrap(), client.get::<Self>(self.id).unwrap(),
Some(client.display().message_sink.clone()),
size, size,
DrmFourcc::try_from(format).unwrap(), DrmFourcc::try_from(format).unwrap(),
flags, flags,
@@ -141,7 +140,6 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
// Create the buffer with DMA-BUF backing using self as the backing // Create the buffer with DMA-BUF backing using self as the backing
_ = DmabufBacking::new( _ = DmabufBacking::new(
client.get::<Self>(self.id).unwrap(), client.get::<Self>(self.id).unwrap(),
None,
[width as u32, height as u32].into(), [width as u32, height as u32].into(),
DrmFourcc::try_from(format).unwrap(), DrmFourcc::try_from(format).unwrap(),
flags, flags,