diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index d7a327eef..ec5397678 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -496,7 +496,10 @@ impl Global { trace.add(trace::Action::FreeBuffer(buffer_id)); } - let _ = buffer.unmap(); + let _ = buffer.unmap( + #[cfg(feature = "trace")] + buffer_id, + ); buffer.destroy() } @@ -519,7 +522,10 @@ impl Global { t.add(trace::Action::DestroyBuffer(buffer_id)); } - let _ = buffer.unmap(); + let _ = buffer.unmap( + #[cfg(feature = "trace")] + buffer_id, + ); let last_submit_index = buffer.info.submission_index(); @@ -2634,7 +2640,10 @@ impl Global { drop(snatch_guard); buffer.device.check_is_valid()?; - buffer.unmap() + buffer.unmap( + #[cfg(feature = "trace")] + buffer_id, + ) } } diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index fadc077d6..012072a97 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -623,8 +623,14 @@ impl Buffer { } // Note: This must not be called while holding a lock. - pub(crate) fn unmap(self: &Arc) -> Result<(), BufferAccessError> { - if let Some((mut operation, status)) = self.unmap_inner()? { + pub(crate) fn unmap( + self: &Arc, + #[cfg(feature = "trace")] buffer_id: BufferId, + ) -> Result<(), BufferAccessError> { + if let Some((mut operation, status)) = self.unmap_inner( + #[cfg(feature = "trace")] + buffer_id, + )? { if let Some(callback) = operation.callback.take() { callback.call(status); } @@ -633,7 +639,10 @@ impl Buffer { Ok(()) } - fn unmap_inner(self: &Arc) -> Result, BufferAccessError> { + fn unmap_inner( + self: &Arc, + #[cfg(feature = "trace")] buffer_id: BufferId, + ) -> Result, BufferAccessError> { use hal::Device; let device = &self.device; @@ -652,7 +661,7 @@ impl Buffer { std::slice::from_raw_parts(ptr.as_ptr(), self.size as usize) }); trace.add(trace::Action::WriteBuffer { - id: self.info.id(), + id: buffer_id, data, range: 0..self.size, queued: true, @@ -716,7 +725,7 @@ impl Buffer { std::slice::from_raw_parts(ptr.as_ptr(), size as usize) }); trace.add(trace::Action::WriteBuffer { - id: self.info.id(), + id: buffer_id, data, range: range.clone(), queued: false,