diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 7fd521715a..d4da468c0f 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -654,18 +654,7 @@ impl Global { query_index, } => { let scope = PassErrorScope::WriteTimestamp; - - query_set.same_device_as(cmd_buf).map_pass_err(scope)?; - - state - .device - .require_features(wgt::Features::TIMESTAMP_QUERY_INSIDE_PASSES) - .map_pass_err(scope)?; - - let query_set = state.tracker.query_sets.insert_single(query_set); - - query_set - .validate_and_write_timestamp(raw, query_index, None) + write_timestamp(&mut state, raw, cmd_buf, query_set, query_index) .map_pass_err(scope)?; } ArcComputeCommand::BeginPipelineStatisticsQuery { @@ -1036,6 +1025,25 @@ fn insert_debug_marker( state.string_offset += len; } +fn write_timestamp( + state: &mut State, + raw: &mut A::CommandEncoder, + cmd_buf: &CommandBuffer, + query_set: Arc>, + query_index: u32, +) -> Result<(), ComputePassErrorInner> { + query_set.same_device_as(cmd_buf)?; + + state + .device + .require_features(wgt::Features::TIMESTAMP_QUERY_INSIDE_PASSES)?; + + let query_set = state.tracker.query_sets.insert_single(query_set); + + query_set.validate_and_write_timestamp(raw, query_index, None)?; + Ok(()) +} + // Recording a compute pass. impl Global { pub fn compute_pass_set_bind_group(