diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 5636bf6a5..e46c0acec 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -416,6 +416,25 @@ impl Global { let scope = PassErrorScope::PassEncoder(encoder_id); let cmd_buf = CommandBuffer::get_encoder(hub, encoder_id).map_pass_err(scope)?; + + #[cfg(feature = "trace")] + { + let mut cmd_buf_data = cmd_buf.data.lock(); + let cmd_buf_data = cmd_buf_data.as_mut().unwrap(); + if let Some(ref mut list) = cmd_buf_data.commands { + list.push(crate::device::trace::Command::RunComputePass { + base: BasePass { + label: base.label.clone(), + commands: base.commands.clone(), + dynamic_offsets: base.dynamic_offsets.clone(), + string_data: base.string_data.clone(), + push_constant_data: base.push_constant_data.clone(), + }, + timestamp_writes: timestamp_writes.cloned(), + }); + } + } + let commands = super::ComputeCommand::resolve_compute_command_ids(A::hub(self), &base.commands)?; @@ -462,24 +481,6 @@ impl Global { let mut cmd_buf_data = cmd_buf.data.lock(); let cmd_buf_data = cmd_buf_data.as_mut().unwrap(); - #[cfg(feature = "trace")] - if let Some(ref mut list) = cmd_buf_data.commands { - list.push(crate::device::trace::Command::RunComputePass { - base: BasePass { - label: base.label.clone(), - commands: base.commands.iter().map(Into::into).collect(), - dynamic_offsets: base.dynamic_offsets.to_vec(), - string_data: base.string_data.to_vec(), - push_constant_data: base.push_constant_data.to_vec(), - }, - timestamp_writes: timestamp_writes.as_ref().map(|tw| PassTimestampWrites { - query_set: tw.query_set.as_info().id(), - beginning_of_pass_write_index: tw.beginning_of_pass_write_index, - end_of_pass_write_index: tw.end_of_pass_write_index, - }), - }); - } - let encoder = &mut cmd_buf_data.encoder; let status = &mut cmd_buf_data.status; diff --git a/wgpu-core/src/command/compute_command.rs b/wgpu-core/src/command/compute_command.rs index aa39a309b..4faab90da 100644 --- a/wgpu-core/src/command/compute_command.rs +++ b/wgpu-core/src/command/compute_command.rs @@ -239,79 +239,3 @@ pub enum ArcComputeCommand { EndPipelineStatisticsQuery, } - -#[cfg(feature = "trace")] -impl From<&ArcComputeCommand> for ComputeCommand { - fn from(value: &ArcComputeCommand) -> Self { - use crate::resource::Resource as _; - - match value { - ArcComputeCommand::SetBindGroup { - index, - num_dynamic_offsets, - bind_group, - } => ComputeCommand::SetBindGroup { - index: *index, - num_dynamic_offsets: *num_dynamic_offsets, - bind_group_id: bind_group.as_info().id(), - }, - - ArcComputeCommand::SetPipeline(pipeline) => { - ComputeCommand::SetPipeline(pipeline.as_info().id()) - } - - ArcComputeCommand::SetPushConstant { - offset, - size_bytes, - values_offset, - } => ComputeCommand::SetPushConstant { - offset: *offset, - size_bytes: *size_bytes, - values_offset: *values_offset, - }, - - ArcComputeCommand::Dispatch(dim) => ComputeCommand::Dispatch(*dim), - - ArcComputeCommand::DispatchIndirect { buffer, offset } => { - ComputeCommand::DispatchIndirect { - buffer_id: buffer.as_info().id(), - offset: *offset, - } - } - - ArcComputeCommand::PushDebugGroup { color, len } => ComputeCommand::PushDebugGroup { - color: *color, - len: *len, - }, - - ArcComputeCommand::PopDebugGroup => ComputeCommand::PopDebugGroup, - - ArcComputeCommand::InsertDebugMarker { color, len } => { - ComputeCommand::InsertDebugMarker { - color: *color, - len: *len, - } - } - - ArcComputeCommand::WriteTimestamp { - query_set, - query_index, - } => ComputeCommand::WriteTimestamp { - query_set_id: query_set.as_info().id(), - query_index: *query_index, - }, - - ArcComputeCommand::BeginPipelineStatisticsQuery { - query_set, - query_index, - } => ComputeCommand::BeginPipelineStatisticsQuery { - query_set_id: query_set.as_info().id(), - query_index: *query_index, - }, - - ArcComputeCommand::EndPipelineStatisticsQuery => { - ComputeCommand::EndPipelineStatisticsQuery - } - } - } -}