Skip to content

Commit

Permalink
For wgpu web backend, use a real type for submission indices. (gfx-rs…
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
jimblandy authored Jul 13, 2022
1 parent af345cd commit 5094525
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<web_sys::GpuAdapter>;
type DeviceId = Sendable<web_sys::GpuDevice>;
Expand All @@ -996,7 +1002,7 @@ impl crate::Context for Context {
type SurfaceId = Sendable<web_sys::GpuCanvasContext>;

type SurfaceOutputDetail = SurfaceOutputDetail;
type SubmissionIndex = ();
type SubmissionIndex = SubmissionIndex;

type RequestAdapterFuture = MakeSendFuture<
wasm_bindgen_futures::JsFuture,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5094525

Please sign in to comment.