747: Custom implement Debug for RenderCommand and ComputeCommand r=kvark a=kunalmohan

This would avoid unnecessarily long debug logs for Render and Compute passes to some extent. I am not sure if it would be helpful to print `dynamic_offsets` and `string_data` under `BasePass` without the content of related `Compute/Render Command`.
<!--**Connections**
_Link to the issues addressed by this PR, or dependent PRs in other repositories_

**Description**
_Describe what problem this is solving, and how it's solved._
This would avoid 
**Testing**
_Explain how this change is tested._

Non-trivial functional changes would need to be tested through:
  - [wgpu-rs](https://github.com/gfx-rs/wgpu-rs) - test the examples.
  - [wgpu-native](https://github.com/gfx-rs/wgpu-native/) - check the generated C header for sanity.

Ideally, a PR needs to link to the draft PRs in these projects with relevant modifications.
See https://github.com/gfx-rs/wgpu/pull/666 for an example.
If you can add a unit/integration test here in `wgpu`, that would be best.
-->


Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
This commit is contained in:
bors[bot] 2020-06-24 14:39:00 +00:00 committed by GitHub
commit 177a0b39ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -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 {

View File

@ -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,