ArcComputePassDescriptor

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev 2025-02-04 16:58:18 +01:00 committed by Nicolas Silva
parent 5c900f15f7
commit 9db6430fdb
3 changed files with 9 additions and 12 deletions

View File

@ -268,7 +268,7 @@ pub fn op_webgpu_command_encoder_begin_compute_pass(
let command_encoder = &command_encoder_resource.1; let command_encoder = &command_encoder_resource.1;
let descriptor = wgpu_core::command::ComputePassDescriptor { let descriptor = wgpu_core::command::ComputePassDescriptor {
label: Some(label), label: Some(label),
timestamp_writes: timestamp_writes.as_ref(), timestamp_writes,
}; };
let (compute_pass, error) = let (compute_pass, error) =

View File

@ -60,7 +60,7 @@ impl ComputePass {
} = desc; } = desc;
Self { Self {
base: Some(BasePass::new(label)), base: Some(BasePass::new(&label)),
parent, parent,
timestamp_writes, timestamp_writes,
@ -95,17 +95,13 @@ impl fmt::Debug for ComputePass {
} }
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct ComputePassDescriptor<'a> { pub struct ComputePassDescriptor<'a, PTW = PassTimestampWrites> {
pub label: Label<'a>, pub label: Label<'a>,
/// Defines where and when timestamp values will be written for this pass. /// Defines where and when timestamp values will be written for this pass.
pub timestamp_writes: Option<&'a PassTimestampWrites>, pub timestamp_writes: Option<PTW>,
} }
struct ArcComputePassDescriptor<'a> { type ArcComputePassDescriptor<'a> = ComputePassDescriptor<'a, ArcPassTimestampWrites>;
pub label: &'a Label<'a>,
/// Defines where and when timestamp values will be written for this pass.
pub timestamp_writes: Option<ArcPassTimestampWrites>,
}
#[derive(Clone, Debug, Error)] #[derive(Clone, Debug, Error)]
#[non_exhaustive] #[non_exhaustive]
@ -292,7 +288,7 @@ impl Global {
let hub = &self.hub; let hub = &self.hub;
let mut arc_desc = ArcComputePassDescriptor { 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. timestamp_writes: None, // Handle only once we resolved the encoder.
}; };
@ -307,6 +303,7 @@ impl Global {
arc_desc.timestamp_writes = match desc arc_desc.timestamp_writes = match desc
.timestamp_writes .timestamp_writes
.as_ref()
.map(|tw| { .map(|tw| {
Self::validate_pass_timestamp_writes(&cmd_buf.device, &hub.query_sets.read(), tw) Self::validate_pass_timestamp_writes(&cmd_buf.device, &hub.query_sets.read(), tw)
}) })
@ -366,7 +363,7 @@ impl Global {
encoder_id, encoder_id,
&ComputePassDescriptor { &ComputePassDescriptor {
label: label.as_deref().map(std::borrow::Cow::Borrowed), label: label.as_deref().map(std::borrow::Cow::Borrowed),
timestamp_writes, timestamp_writes: timestamp_writes.cloned(),
}, },
); );
if let Some(err) = encoder_error { if let Some(err) = encoder_error {

View File

@ -2210,7 +2210,7 @@ impl dispatch::CommandEncoderInterface for CoreCommandEncoder {
self.id, self.id,
&wgc::command::ComputePassDescriptor { &wgc::command::ComputePassDescriptor {
label: desc.label.map(Borrowed), label: desc.label.map(Borrowed),
timestamp_writes: timestamp_writes.as_ref(), timestamp_writes,
}, },
); );