fix(wayland): fix function instrumentation

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-07-17 17:01:40 +02:00
parent 6cb46cf4f3
commit 66a3ae22cc
8 changed files with 39 additions and 38 deletions

2
Cargo.lock generated
View File

@@ -1410,11 +1410,13 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b674242641cab680688fc3b850243b351c1af49d4f3417a576debd6cca8dcf5" checksum = "5b674242641cab680688fc3b850243b351c1af49d4f3417a576debd6cca8dcf5"
dependencies = [ dependencies = [
"async-channel",
"async-executor", "async-executor",
"async-task", "async-task",
"atomic-waker", "atomic-waker",
"bevy_platform", "bevy_platform",
"cfg-if", "cfg-if",
"concurrent-queue",
"crossbeam-queue", "crossbeam-queue",
"derive_more", "derive_more",
"futures-channel", "futures-channel",

View File

@@ -103,6 +103,7 @@ bevy = { version = "0.16", default-features = false, features = [
"hdr", "hdr",
"jpeg", "jpeg",
"tonemapping_luts", "tonemapping_luts",
"multi_threaded",
] } ] }
bevy_mod_xr = "0.3" bevy_mod_xr = "0.3"
bevy_mod_openxr = "0.3" bevy_mod_openxr = "0.3"

View File

