Skip to content

Commit 333f811

Browse files
authored
Rework wgpu::PollType to only two enum variants (#8285)
1 parent 43eccd2 commit 333f811

File tree

74 files changed

+416
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+416
-190
lines changed

CHANGELOG.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,52 @@ by if the `Feature::MULTI_DRAW_INDIRECT_COUNT` feature is available on the devic
158158

159159
By @cwfitzgerald in [#8162](https://github.com/gfx-rs/wgpu/pull/8162).
160160

161+
162+
#### `wgpu::PollType::Wait` has now an optional timeout
163+
164+
We removed `wgpu::PollType::WaitForSubmissionIndex` and added fields to `wgpu::PollType::Wait` in order to express timeouts.
165+
166+
Before/after for `wgpu::PollType::Wait`:
167+
168+
```diff
169+
-device.poll(wgpu::PollType::Wait).unwrap();
170+
-device.poll(wgpu::PollType::wait_indefinitely()).unwrap();
171+
+device.poll(wgpu::PollType::Wait {
172+
+ submission_index: None, // Wait for most recent submission
173+
+ timeout: Some(std::time::Duration::from_secs(60)), // Previous behavior, but more likely you want `None` instead.
174+
+ })
175+
+ .unwrap();
176+
```
177+
178+
Before/after for `wgpu::PollType::WaitForSubmissionIndex`:
179+
180+
```diff
181+
-device.poll(wgpu::PollType::WaitForSubmissionIndex(index_to_wait_on))
182+
+device.poll(wgpu::PollType::Wait {
183+
+ submission_index: Some(index_to_wait_on),
184+
+ timeout: Some(std::time::Duration::from_secs(60)), // Previous behavior, but more likely you want `None` instead.
185+
+ })
186+
+ .unwrap();
187+
```
188+
189+
⚠️ Previously, both `wgpu::PollType::WaitForSubmissionIndex` and `wgpu::PollType::Wait` had a hard-coded timeout of 60 seconds.
190+
191+
192+
To wait indefinitely on the latest submission, you can also use the `wait_indefinitely` convenience function:
193+
```rust
194+
device.poll(wgpu::PollType::wait_indefinitely());
195+
```
196+
197+
By @wumpf in [#8282](https://github.com/gfx-rs/wgpu/pull/8282), [#8285](https://github.com/gfx-rs/wgpu/pull/8285)
198+
161199
### New Features
162200

163201
#### General
164202

165203
- Added mesh shader support to `wgpu`, with examples. Requires passthrough. By @SupaMaggie70Incorporated in [#7345](https://github.com/gfx-rs/wgpu/pull/7345).
166204

167205
- Added support for external textures based on WebGPU's [`GPUExternalTexture`](https://www.w3.org/TR/webgpu/#gpuexternaltexture). These allow shaders to transparently operate on potentially multiplanar source texture data in either RGB or YCbCr formats via WGSL's `texture_external` type. This is gated behind the `Features::EXTERNAL_TEXTURE` feature, which is currently only supported on DX12. By @jamienicol in [#4386](https://github.com/gfx-rs/wgpu/issues/4386).
168-
- `wgpu::Device::poll` can now specify a timeout via `wgpu::PollType::WaitWithTimeout`/`wgpu::PollType::WaitForSubmissionIndexWithTimeout`. By @wumpf in [#8282](https://github.com/gfx-rs/wgpu/pull/8282)
206+
- `wgpu::Device::poll` can now specify a timeout via `wgpu::PollType::Wait`. By @wumpf in [#8282](https://github.com/gfx-rs/wgpu/pull/8282) & [#8285](https://github.com/gfx-rs/wgpu/pull/8285)
169207

170208
#### naga
171209

@@ -195,7 +233,6 @@ By @cwfitzgerald in [#8162](https://github.com/gfx-rs/wgpu/pull/8162).
195233
- Require new `F16_IN_F32` downlevel flag for `quantizeToF16`, `pack2x16float`, and `unpack2x16float` in WGSL input. By @aleiserson in [#8130](https://github.com/gfx-rs/wgpu/pull/8130).
196234
- The error message for non-copyable depth/stencil formats no longer mentions the aspect when it is not relevant. By @reima in [#8156](https://github.com/gfx-rs/wgpu/pull/8156).
197235
- Track the initialization status of buffer memory correctly when `copy_texture_to_buffer` skips over padding space between rows or layers, or when the start/end of a texture-buffer transfer is not 4B aligned. By @andyleiserson in [#8099](https://github.com/gfx-rs/wgpu/pull/8099).
198-
- `wgpu::PollType::Wait`/`wgpu::PollType::WaitForSubmissionIndex` will no longer timeout after 60 seconds, but instead wait indefinitely or (depending on backend implementation) until an error is encountered. Use `wgpu::PollType::WaitWithTimeout`/`wgpu::PollType::WaitForSubmissionIndexWithTimeout` if you need a timeout. By @wumpf in [#8282](https://github.com/gfx-rs/wgpu/pull/8282)
199236

200237
#### naga
201238

benches/benches/wgpu-benchmark/bind_groups.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn run_bench(ctx: &mut Criterion) {
155155
state
156156
.device_state
157157
.device
158-
.poll(wgpu::PollType::Wait)
158+
.poll(wgpu::PollType::wait_indefinitely())
159159
.unwrap();
160160
}
161161

benches/benches/wgpu-benchmark/computepass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ fn run_bench(ctx: &mut Criterion) {
489489
state
490490
.device_state
491491
.device
492-
.poll(wgpu::PollType::Wait)
492+
.poll(wgpu::PollType::wait_indefinitely())
493493
.unwrap();
494494
}
495495

@@ -538,7 +538,7 @@ fn run_bench(ctx: &mut Criterion) {
538538
state
539539
.device_state
540540
.device
541-
.poll(wgpu::PollType::Wait)
541+
.poll(wgpu::PollType::wait_indefinitely())
542542
.unwrap();
543543
}
544544

@@ -584,7 +584,7 @@ fn run_bench(ctx: &mut Criterion) {
584584
state
585585
.device_state
586586
.device
587-
.poll(wgpu::PollType::Wait)
587+
.poll(wgpu::PollType::wait_indefinitely())
588588
.unwrap();
589589
}
590590

benches/benches/wgpu-benchmark/renderpass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ fn run_bench(ctx: &mut Criterion) {
497497
state
498498
.device_state
499499
.device
500-
.poll(wgpu::PollType::Wait)
500+
.poll(wgpu::PollType::wait_indefinitely())
501501
.unwrap();
502502
}
503503

@@ -544,7 +544,7 @@ fn run_bench(ctx: &mut Criterion) {
544544
state
545545
.device_state
546546
.device
547-
.poll(wgpu::PollType::Wait)
547+
.poll(wgpu::PollType::wait_indefinitely())
548548
.unwrap();
549549
}
550550

@@ -584,7 +584,7 @@ fn run_bench(ctx: &mut Criterion) {
584584
state
585585
.device_state
586586
.device
587-
.poll(wgpu::PollType::Wait)
587+
.poll(wgpu::PollType::wait_indefinitely())
588588
.unwrap();
589589
}
590590

benches/benches/wgpu-benchmark/resource_creation.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ fn run_bench(ctx: &mut Criterion) {
6161
drop(buffers);
6262

6363
state.queue.submit([]);
64-
state.device.poll(wgpu::PollType::Wait).unwrap();
64+
state
65+
.device
66+
.poll(wgpu::PollType::wait_indefinitely())
67+
.unwrap();
6568
}
6669

6770
duration

deno_webgpu/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl GPUBuffer {
177177
{
178178
self
179179
.instance
180-
.device_poll(self.device, wgpu_types::PollType::wait())
180+
.device_poll(self.device, wgpu_types::PollType::wait_indefinitely())
181181
.unwrap();
182182
}
183183
tokio::time::sleep(Duration::from_millis(10)).await;

deno_webgpu/device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ impl GPUDevice {
685685
fn stop_capture(&self) {
686686
self
687687
.instance
688-
.device_poll(self.id, wgpu_types::PollType::wait())
688+
.device_poll(self.id, wgpu_types::PollType::wait_indefinitely())
689689
.unwrap();
690690
unsafe { self.instance.device_stop_graphics_debugger_capture(self.id) };
691691
}

deno_webgpu/queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl GPUQueue {
103103
{
104104
self
105105
.instance
106-
.device_poll(self.device, wgpu_types::PollType::wait())
106+
.device_poll(self.device, wgpu_types::PollType::wait_indefinitely())
107107
.unwrap();
108108
}
109109
tokio::time::sleep(Duration::from_millis(10)).await;

examples/features/src/big_compute_buffers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub async fn execute_gpu_inner(
8080
slice.map_async(wgpu::MapMode::Read, |_| {});
8181
}
8282

83-
device.poll(wgpu::PollType::Wait).unwrap();
83+
device.poll(wgpu::PollType::wait_indefinitely()).unwrap();
8484

8585
let mut data = Vec::new();
8686
for staging_buffer in &staging_buffers {

examples/features/src/framework.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,9 @@ impl<E: Example + wgpu::WasmNotSendSync> From<ExampleTestParams<E>>
597597

598598
let dst_buffer_slice = dst_buffer.slice(..);
599599
dst_buffer_slice.map_async(wgpu::MapMode::Read, |_| ());
600-
ctx.async_poll(wgpu::PollType::wait()).await.unwrap();
600+
ctx.async_poll(wgpu::PollType::wait_indefinitely())
601+
.await
602+
.unwrap();
601603
let bytes = dst_buffer_slice.get_mapped_range().to_vec();
602604

603605
wgpu_test::image::compare_image_output(

0 commit comments

Comments
 (0)