From ce1d6e4173b9f11a33b21a01c25382d39a17d1ab Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 21 Nov 2024 09:34:44 -0500 Subject: [PATCH] refactor: destructure timestamp writes in `command_encoder_create_{compute,render}_pass` --- wgpu-core/src/command/compute.rs | 16 ++++++++++++---- wgpu-core/src/command/render.rs | 12 +++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 747fddb0d0..745fe50150 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -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}; @@ -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) @@ -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), }; @@ -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 diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index db03e1c156..9c2119430b 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1392,7 +1392,13 @@ 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)?; @@ -1400,8 +1406,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