feat(wayland/shm): impl shm ontop of dmabuf (again), and make the upload async

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-09-12 00:51:17 +02:00
parent c4ccda2118
commit 4bc71b01cb
3 changed files with 256 additions and 56 deletions

View File

@@ -23,6 +23,7 @@ use bevy_dmabuf::import::ImportedDmatexs;
use mint::Vector2;
use parking_lot::Mutex;
use std::sync::{Arc, OnceLock, Weak};
use tokio::task::LocalSet;
use waynest::{
server::{
Client, Dispatcher, Result,
@@ -370,6 +371,19 @@ impl WlSurface for Surface {
/// https://wayland.app/protocols/wayland#wl_surface:request:commit
#[tracing::instrument(level = "debug", skip_all)]
async fn commit(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
// we want the upload to complete before we give the image to bevy
let buffer_option = self
.state
.lock()
.pending
.buffer
.as_ref()
.map(|b| b.buffer.clone());
if let Some(buffer) = buffer_option {
tokio::task::spawn_blocking(move || buffer.on_commit())
.await
.unwrap();
}
self.state.lock().apply();
self.state.lock().pending.frame_callbacks.clear();
let current_state = self.current_state();