From 421aa79364109e7620db9c0e193a29c7a14f9c17 Mon Sep 17 00:00:00 2001 From: Kunal Mohan Date: Tue, 23 Jun 2020 23:18:21 +0530 Subject: [PATCH] Custom implement Debug for RenderPass and ComputePass --- Cargo.lock | 4 ++-- wgpu-core/src/command/compute.rs | 14 +++++++++++++- wgpu-core/src/command/render.rs | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f148964fc..64a1b10d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -493,7 +493,7 @@ dependencies = [ [[package]] name = "gfx-descriptor" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx-extras?rev=438353c3f75368c12024ad2fc03cbeb15f351fd9#438353c3f75368c12024ad2fc03cbeb15f351fd9" +source = "git+https://github.com/gfx-rs/gfx-extras?rev=0f7dac1b05813948fa0e5999c4fe6473f0c98f9b#0f7dac1b05813948fa0e5999c4fe6473f0c98f9b" dependencies = [ "fxhash", "gfx-hal", @@ -513,7 +513,7 @@ dependencies = [ [[package]] name = "gfx-memory" version = "0.1.3" -source = "git+https://github.com/gfx-rs/gfx-extras?rev=438353c3f75368c12024ad2fc03cbeb15f351fd9#438353c3f75368c12024ad2fc03cbeb15f351fd9" +source = "git+https://github.com/gfx-rs/gfx-extras?rev=0f7dac1b05813948fa0e5999c4fe6473f0c98f9b#0f7dac1b05813948fa0e5999c4fe6473f0c98f9b" dependencies = [ "fxhash", "gfx-hal", diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 12f5b3083..0465ee11d 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -17,7 +17,7 @@ use crate::{ use hal::command::CommandBuffer as _; use wgt::{BufferAddress, BufferUsage, BIND_BUFFER_ALIGNMENT}; -use std::{iter, str}; +use std::{fmt, iter, str}; #[doc(hidden)] #[derive(Clone, Copy, Debug)] @@ -71,6 +71,18 @@ impl ComputePass { } } +impl fmt::Debug for ComputePass { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "ComputePass {{ encoder_id: {:?}, data: {:?} commands and {:?} dynamic offsets }}", + self.parent_id, + self.base.commands.len(), + self.base.dynamic_offsets.len() + ) + } +} + #[repr(C)] #[derive(Clone, Debug, Default)] pub struct ComputePassDescriptor { diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index ef0554b9e..43a437d83 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -166,6 +166,20 @@ impl RenderPass { } } +impl fmt::Debug for RenderPass { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "RenderPass {{ encoder_id: {:?}, color_targets: {:?}, depth_stencil_target: {:?}, data: {:?} commands and {:?} dynamic offsets }}", + self.parent_id, + self.color_targets, + self.depth_stencil_target, + self.base.commands.len(), + self.base.dynamic_offsets.len() + ) + } +} + #[derive(Debug, PartialEq)] enum OptionalState { Unused,