diff --git a/player/src/lib.rs b/player/src/lib.rs index 7fbcb25f6..837c33441 100644 --- a/player/src/lib.rs +++ b/player/src/lib.rs @@ -102,8 +102,7 @@ impl GlobalPlay for wgc::global::Global { encoder, base, timestamp_writes.as_ref(), - ) - .unwrap(); + ); } trace::Command::RunRenderPass { base, @@ -119,8 +118,7 @@ impl GlobalPlay for wgc::global::Global { target_depth_stencil.as_ref(), timestamp_writes.as_ref(), occlusion_query_set_id, - ) - .unwrap(); + ); } trace::Command::BuildAccelerationStructuresUnsafeTlas { blas, tlas } => { let blas_iter = blas.iter().map(|x| { diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 7fa1596e6..def050fd7 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -321,6 +321,9 @@ impl Global { /// Note that this differs from [`Self::compute_pass_end`], it will /// create a new pass, replay the commands and end the pass. + /// + /// # Panics + /// On any error. #[doc(hidden)] #[cfg(any(feature = "serde", feature = "replay"))] pub fn compute_pass_end_with_unresolved_commands( @@ -328,9 +331,7 @@ impl Global { encoder_id: id::CommandEncoderId, base: BasePass, timestamp_writes: Option<&PassTimestampWrites>, - ) -> Result<(), ComputePassError> { - let pass_scope = PassErrorScope::Pass; - + ) { #[cfg(feature = "trace")] { let cmd_buf = self @@ -338,7 +339,7 @@ impl Global { .command_buffers .get(encoder_id.into_command_buffer_id()); let mut cmd_buf_data = cmd_buf.data.lock(); - let cmd_buf_data = cmd_buf_data.get_inner().map_pass_err(pass_scope)?; + let cmd_buf_data = cmd_buf_data.get_inner(); if let Some(ref mut list) = cmd_buf_data.commands { list.push(crate::device::trace::Command::RunComputePass { @@ -370,21 +371,19 @@ impl Global { }, ); if let Some(err) = encoder_error { - return Err(ComputePassError { - scope: pass_scope, - inner: err.into(), - }); + panic!("{:?}", err); }; compute_pass.base = Some(BasePass { label, - commands: super::ComputeCommand::resolve_compute_command_ids(&self.hub, &commands)?, + commands: super::ComputeCommand::resolve_compute_command_ids(&self.hub, &commands) + .unwrap(), dynamic_offsets, string_data, push_constant_data, }); - self.compute_pass_end(&mut compute_pass) + self.compute_pass_end(&mut compute_pass).unwrap(); } pub fn compute_pass_end(&self, pass: &mut ComputePass) -> Result<(), ComputePassError> { diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 8ad5badf4..fbb1c488a 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -108,10 +108,14 @@ impl CommandEncoderStatus { } #[cfg(feature = "trace")] - fn get_inner(&mut self) -> Result<&mut CommandBufferMutable, CommandEncoderError> { + fn get_inner(&mut self) -> &mut CommandBufferMutable { match self { - Self::Locked(inner) | Self::Finished(inner) | Self::Recording(inner) => Ok(inner), - Self::Error => Err(CommandEncoderError::Invalid), + Self::Locked(inner) | Self::Finished(inner) | Self::Recording(inner) => inner, + // This is unreachable because this function is only used when + // playing back a recorded trace. If only to avoid having to + // implement serialization for all the error types, we don't support + // storing the errors in a trace. + Self::Error => unreachable!("passes in a trace do not store errors"), } } diff --git a/wgpu-core/src/command/ray_tracing.rs b/wgpu-core/src/command/ray_tracing.rs index a5386934e..50c7a8673 100644 --- a/wgpu-core/src/command/ray_tracing.rs +++ b/wgpu-core/src/command/ray_tracing.rs @@ -161,7 +161,7 @@ impl Global { #[cfg(feature = "trace")] let trace_tlas: Vec = tlas_iter.collect(); #[cfg(feature = "trace")] - if let Some(ref mut list) = cmd_buf.data.lock().get_inner()?.commands { + if let Some(ref mut list) = cmd_buf.data.lock().get_inner().commands { list.push( crate::device::trace::Command::BuildAccelerationStructuresUnsafeTlas { blas: trace_blas.clone(), @@ -444,7 +444,7 @@ impl Global { .collect(); #[cfg(feature = "trace")] - if let Some(ref mut list) = cmd_buf.data.lock().get_inner()?.commands { + if let Some(ref mut list) = cmd_buf.data.lock().get_inner().commands { list.push(crate::device::trace::Command::BuildAccelerationStructures { blas: trace_blas.clone(), tlas: trace_tlas.clone(), diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 751a19683..644c190c7 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1630,9 +1630,7 @@ impl Global { depth_stencil_attachment: Option<&RenderPassDepthStencilAttachment>, timestamp_writes: Option<&PassTimestampWrites>, occlusion_query_set: Option, - ) -> Result<(), RenderPassError> { - let pass_scope = PassErrorScope::Pass; - + ) { #[cfg(feature = "trace")] { let cmd_buf = self @@ -1640,7 +1638,7 @@ impl Global { .command_buffers .get(encoder_id.into_command_buffer_id()); let mut cmd_buf_data = cmd_buf.data.lock(); - let cmd_buf_data = cmd_buf_data.get_inner().map_pass_err(pass_scope)?; + let cmd_buf_data = cmd_buf_data.get_inner(); if let Some(ref mut list) = cmd_buf_data.commands { list.push(crate::device::trace::Command::RunRenderPass { @@ -1678,21 +1676,19 @@ impl Global { }, ); if let Some(err) = encoder_error { - return Err(RenderPassError { - scope: pass_scope, - inner: err.into(), - }); + panic!("{:?}", err); }; render_pass.base = Some(BasePass { label, - commands: super::RenderCommand::resolve_render_command_ids(&self.hub, &commands)?, + commands: super::RenderCommand::resolve_render_command_ids(&self.hub, &commands) + .unwrap(), dynamic_offsets, string_data, push_constant_data, }); - self.render_pass_end(&mut render_pass) + self.render_pass_end(&mut render_pass).unwrap(); } pub fn render_pass_end(&self, pass: &mut RenderPass) -> Result<(), RenderPassError> {