From d0b99297d6667a0cf92ecf19cb9b881780b8022e 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 | 12 ++++++++++-- wgpu-core/src/command/render.rs | 8 +++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 83cc08a4814..6fd3fb16fc3 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), }; diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index db03e1c1560..49318ecc97e 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)?;