diff --git a/wgpu-hal/src/dx11/mod.rs b/wgpu-hal/src/dx11/mod.rs index a77bb9591..a459e4dca 100644 --- a/wgpu-hal/src/dx11/mod.rs +++ b/wgpu-hal/src/dx11/mod.rs @@ -72,8 +72,10 @@ unsafe impl Sync for Device {} pub struct Queue {} +#[derive(Debug)] pub struct CommandEncoder {} +#[derive(Debug)] pub struct CommandBuffer {} #[derive(Debug)] diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index 009a01d42..6f9f18b6c 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -45,7 +45,7 @@ use crate::auxil::{self, dxgi::result::HResult as _}; use arrayvec::ArrayVec; use parking_lot::Mutex; -use std::{ffi, mem, num::NonZeroU32, sync::Arc}; +use std::{ffi, fmt, mem, num::NonZeroU32, sync::Arc}; use winapi::{ shared::{dxgi, dxgi1_4, dxgitype, windef, winerror}, um::{d3d12, dcomp, synchapi, winbase, winnt}, @@ -347,6 +347,16 @@ pub struct CommandEncoder { unsafe impl Send for CommandEncoder {} unsafe impl Sync for CommandEncoder {} +impl fmt::Debug for CommandEncoder { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("CommandEncoder") + .field("allocator", &self.allocator) + .field("device", &self.allocator) + .finish() + } +} + +#[derive(Debug)] pub struct CommandBuffer { raw: native::GraphicsCommandList, } diff --git a/wgpu-hal/src/empty.rs b/wgpu-hal/src/empty.rs index 24e7720be..b13ceb948 100644 --- a/wgpu-hal/src/empty.rs +++ b/wgpu-hal/src/empty.rs @@ -5,6 +5,7 @@ use std::ops::Range; #[derive(Clone)] pub struct Api; pub struct Context; +#[derive(Debug)] pub struct Encoder; #[derive(Debug)] pub struct Resource; diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index 717502f2c..37582cafc 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -82,7 +82,7 @@ use arrayvec::ArrayVec; use glow::HasContext; -use std::{ops::Range, sync::Arc}; +use std::{fmt, ops::Range, sync::Arc}; #[derive(Clone)] pub struct Api; @@ -758,6 +758,16 @@ pub struct CommandBuffer { queries: Vec, } +impl fmt::Debug for CommandBuffer { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut builder = f.debug_struct("CommandBuffer"); + if let Some(ref label) = self.label { + builder.field("label", label); + } + builder.finish() + } +} + //TODO: we would have something like `Arc` // here and in the command buffers. So that everything grows // inside the encoder and stays there until `reset_all`. @@ -767,3 +777,11 @@ pub struct CommandEncoder { state: command::State, private_caps: PrivateCapabilities, } + +impl fmt::Debug for CommandEncoder { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("CommandEncoder") + .field("cmd_buffer", &self.cmd_buffer) + .finish() + } +} diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index cbaf803d9..e8531643d 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -156,7 +156,7 @@ pub trait Api: Clone + Sized { type Queue: Queue; type CommandEncoder: CommandEncoder; - type CommandBuffer: Send + Sync; + type CommandBuffer: Send + Sync + fmt::Debug; type Buffer: fmt::Debug + Send + Sync + 'static; type Texture: fmt::Debug + Send + Sync + 'static; @@ -350,7 +350,7 @@ pub trait Queue: Send + Sync { /// Serves as a parent for all the encoded command buffers. /// Works in bursts of action: one or more command buffers are recorded, /// then submitted to a queue, and then it needs to be `reset_all()`. -pub trait CommandEncoder: Send + Sync { +pub trait CommandEncoder: Send + Sync + fmt::Debug { /// Begin encoding a new command buffer. unsafe fn begin_encoding(&mut self, label: Label) -> Result<(), DeviceError>; /// Discard currently recorded list, if any. diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index 82cb2a889..62a9b3b08 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -20,7 +20,7 @@ mod device; mod surface; use std::{ - iter, ops, + fmt, iter, ops, ptr::NonNull, sync::{atomic, Arc}, thread, @@ -727,9 +727,19 @@ pub struct CommandEncoder { temp: Temp, } +impl fmt::Debug for CommandEncoder { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("CommandEncoder") + .field("raw_queue", &self.raw_queue) + .field("raw_cmd_buf", &self.raw_cmd_buf) + .finish() + } +} + unsafe impl Send for CommandEncoder {} unsafe impl Sync for CommandEncoder {} +#[derive(Debug)] pub struct CommandBuffer { raw: mtl::CommandBuffer, } diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index d3416a50e..8fbc520ea 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -31,7 +31,7 @@ mod conv; mod device; mod instance; -use std::{borrow::Borrow, ffi::CStr, num::NonZeroU32, sync::Arc}; +use std::{borrow::Borrow, ffi::CStr, fmt, num::NonZeroU32, sync::Arc}; use arrayvec::ArrayVec; use ash::{ @@ -443,6 +443,15 @@ pub struct CommandEncoder { rpass_debug_marker_active: bool, } +impl fmt::Debug for CommandEncoder { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("CommandEncoder") + .field("raw", &self.raw) + .finish() + } +} + +#[derive(Debug)] pub struct CommandBuffer { raw: vk::CommandBuffer, }