From 2e46a6c9c9a8273537f1438a8ad2fef7545c2dbf Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 5 Nov 2024 14:51:46 -0500 Subject: [PATCH] fix: req. `TIMESTAMP_QUERY` feat. for `::timestamp_writes` --- CHANGELOG.md | 6 ++++++ wgpu-core/src/command/compute.rs | 8 ++++++++ wgpu-core/src/command/mod.rs | 4 +++- wgpu-core/src/command/render.rs | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45b2871c3..8a9928c90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,12 @@ Bottom level categories: - Change the `DropCallback` API to use `FnOnce` instead of `FnMut`. By @jerzywilczek in [#6482](https://github.com/gfx-rs/wgpu/pull/6482) +### Bug Fixes + +#### General + +- Ensure that `Features::TIMESTAMP_QUERY` is set when using timestamp writes in render and compute passes. By @ErichDonGubler in [#6497](https://github.com/gfx-rs/wgpu/pull/6497). + ## 23.0.0 (2024-10-25) ### Themes of this release diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 07dcc2475..4bc6839ec 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -308,6 +308,14 @@ impl Global { }; arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes { + match cmd_buf + .device + .require_features(wgt::Features::TIMESTAMP_QUERY) + { + Ok(()) => (), + Err(e) => return make_err(e.into(), arc_desc), + } + let query_set = match hub.query_sets.get(tw.query_set).get() { Ok(query_set) => query_set, Err(e) => return make_err(e.into(), arc_desc), diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 42c80d3ca..540ff9d2e 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -26,7 +26,7 @@ pub use timestamp_writes::PassTimestampWrites; use self::memory_init::CommandBufferTextureMemoryActions; -use crate::device::{Device, DeviceError}; +use crate::device::{Device, DeviceError, MissingFeatures}; use crate::lock::{rank, Mutex}; use crate::snatch::SnatchGuard; @@ -642,6 +642,8 @@ pub enum CommandEncoderError { InvalidColorAttachment(#[from] ColorAttachmentError), #[error(transparent)] InvalidResource(#[from] InvalidResourceError), + #[error(transparent)] + MissingFeatures(#[from] MissingFeatures), } impl Global { diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index d22eb5f0d..fef6fcad9 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1393,6 +1393,8 @@ impl Global { }; arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes { + device.require_features(wgt::Features::TIMESTAMP_QUERY)?; + let query_set = query_sets.get(tw.query_set).get()?; Some(ArcPassTimestampWrites {