Skip to content

Commit

Permalink
refactor: destructure timestamp writes in `command_encoder_create_{co…
Browse files Browse the repository at this point in the history
…mpute,render}_pass`
  • Loading branch information
ErichDonGubler committed Nov 22, 2024
1 parent b17c303 commit ce1d6e4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
16 changes: 12 additions & 4 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ use crate::{
use thiserror::Error;
use wgt::{BufferAddress, DynamicOffset};

use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions};
use super::{
bind::BinderError, memory_init::CommandBufferTextureMemoryActions, SimplifiedQueryType,
};
use crate::ray_tracing::TlasAction;
use std::sync::Arc;
use std::{fmt, mem::size_of, str};
Expand Down Expand Up @@ -309,6 +311,12 @@ impl Global {
};

arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
let &PassTimestampWrites {
query_set,
beginning_of_pass_write_index,
end_of_pass_write_index,
} = tw;

match cmd_buf
.device
.require_features(wgt::Features::TIMESTAMP_QUERY)
Expand All @@ -317,7 +325,7 @@ impl Global {
Err(e) => return make_err(e.into(), arc_desc),
}

let query_set = match hub.query_sets.get(tw.query_set).get() {
let query_set = match hub.query_sets.get(query_set).get() {
Ok(query_set) => query_set,
Err(e) => return make_err(e.into(), arc_desc),
};
Expand All @@ -329,8 +337,8 @@ impl Global {

Some(ArcPassTimestampWrites {
query_set,
beginning_of_pass_write_index: tw.beginning_of_pass_write_index,
end_of_pass_write_index: tw.end_of_pass_write_index,
beginning_of_pass_write_index,
end_of_pass_write_index,
})
} else {
None
Expand Down
12 changes: 9 additions & 3 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,16 +1392,22 @@ impl Global {
};

arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
let query_set = query_sets.get(tw.query_set).get()?;
let &PassTimestampWrites {
query_set,
beginning_of_pass_write_index,
end_of_pass_write_index,
} = tw;

let query_set = query_sets.get(query_set).get()?;

device.require_features(wgt::Features::TIMESTAMP_QUERY)?;

query_set.same_device(device)?;

Some(ArcPassTimestampWrites {
query_set,
beginning_of_pass_write_index: tw.beginning_of_pass_write_index,
end_of_pass_write_index: tw.end_of_pass_write_index,
beginning_of_pass_write_index,
end_of_pass_write_index,
})
} else {
None
Expand Down

0 comments on commit ce1d6e4

Please sign in to comment.