Skip to content

Commit

Permalink
Fix serde issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Apr 25, 2022
1 parent fd90b21 commit 67c8d92
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
18 changes: 9 additions & 9 deletions wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ pub struct RenderBundleEncoder {
pub(crate) is_ds_read_only: bool,

// Resource binding dedupe state.
#[serde(skip)]
current_bind_groups: BindGroupStateChange,
#[serde(skip)]
current_pipeline: StateChange<id::RenderPipelineId>,
}

Expand Down Expand Up @@ -1231,15 +1233,13 @@ pub mod bundle_ffi {
offsets: *const DynamicOffset,
offset_length: usize,
) {
let redundant = bundle
.current_bind_groups
.set_and_check_redundant(
bind_group_id,
index,
&mut bundle.base.dynamic_offsets,
offsets,
offset_length,
);
let redundant = bundle.current_bind_groups.set_and_check_redundant(
bind_group_id,
index,
&mut bundle.base.dynamic_offsets,
offsets,
offset_length,
);

if redundant {
return;
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ pub struct ComputePass {
parent_id: id::CommandEncoderId,

// Resource binding dedupe state.
#[serde(skip)]
current_bind_groups: BindGroupStateChange,
#[serde(skip)]
current_pipeline: StateChange<id::ComputePipelineId>,
}

Expand Down
16 changes: 15 additions & 1 deletion wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,22 @@ impl<T: Copy + PartialEq> StateChange<T> {
}
}

impl<T: Copy + PartialEq> Default for StateChange<T> {
fn default() -> Self {
Self::new()
}
}

#[derive(Debug)]
struct BindGroupStateChange {
last_states: [StateChange<id::BindGroupId>; hal::MAX_BIND_GROUPS],
}

impl BindGroupStateChange {
fn new() -> Self {
Self { last_states: [StateChange::new(); hal::MAX_BIND_GROUPS] }
Self {
last_states: [StateChange::new(); hal::MAX_BIND_GROUPS],
}
}

unsafe fn set_and_check_redundant(
Expand Down Expand Up @@ -466,6 +474,12 @@ impl BindGroupStateChange {
}
}

impl Default for BindGroupStateChange {
fn default() -> Self {
Self::new()
}
}

trait MapPassErr<T, O> {
fn map_pass_err(self, scope: PassErrorScope) -> Result<T, O>;
}
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ pub struct RenderPass {
depth_stencil_target: Option<RenderPassDepthStencilAttachment>,

// Resource binding dedupe state.
#[serde(skip)]
current_bind_groups: BindGroupStateChange,
#[serde(skip)]
current_pipeline: StateChange<id::RenderPipelineId>,
}

Expand Down

0 comments on commit 67c8d92

Please sign in to comment.