diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 048dda0d2..4d8a00769 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1506,6 +1506,33 @@ impl Global { timestamp_writes: Option<&PassTimestampWrites>, occlusion_query_set: Option, ) -> Result<(), RenderPassError> { + let pass_scope = PassErrorScope::PassEncoder(encoder_id); + #[cfg(feature = "trace")] + { + let hub = A::hub(self); + let cmd_buf: Arc> = + CommandBuffer::get_encoder(hub, encoder_id).map_pass_err(pass_scope)?; + + 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::RunRenderPass { + 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(), + }, + target_colors: color_attachments.to_vec(), + target_depth_stencil: depth_stencil_attachment.cloned(), + timestamp_writes: timestamp_writes.cloned(), + occlusion_query_set_id: occlusion_query_set, + }); + } + } + let BasePass { label, commands, @@ -1526,7 +1553,7 @@ impl Global { ); if let Some(err) = encoder_error { return Err(RenderPassError { - scope: PassErrorScope::PassEncoder(encoder_id), + scope: pass_scope, inner: err.into(), }); }; @@ -1583,48 +1610,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::RunRenderPass { - 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(), - }, - target_colors: pass - .color_attachments - .iter() - .map(|attachment| { - attachment.as_ref().map(|a| RenderPassColorAttachment { - view: a.view.as_info().id(), - resolve_target: a.resolve_target.as_ref().map(|a| a.as_info().id()), - channel: a.channel.clone(), - }) - }) - .collect(), - target_depth_stencil: pass.depth_stencil_attachment.as_ref().map(|d| { - RenderPassDepthStencilAttachment { - view: d.view.as_info().id(), - depth: d.depth.clone(), - stencil: d.stencil.clone(), - } - }), - timestamp_writes: pass.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, - } - }), - occlusion_query_set_id: pass - .occlusion_query_set - .as_ref() - .map(|q| q.as_info().id()), - }); - } - device.check_is_valid().map_pass_err(pass_scope)?; let encoder = &mut cmd_buf_data.encoder; diff --git a/wgpu-core/src/command/render_command.rs b/wgpu-core/src/command/render_command.rs index ad0dbaa50..c86bfd12b 100644 --- a/wgpu-core/src/command/render_command.rs +++ b/wgpu-core/src/command/render_command.rs @@ -487,179 +487,3 @@ pub enum ArcRenderCommand { EndPipelineStatisticsQuery, ExecuteBundle(Arc>), } - -#[cfg(feature = "trace")] -impl From<&ArcRenderCommand> for RenderCommand { - fn from(value: &ArcRenderCommand) -> Self { - use crate::resource::Resource as _; - - match value { - ArcRenderCommand::SetBindGroup { - index, - num_dynamic_offsets, - bind_group, - } => RenderCommand::SetBindGroup { - index: *index, - num_dynamic_offsets: *num_dynamic_offsets, - bind_group_id: bind_group.as_info().id(), - }, - - ArcRenderCommand::SetPipeline(pipeline) => { - RenderCommand::SetPipeline(pipeline.as_info().id()) - } - - ArcRenderCommand::SetPushConstant { - offset, - size_bytes, - values_offset, - stages, - } => RenderCommand::SetPushConstant { - offset: *offset, - size_bytes: *size_bytes, - values_offset: *values_offset, - stages: *stages, - }, - - ArcRenderCommand::PushDebugGroup { color, len } => RenderCommand::PushDebugGroup { - color: *color, - len: *len, - }, - - ArcRenderCommand::PopDebugGroup => RenderCommand::PopDebugGroup, - - ArcRenderCommand::InsertDebugMarker { color, len } => { - RenderCommand::InsertDebugMarker { - color: *color, - len: *len, - } - } - - ArcRenderCommand::WriteTimestamp { - query_set, - query_index, - } => RenderCommand::WriteTimestamp { - query_set_id: query_set.as_info().id(), - query_index: *query_index, - }, - - ArcRenderCommand::BeginPipelineStatisticsQuery { - query_set, - query_index, - } => RenderCommand::BeginPipelineStatisticsQuery { - query_set_id: query_set.as_info().id(), - query_index: *query_index, - }, - - ArcRenderCommand::EndPipelineStatisticsQuery => { - RenderCommand::EndPipelineStatisticsQuery - } - ArcRenderCommand::SetIndexBuffer { - buffer, - index_format, - offset, - size, - } => RenderCommand::SetIndexBuffer { - buffer_id: buffer.as_info().id(), - index_format: *index_format, - offset: *offset, - size: *size, - }, - - ArcRenderCommand::SetVertexBuffer { - slot, - buffer, - offset, - size, - } => RenderCommand::SetVertexBuffer { - slot: *slot, - buffer_id: buffer.as_info().id(), - offset: *offset, - size: *size, - }, - - ArcRenderCommand::SetBlendConstant(color) => RenderCommand::SetBlendConstant(*color), - - ArcRenderCommand::SetStencilReference(reference) => { - RenderCommand::SetStencilReference(*reference) - } - - ArcRenderCommand::SetViewport { - rect, - depth_min, - depth_max, - } => RenderCommand::SetViewport { - rect: *rect, - depth_min: *depth_min, - depth_max: *depth_max, - }, - - ArcRenderCommand::SetScissor(scissor) => RenderCommand::SetScissor(*scissor), - - ArcRenderCommand::Draw { - vertex_count, - instance_count, - first_vertex, - first_instance, - } => RenderCommand::Draw { - vertex_count: *vertex_count, - instance_count: *instance_count, - first_vertex: *first_vertex, - first_instance: *first_instance, - }, - - ArcRenderCommand::DrawIndexed { - index_count, - instance_count, - first_index, - base_vertex, - first_instance, - } => RenderCommand::DrawIndexed { - index_count: *index_count, - instance_count: *instance_count, - first_index: *first_index, - base_vertex: *base_vertex, - first_instance: *first_instance, - }, - - ArcRenderCommand::MultiDrawIndirect { - buffer, - offset, - count, - indexed, - } => RenderCommand::MultiDrawIndirect { - buffer_id: buffer.as_info().id(), - offset: *offset, - count: *count, - indexed: *indexed, - }, - - ArcRenderCommand::MultiDrawIndirectCount { - buffer, - offset, - count_buffer, - count_buffer_offset, - max_count, - indexed, - } => RenderCommand::MultiDrawIndirectCount { - buffer_id: buffer.as_info().id(), - offset: *offset, - count_buffer_id: count_buffer.as_info().id(), - count_buffer_offset: *count_buffer_offset, - max_count: *max_count, - indexed: *indexed, - }, - - ArcRenderCommand::BeginOcclusionQuery { query_index } => { - RenderCommand::BeginOcclusionQuery { - query_index: *query_index, - } - } - - ArcRenderCommand::EndOcclusionQuery => RenderCommand::EndOcclusionQuery, - - ArcRenderCommand::ExecuteBundle(bundle) => { - RenderCommand::ExecuteBundle(bundle.as_info().id()) - } - } - } -}