From 0e7fb34d9793063a0cbf595e4db0d06474032ea8 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Thu, 3 Sep 2026 13:27:23 +0200 Subject: [PATCH] [deno] Use GPUQuerySet::{count, type} from wgc Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- deno_webgpu/device.rs | 6 +----- deno_webgpu/query_set.rs | 8 +++----- wgpu-types/src/lib.rs | 10 ++++++++++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/deno_webgpu/device.rs b/deno_webgpu/device.rs index e2b260c60..6c27e56e1 100644 --- a/deno_webgpu/device.rs +++ b/deno_webgpu/device.rs @@ -725,11 +725,7 @@ impl GPUDevice { let wgpu_query_set = self.wgpu_device.create_query_set(&wgpu_descriptor); - Ok(GPUQuerySet { - wgpu_query_set, - r#type: descriptor.r#type, - count: descriptor.count, - }) + Ok(GPUQuerySet { wgpu_query_set }) } #[getter] diff --git a/deno_webgpu/query_set.rs b/deno_webgpu/query_set.rs index c1f4d106e..a314855d2 100644 --- a/deno_webgpu/query_set.rs +++ b/deno_webgpu/query_set.rs @@ -13,8 +13,6 @@ use crate::error::GPUGenericError; pub struct GPUQuerySet { pub wgpu_query_set: Arc, - pub r#type: GPUQueryType, - pub count: u32, } impl WebIdlInterfaceConverter for GPUQuerySet { @@ -56,13 +54,13 @@ impl GPUQuerySet { #[getter] #[string] #[rename("type")] - fn r#type(&self) -> &'static str { - self.r#type.as_str() + fn r#type(&self) -> String { + self.wgpu_query_set.descriptor().ty.to_string() } #[getter] fn count(&self) -> u32 { - self.count + self.wgpu_query_set.descriptor().count } } diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index bd41ae3dd..255547304 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -512,6 +512,16 @@ pub enum QueryType { PipelineStatistics(PipelineStatisticsTypes), } +impl fmt::Display for QueryType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Occlusion => f.write_str("occlusion"), + Self::Timestamp => f.write_str("timestamp"), + Self::PipelineStatistics(_) => f.write_str("pipeline-statistics"), + } + } +} + bitflags::bitflags! { /// Flags for which pipeline data should be recorded in a query. ///