feat(wayland): implement infrastructure for async dmatex importing
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
21
Cargo.lock
generated
21
Cargo.lock
generated
@@ -591,9 +591,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy-dmabuf"
|
name = "bevy-dmabuf"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "321fa0b7c6b02ac16d5f85f1703b9d4a9a50e2ad3f9adae3b52138868a2747e8"
|
checksum = "f4af0a7897ed821f1e8fd5e1782711b8b54722f49a9398c9713f7f72ec2c5c0e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ash",
|
"ash",
|
||||||
"bevy",
|
"bevy",
|
||||||
@@ -1594,7 +1594,7 @@ dependencies = [
|
|||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
"itertools 0.13.0",
|
"itertools 0.11.0",
|
||||||
"log",
|
"log",
|
||||||
"prettyplease",
|
"prettyplease",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -1614,7 +1614,7 @@ dependencies = [
|
|||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
"itertools 0.13.0",
|
"itertools 0.11.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"regex",
|
"regex",
|
||||||
@@ -3314,15 +3314,6 @@ dependencies = [
|
|||||||
"either",
|
"either",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itertools"
|
|
||||||
version = "0.13.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
@@ -3481,7 +3472,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
|
checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.48.5",
|
"windows-targets 0.53.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -6034,7 +6025,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "5f9612d9503675b07b244922ea6f6f3cdd88c43add1b3498084613fc88cdf69d"
|
checksum = "5f9612d9503675b07b244922ea6f6f3cdd88c43add1b3498084613fc88cdf69d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"windows-targets 0.48.5",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ use bevy::{
|
|||||||
};
|
};
|
||||||
use bevy_dmabuf::{
|
use bevy_dmabuf::{
|
||||||
dmatex::{Dmatex, DmatexPlane, Resolution},
|
dmatex::{Dmatex, DmatexPlane, Resolution},
|
||||||
import::ImportedDmatexs,
|
import::{ImportedDmatexs, ImportedTexture},
|
||||||
};
|
};
|
||||||
use drm_fourcc::DrmFourcc;
|
use drm_fourcc::DrmFourcc;
|
||||||
use mint::Vector2;
|
use mint::Vector2;
|
||||||
|
use parking_lot::Mutex;
|
||||||
use std::sync::{Arc, OnceLock};
|
use std::sync::{Arc, OnceLock};
|
||||||
use waynest::server::protocol::stable::linux_dmabuf_v1::zwp_linux_buffer_params_v1::Flags;
|
use waynest::server::protocol::stable::linux_dmabuf_v1::zwp_linux_buffer_params_v1::Flags;
|
||||||
|
|
||||||
/// Parameters for a shared memory buffer
|
/// Parameters for a shared memory buffer
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct DmabufBacking {
|
pub struct DmabufBacking {
|
||||||
message_sink: Option<MessageSink>,
|
message_sink: Option<MessageSink>,
|
||||||
params: Arc<BufferParams>,
|
params: Arc<BufferParams>,
|
||||||
@@ -22,6 +22,20 @@ pub struct DmabufBacking {
|
|||||||
format: DrmFourcc,
|
format: DrmFourcc,
|
||||||
_flags: Flags,
|
_flags: Flags,
|
||||||
tex: OnceLock<Handle<Image>>,
|
tex: OnceLock<Handle<Image>>,
|
||||||
|
pending_imported_dmatex: Mutex<Option<ImportedTexture>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for DmabufBacking {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("DmabufBacking")
|
||||||
|
.field("message_sink", &self.message_sink)
|
||||||
|
.field("params", &self.params)
|
||||||
|
.field("size", &self.size)
|
||||||
|
.field("format", &self.format)
|
||||||
|
.field("_flags", &self._flags)
|
||||||
|
.field("tex", &self.tex)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DmabufBacking {
|
impl DmabufBacking {
|
||||||
@@ -40,6 +54,7 @@ impl DmabufBacking {
|
|||||||
format,
|
format,
|
||||||
_flags: flags,
|
_flags: flags,
|
||||||
tex: OnceLock::new(),
|
tex: OnceLock::new(),
|
||||||
|
pending_imported_dmatex: Mutex::new(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,12 +111,16 @@ impl DmabufBacking {
|
|||||||
images: &mut Assets<Image>,
|
images: &mut Assets<Image>,
|
||||||
buffer: Arc<Buffer>,
|
buffer: Arc<Buffer>,
|
||||||
) -> Option<Handle<Image>> {
|
) -> Option<Handle<Image>> {
|
||||||
if self.tex.get().is_none()
|
self.pending_imported_dmatex
|
||||||
&& let Some(dmatex) = self.import_dmabuf(dmatexes, images, buffer)
|
.lock()
|
||||||
{
|
.take()
|
||||||
let _ = self.tex.set(dmatex);
|
.map(|tex| dmatexes.insert_imported_dmatex(images, tex))
|
||||||
}
|
// if self.tex.get().is_none()
|
||||||
self.tex.get().cloned()
|
// && let Some(dmatex) = self.import_dmabuf(dmatexes, images, buffer)
|
||||||
|
// {
|
||||||
|
// let _ = self.tex.set(dmatex);
|
||||||
|
// }
|
||||||
|
// self.tex.get().cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_transparent(&self) -> bool {
|
pub fn is_transparent(&self) -> bool {
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use bevy::app::{App, Plugin, Update};
|
use bevy::app::{App, Plugin, Update};
|
||||||
|
use bevy::ecs::schedule::IntoScheduleConfigs;
|
||||||
use bevy::ecs::system::{Res, ResMut};
|
use bevy::ecs::system::{Res, ResMut};
|
||||||
|
use bevy::render::renderer::RenderDevice;
|
||||||
|
use bevy::render::{Render, RenderApp};
|
||||||
use bevy::{asset::Assets, ecs::resource::Resource, image::Image};
|
use bevy::{asset::Assets, ecs::resource::Resource, image::Image};
|
||||||
use bevy_dmabuf::import::ImportedDmatexs;
|
use bevy_dmabuf::import::ImportedDmatexs;
|
||||||
use cluFlock::ToFlock;
|
use cluFlock::ToFlock;
|
||||||
@@ -286,14 +289,24 @@ impl Drop for Wayland {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RENDER_DEVICE: OnceLock<RenderDevice> = OnceLock::new();
|
||||||
|
|
||||||
pub struct WaylandPlugin;
|
pub struct WaylandPlugin;
|
||||||
impl Plugin for WaylandPlugin {
|
impl Plugin for WaylandPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(PreFrameWait, early_frame);
|
app.add_systems(PreFrameWait, early_frame);
|
||||||
app.add_systems(Update, update_graphics);
|
app.add_systems(Update, update_graphics);
|
||||||
|
app.sub_app_mut(RenderApp).add_systems(
|
||||||
|
Render,
|
||||||
|
init_render_device.run_if(|| RENDER_DEVICE.get().is_none()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn init_render_device(dev: Res<RenderDevice>) {
|
||||||
|
_ = RENDER_DEVICE.set(dev.clone());
|
||||||
|
}
|
||||||
|
|
||||||
fn early_frame() {
|
fn early_frame() {
|
||||||
info!("test");
|
info!("test");
|
||||||
for buffer in WL_BUFFER_REGISTRY.get_valid_contents() {
|
for buffer in WL_BUFFER_REGISTRY.get_valid_contents() {
|
||||||
|
|||||||
Reference in New Issue
Block a user