Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v0.19] Wire up Timestamp Queries in WebGPU Backend #5527

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions wgpu/src/backend/webgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,20 @@ impl crate::context::Context for ContextWebGpu {
if let Some(label) = desc.label {
mapped_desc.label(label);
}

if let Some(ref timestamp_writes) = desc.timestamp_writes {
let query_set: &<ContextWebGpu as crate::Context>::QuerySetData =
downcast_ref(timestamp_writes.query_set.data.as_ref());
let mut writes = webgpu_sys::GpuComputePassTimestampWrites::new(&query_set.0);
if let Some(index) = timestamp_writes.beginning_of_pass_write_index {
writes.beginning_of_pass_write_index(index);
}
if let Some(index) = timestamp_writes.end_of_pass_write_index {
writes.end_of_pass_write_index(index);
}
mapped_desc.timestamp_writes(&writes);
}

create_identified(
encoder_data
.0
Expand Down Expand Up @@ -2410,6 +2424,19 @@ impl crate::context::Context for ContextWebGpu {
mapped_desc.depth_stencil_attachment(&mapped_depth_stencil_attachment);
}

if let Some(ref timestamp_writes) = desc.timestamp_writes {
let query_set: &<ContextWebGpu as crate::Context>::QuerySetData =
downcast_ref(timestamp_writes.query_set.data.as_ref());
let mut writes = webgpu_sys::GpuRenderPassTimestampWrites::new(&query_set.0);
if let Some(index) = timestamp_writes.beginning_of_pass_write_index {
writes.beginning_of_pass_write_index(index);
}
if let Some(index) = timestamp_writes.end_of_pass_write_index {
writes.end_of_pass_write_index(index);
}
mapped_desc.timestamp_writes(&writes);
}

create_identified(encoder_data.0.begin_render_pass(&mapped_desc))
}

Expand Down
Loading