diff --git a/deno_webgpu/command_encoder.rs b/deno_webgpu/command_encoder.rs index 6d45909f2..02adeb0b1 100644 --- a/deno_webgpu/command_encoder.rs +++ b/deno_webgpu/command_encoder.rs @@ -268,7 +268,7 @@ pub fn op_webgpu_command_encoder_begin_compute_pass( let command_encoder = &command_encoder_resource.1; let descriptor = wgpu_core::command::ComputePassDescriptor { label: Some(label), - timestamp_writes: timestamp_writes.as_ref(), + timestamp_writes, }; let (compute_pass, error) = diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index d9b0b1905..921f2d673 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -60,7 +60,7 @@ impl ComputePass { } = desc; Self { - base: Some(BasePass::new(label)), + base: Some(BasePass::new(&label)), parent, timestamp_writes, @@ -95,17 +95,13 @@ impl fmt::Debug for ComputePass { } #[derive(Clone, Debug, Default)] -pub struct ComputePassDescriptor<'a> { +pub struct ComputePassDescriptor<'a, PTW = PassTimestampWrites> { pub label: Label<'a>, /// Defines where and when timestamp values will be written for this pass. - pub timestamp_writes: Option<&'a PassTimestampWrites>, + pub timestamp_writes: Option, } -struct ArcComputePassDescriptor<'a> { - pub label: &'a Label<'a>, - /// Defines where and when timestamp values will be written for this pass. - pub timestamp_writes: Option, -} +type ArcComputePassDescriptor<'a> = ComputePassDescriptor<'a, ArcPassTimestampWrites>; #[derive(Clone, Debug, Error)] #[non_exhaustive] @@ -292,7 +288,7 @@ impl Global { let hub = &self.hub; let mut arc_desc = ArcComputePassDescriptor { - label: &desc.label, + label: desc.label.as_deref().map(std::borrow::Cow::Borrowed), timestamp_writes: None, // Handle only once we resolved the encoder. }; @@ -307,6 +303,7 @@ impl Global { arc_desc.timestamp_writes = match desc .timestamp_writes + .as_ref() .map(|tw| { Self::validate_pass_timestamp_writes(&cmd_buf.device, &hub.query_sets.read(), tw) }) @@ -366,7 +363,7 @@ impl Global { encoder_id, &ComputePassDescriptor { label: label.as_deref().map(std::borrow::Cow::Borrowed), - timestamp_writes, + timestamp_writes: timestamp_writes.cloned(), }, ); if let Some(err) = encoder_error { diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 64203914c..b2e242b6b 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -2210,7 +2210,7 @@ impl dispatch::CommandEncoderInterface for CoreCommandEncoder { self.id, &wgc::command::ComputePassDescriptor { label: desc.label.map(Borrowed), - timestamp_writes: timestamp_writes.as_ref(), + timestamp_writes, }, );