@@ -40,7 +40,7 @@ pub struct Buffer {
} }
impl Buffer { impl Buffer {
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn new(client: &mut Client, id: ObjectId, backing: BufferBacking) -> Arc<Self> { pub fn new(client: &mut Client, id: ObjectId, backing: BufferBacking) -> Arc<Self> {
let buffer = client.insert( let buffer = client.insert(
id, id,
@@ -56,7 +56,7 @@ impl Buffer {
} }
/// Returns the tex if it was updated /// Returns the tex if it was updated
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn update_tex( pub fn update_tex(
&self, &self,
dmatexes: &ImportedDmatexs, dmatexes: &ImportedDmatexs,

View File

@@ -18,7 +18,7 @@ pub struct ShmPool {
} }
impl ShmPool { impl ShmPool {
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn new(fd: OwnedFd, size: i32) -> Result<Self> { pub fn new(fd: OwnedFd, size: i32) -> Result<Self> {
let map = unsafe { let map = unsafe {
MmapOptions::new() MmapOptions::new()
@@ -31,7 +31,7 @@ impl ShmPool {
}) })
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn data_lock(&self) -> MappedMutexGuard<RawMutex, [u8]> { pub fn data_lock(&self) -> MappedMutexGuard<RawMutex, [u8]> {
MutexGuard::map(self.inner.lock(), |i| i.as_mut()) MutexGuard::map(self.inner.lock(), |i| i.as_mut())
} }
@@ -39,7 +39,7 @@ impl ShmPool {
impl WlShmPool for ShmPool { impl WlShmPool for ShmPool {
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:create_buffer /// https://wayland.app/protocols/wayland#wl_shm_pool:request:create_buffer
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn create_buffer( async fn create_buffer(
&self, &self,
client: &mut Client, client: &mut Client,
@@ -64,7 +64,7 @@ impl WlShmPool for ShmPool {
} }
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:resize /// https://wayland.app/protocols/wayland#wl_shm_pool:request:resize
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn resize(&self, _client: &mut Client, _sender_id: ObjectId, size: i32) -> Result<()> { async fn resize(&self, _client: &mut Client, _sender_id: ObjectId, size: i32) -> Result<()> {
let mut inner = self.inner.lock(); let mut inner = self.inner.lock();
unsafe { inner.remap(size as usize, RemapOptions::new().may_move(true))? }; unsafe { inner.remap(size as usize, RemapOptions::new().may_move(true))? };
@@ -72,7 +72,7 @@ impl WlShmPool for ShmPool {
} }
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:destroy /// https://wayland.app/protocols/wayland#wl_shm_pool:request:destroy
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> { async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
Ok(()) Ok(())
} }

View File

@@ -85,7 +85,7 @@ impl std::fmt::Debug for Surface {
} }
} }
impl Surface { impl Surface {
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn new(client: &Client, id: ObjectId) -> Self { pub fn new(client: &Client, id: ObjectId) -> Self {
Surface { Surface {
id, id,
@@ -99,12 +99,12 @@ impl Surface {
} }
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn pending_state(&self) -> parking_lot::MutexGuard<'_, DoubleBuffer<SurfaceState>> { pub fn pending_state(&self) -> parking_lot::MutexGuard<'_, DoubleBuffer<SurfaceState>> {
self.state.lock() self.state.lock()
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn add_commit_handler<F: Fn(&Surface, &SurfaceState) -> bool + Send + Sync + 'static>( pub fn add_commit_handler<F: Fn(&Surface, &SurfaceState) -> bool + Send + Sync + 'static>(
&self, &self,
handler: F, handler: F,
@@ -113,7 +113,7 @@ impl Surface {
handlers.push(Box::new(handler)); handlers.push(Box::new(handler));
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn update_graphics( pub fn update_graphics(
&self, &self,
dmatexes: &ImportedDmatexs, dmatexes: &ImportedDmatexs,
@@ -160,13 +160,13 @@ impl Surface {
let _ = state_lock.current().clean_lock.set(()); let _ = state_lock.current().clean_lock.set(());
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn apply_material(&self, model_part: &Arc<ModelPart>) { pub fn apply_material(&self, model_part: &Arc<ModelPart>) {
// tracing::info!("uwu applying material"); // tracing::info!("uwu applying material");
self.pending_material_applications.add_raw(model_part) self.pending_material_applications.add_raw(model_part)
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
fn apply_surface_materials(&self) { fn apply_surface_materials(&self) {
let Some(mat) = self.material.get() else { let Some(mat) = self.material.get() else {
return; return;
@@ -177,15 +177,15 @@ impl Surface {
} }
self.pending_material_applications.clear(); self.pending_material_applications.clear();
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
fn mark_dirty(&self) { fn mark_dirty(&self) {
self.state.lock().pending.clean_lock = Default::default(); self.state.lock().pending.clean_lock = Default::default();
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn current_state(&self) -> SurfaceState { pub fn current_state(&self) -> SurfaceState {
self.state.lock().current().clone() self.state.lock().current().clone()
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn frame_event(&self) { pub fn frame_event(&self) {
if let Some(callback_obj) = self.frame_callback_object.lock().take() { if let Some(callback_obj) = self.frame_callback_object.lock().take() {
let _ = self.message_sink.send(Message::Frame(callback_obj)); let _ = self.message_sink.send(Message::Frame(callback_obj));
@@ -222,7 +222,7 @@ impl Surface {
} }
impl WlSurface for Surface { impl WlSurface for Surface {
/// https://wayland.app/protocols/wayland#wl_surface:request:attach /// https://wayland.app/protocols/wayland#wl_surface:request:attach
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn attach( async fn attach(
&self, &self,
client: &mut Client, client: &mut Client,
@@ -236,7 +236,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:damage /// https://wayland.app/protocols/wayland#wl_surface:request:damage
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn damage( async fn damage(
&self, &self,
_client: &mut Client, _client: &mut Client,
@@ -252,7 +252,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:frame /// https://wayland.app/protocols/wayland#wl_surface:request:frame
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn frame( async fn frame(
&self, &self,
client: &mut Client, client: &mut Client,
@@ -265,7 +265,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:set_opaque_region /// https://wayland.app/protocols/wayland#wl_surface:request:set_opaque_region
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn set_opaque_region( async fn set_opaque_region(
&self, &self,
_client: &mut Client, _client: &mut Client,
@@ -277,7 +277,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:set_input_region /// https://wayland.app/protocols/wayland#wl_surface:request:set_input_region
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn set_input_region( async fn set_input_region(
&self, &self,
_client: &mut Client, _client: &mut Client,
@@ -289,7 +289,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:commit /// https://wayland.app/protocols/wayland#wl_surface:request:commit
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn commit(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> { async fn commit(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
{ {
let mut lock = self.state.lock(); let mut lock = self.state.lock();
@@ -324,7 +324,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:set_buffer_transform /// https://wayland.app/protocols/wayland#wl_surface:request:set_buffer_transform
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn set_buffer_transform( async fn set_buffer_transform(
&self, &self,
_client: &mut Client, _client: &mut Client,
@@ -336,7 +336,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:set_buffer_scale /// https://wayland.app/protocols/wayland#wl_surface:request:set_buffer_scale
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn set_buffer_scale( async fn set_buffer_scale(
&self, &self,
_client: &mut Client, _client: &mut Client,
@@ -348,7 +348,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:damage_buffer /// https://wayland.app/protocols/wayland#wl_surface:request:damage_buffer
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn damage_buffer( async fn damage_buffer(
&self, &self,
_client: &mut Client, _client: &mut Client,
@@ -364,7 +364,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:offset /// https://wayland.app/protocols/wayland#wl_surface:request:offset
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn offset( async fn offset(
&self, &self,
_client: &mut Client, _client: &mut Client,
@@ -376,7 +376,7 @@ impl WlSurface for Surface {
} }
/// https://wayland.app/protocols/wayland#wl_surface:request:destroy /// https://wayland.app/protocols/wayland#wl_surface:request:destroy
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> { async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
Ok(()) Ok(())
} }

View File

@@ -11,7 +11,6 @@ use bevy_dmabuf::{
use drm_fourcc::DrmFourcc; use drm_fourcc::DrmFourcc;
use mint::Vector2; use mint::Vector2;
use parking_lot::Mutex; use parking_lot::Mutex;
use tracing::info;
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;
@@ -40,7 +39,7 @@ impl std::fmt::Debug for DmabufBacking {
} }
impl DmabufBacking { impl DmabufBacking {
#[tracing::instrument("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>, message_sink: Option<MessageSink>,
@@ -76,13 +75,12 @@ impl DmabufBacking {
}) })
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn update_tex( pub fn update_tex(
&self, &self,
dmatexes: &ImportedDmatexs, dmatexes: &ImportedDmatexs,
images: &mut Assets<Image>, images: &mut Assets<Image>,
) -> Option<Handle<Image>> { ) -> Option<Handle<Image>> {
info!("updating dmabuf tex");
self.pending_imported_dmatex self.pending_imported_dmatex
.lock() .lock()
.take() .take()

View File

@@ -30,7 +30,7 @@ pub struct BufferParams {
} }
impl BufferParams { impl BufferParams {
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub fn new(id: ObjectId) -> Self { pub fn new(id: ObjectId) -> Self {
tracing::info!("Creating new BufferParams with id {:?}", id); tracing::info!("Creating new BufferParams with id {:?}", id);
Self { Self {
@@ -46,7 +46,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
Ok(()) Ok(())
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn add( async fn add(
&self, &self,
_client: &mut Client, _client: &mut Client,
@@ -91,7 +91,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
Ok(()) Ok(())
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn create( async fn create(
&self, &self,
client: &mut Client, client: &mut Client,
@@ -126,7 +126,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
} }
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
async fn create_immed( async fn create_immed(
&self, &self,
client: &mut Client, client: &mut Client,
@@ -154,7 +154,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
} }
impl Drop for BufferParams { impl Drop for BufferParams {
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
fn drop(&mut self) { fn drop(&mut self) {
let planes = self.planes.get_mut(); let planes = self.planes.get_mut();
tracing::info!("BufferParams being dropped with {} planes", planes.len()); tracing::info!("BufferParams being dropped with {} planes", planes.len());

View File

@@ -19,7 +19,7 @@ use waynest::{
#[derive(Debug, Dispatcher)] #[derive(Debug, Dispatcher)]
pub struct DmabufFeedback(pub Arc<Dmabuf>); pub struct DmabufFeedback(pub Arc<Dmabuf>);
impl DmabufFeedback { impl DmabufFeedback {
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub async fn send_params(&self, client: &mut Client, sender_id: ObjectId) -> Result<()> { pub async fn send_params(&self, client: &mut Client, sender_id: ObjectId) -> Result<()> {
let num_formats = self.0.formats.len(); let num_formats = self.0.formats.len();
// Send format table first // Send format table first
@@ -60,7 +60,7 @@ impl DmabufFeedback {
Ok(()) Ok(())
} }
#[tracing::instrument("debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub async fn send_format_table(&self, client: &mut Client, sender_id: ObjectId) -> Result<()> { pub async fn send_format_table(&self, client: &mut Client, sender_id: ObjectId) -> Result<()> {
// Format + modifier pair (16 bytes): // Format + modifier pair (16 bytes):
// - format: u32 // - format: u32