1008: Add helpers to convert passes to serialized forms r=grovesNL a=kvark

**Connections**
Stuff I needed to fix in the upcoming Gecko WebGPU update.

**Description**
It allows us to use the tracing `Command` more aggressively.

**Testing**
Tested in Gecko, doesn't need testing in wgpu

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
This commit is contained in:
bors[bot] 2020-11-02 23:15:03 +00:00 committed by GitHub
commit 7b9abf0fef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 3 deletions

View File

@ -1 +1,3 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

View File

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
fn main() {
// Setup cfg aliases
cfg_aliases::cfg_aliases! {

View File

@ -79,6 +79,11 @@ impl ComputePass {
pub fn parent_id(&self) -> id::CommandEncoderId {
self.parent_id
}
#[cfg(feature = "trace")]
pub fn into_command(self) -> crate::device::trace::Command {
crate::device::trace::Command::RunComputePass { base: self.base }
}
}
impl fmt::Debug for ComputePass {

View File

@ -163,6 +163,15 @@ impl RenderPass {
pub fn parent_id(&self) -> id::CommandEncoderId {
self.parent_id
}
#[cfg(feature = "trace")]
pub fn into_command(self) -> crate::device::trace::Command {
crate::device::trace::Command::RunRenderPass {
base: self.base,
target_colors: self.color_targets.into_iter().collect(),
target_depth_stencil: self.depth_stencil_target,
}
}
}
impl fmt::Debug for RenderPass {

View File

@ -13,7 +13,8 @@ use std::borrow::{Borrow, Cow};
use thiserror::Error;
use wgt::{BufferAddress, IndexFormat, InputStepMode};
#[repr(C)]
// Unable to serialize with `naga::Module` in here:
// requires naga serialization feature.
#[derive(Debug)]
pub enum ShaderModuleSource<'a> {
SpirV(Cow<'a, [u32]>),

View File

@ -6,7 +6,7 @@
// However when building from both the wgpu crate or this crate cargo doc will claim all the links cannot be resolved
// despite the fact that it works fine when it needs to.
// So we just disable those warnings.
#![allow(intra_doc_link_resolution_failure)]
#![allow(broken_intra_doc_links)]
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
@ -1252,6 +1252,8 @@ impl<L> BufferDescriptor<L> {
/// Describes a [`CommandEncoder`].
#[repr(C)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct CommandEncoderDescriptor<L> {
/// Debug label for the command encoder. This will show up in graphics debuggers for easy identification.