diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 2c34103d8e..2442638599 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -230,7 +230,7 @@ impl Global { pub fn command_encoder_run_compute_pass_impl( &self, encoder_id: id::CommandEncoderId, - mut base: BasePassRef, + base: BasePassRef, ) -> Result<(), ComputePassError> { span!(_guard, INFO, "CommandEncoder::run_compute_pass"); let scope = PassErrorScope::Pass(encoder_id); @@ -270,6 +270,8 @@ impl Global { debug_scope_depth: 0, }; let mut temp_offsets = Vec::new(); + let mut dynamic_offset_count = 0; + let mut string_offset = 0; for command in base.commands { match *command { @@ -290,9 +292,11 @@ impl Global { } temp_offsets.clear(); - temp_offsets - .extend_from_slice(&base.dynamic_offsets[..num_dynamic_offsets as usize]); - base.dynamic_offsets = &base.dynamic_offsets[num_dynamic_offsets as usize..]; + temp_offsets.extend_from_slice( + &base.dynamic_offsets[dynamic_offset_count + ..dynamic_offset_count + (num_dynamic_offsets as usize)], + ); + dynamic_offset_count += num_dynamic_offsets as usize; let bind_group = cmd_buf .trackers @@ -488,12 +492,13 @@ impl Global { } ComputeCommand::PushDebugGroup { color, len } => { state.debug_scope_depth += 1; - - let label = str::from_utf8(&base.string_data[..len]).unwrap(); + let label = + str::from_utf8(&base.string_data[string_offset..string_offset + len]) + .unwrap(); + string_offset += len; unsafe { raw.begin_debug_marker(label, color); } - base.string_data = &base.string_data[len..]; } ComputeCommand::PopDebugGroup => { let scope = PassErrorScope::PopDebugGroup; @@ -508,9 +513,11 @@ impl Global { } } ComputeCommand::InsertDebugMarker { color, len } => { - let label = str::from_utf8(&base.string_data[..len]).unwrap(); + let label = + str::from_utf8(&base.string_data[string_offset..string_offset + len]) + .unwrap(); + string_offset += len; unsafe { raw.insert_debug_marker(label, color) } - base.string_data = &base.string_data[len..]; } } } diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 65320b1c1c..26e7b62c10 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1059,7 +1059,7 @@ impl Global { pub fn command_encoder_run_render_pass_impl( &self, encoder_id: id::CommandEncoderId, - mut base: BasePassRef, + base: BasePassRef, color_attachments: &[ColorAttachmentDescriptor], depth_stencil_attachment: Option<&DepthStencilAttachmentDescriptor>, ) -> Result<(), RenderPassError> { @@ -1121,6 +1121,8 @@ impl Global { debug_scope_depth: 0, }; let mut temp_offsets = Vec::new(); + let mut dynamic_offset_count = 0; + let mut string_offset = 0; for command in base.commands { match *command { @@ -1141,10 +1143,10 @@ impl Global { temp_offsets.clear(); temp_offsets.extend_from_slice( - &base.dynamic_offsets[..num_dynamic_offsets as usize], + &base.dynamic_offsets[dynamic_offset_count + ..dynamic_offset_count + (num_dynamic_offsets as usize)], ); - base.dynamic_offsets = - &base.dynamic_offsets[num_dynamic_offsets as usize..]; + dynamic_offset_count += num_dynamic_offsets as usize; let bind_group = info .trackers @@ -1748,11 +1750,13 @@ impl Global { } RenderCommand::PushDebugGroup { color, len } => { state.debug_scope_depth += 1; - let label = str::from_utf8(&base.string_data[..len]).unwrap(); + let label = + str::from_utf8(&base.string_data[string_offset..string_offset + len]) + .unwrap(); + string_offset += len; unsafe { raw.begin_debug_marker(label, color); } - base.string_data = &base.string_data[len..]; } RenderCommand::PopDebugGroup => { let scope = PassErrorScope::PopDebugGroup; @@ -1766,11 +1770,13 @@ impl Global { } } RenderCommand::InsertDebugMarker { color, len } => { - let label = str::from_utf8(&base.string_data[..len]).unwrap(); + let label = + str::from_utf8(&base.string_data[string_offset..string_offset + len]) + .unwrap(); + string_offset += len; unsafe { raw.insert_debug_marker(label, color); } - base.string_data = &base.string_data[len..]; } RenderCommand::ExecuteBundle(bundle_id) => { let scope = PassErrorScope::ExecuteBundle;