From 5094525fb8b6cd4d4e286619288662f6b48b8dfc Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 13 Jul 2022 09:37:21 -0700 Subject: [PATCH] For wgpu web backend, use a real type for submission indices. (#2874) The wgpu web backend uses `()` as `Context::SubmissionIndex`, which is fine --- WebGPU provides no way to identify individual queue submissions --- except that Clippy is concerned about us passing around `()` in the front end as if it were a real value. Instead, define a new zero-size `wgpu::backend::web::SubmissionIndex` type for this use. --- wgpu/src/backend/web.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 54ebeadb8a..15ed91356e 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -972,6 +972,12 @@ impl Context { } } +// The web doesn't provide any way to identify specific queue +// submissions. But Clippy gets concerned if we pass around `()` as if +// it were meaningful. +#[derive(Debug, Clone, Copy)] +pub struct SubmissionIndex; + impl crate::Context for Context { type AdapterId = Sendable; type DeviceId = Sendable; @@ -996,7 +1002,7 @@ impl crate::Context for Context { type SurfaceId = Sendable; type SurfaceOutputDetail = SurfaceOutputDetail; - type SubmissionIndex = (); + type SubmissionIndex = SubmissionIndex; type RequestAdapterFuture = MakeSendFuture< wasm_bindgen_futures::JsFuture, @@ -2280,7 +2286,7 @@ impl crate::Context for Context { queue.0.submit(&temp_command_buffers); - // SubmissionIndex is (), so just let this function end + SubmissionIndex } fn queue_get_timestamp_period(&self, _queue: &Self::QueueId) -> f32 {