Skip to content

Commit 3ef31fc

Browse files
committed
Require token for experimental features
1 parent 967cd4b commit 3ef31fc

File tree

24 files changed

+191
-3
lines changed

24 files changed

+191
-3
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ Difference for SPIR-V passthrough:
7373
```
7474
This allows using precompiled shaders without manually checking which backend's code to pass, for example if you have shaders precompiled for both DXIL and SPIR-V.
7575

76+
#### `EXPERIMENTAL_*` features now require unsafe code to enable
77+
78+
We want to be able to expose potentially experimental features to our users before we have ensured that they are fully sound to use.
79+
As such, we now require any feature that is prefixed with `EXPERIMENTAL` to have a special unsafe token enabled in the device descriptor
80+
acknowledging that the features may still have bugs in them and to report any they find.
81+
82+
```rust
83+
adapter.request_device(&wgpu::DeviceDescriptor {
84+
features: wgpu::Features::EXPERIMENTAL_MESH_SHADER,
85+
experimental_features: unsafe { wgpu::ExperimentalFeatures::enabled() }
86+
..
87+
})
88+
```
89+
90+
By @cwfitzgerald in [#8163](https://github.com/gfx-rs/wgpu/pull/8163).
7691

7792
#### Multi-draw indirect is now unconditionally supported when indirect draws are supported
7893

benches/benches/wgpu-benchmark/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl DeviceState {
4747
required_features: adapter.features(),
4848
required_limits: adapter.limits(),
4949
memory_hints: wgpu::MemoryHints::Performance,
50+
experimental_features: unsafe { wgpu::ExperimentalFeatures::enabled() },
5051
label: Some("Compute/RenderPass Device"),
5152
trace: wgpu::Trace::Off,
5253
}))

deno_webgpu/adapter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ impl GPUAdapter {
146146
descriptor.required_features,
147147
),
148148
required_limits,
149+
experimental_features: wgpu_types::ExperimentalFeatures::disabled(),
149150
memory_hints: Default::default(),
150151
trace,
151152
};

examples/features/src/framework.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ impl ExampleContext {
287287
required_features: (E::optional_features() & adapter.features())
288288
| E::required_features(),
289289
required_limits: needed_limits,
290+
experimental_features: unsafe { wgpu::ExperimentalFeatures::enabled() },
290291
memory_hints: wgpu::MemoryHints::MemoryUsage,
291292
trace: match std::env::var_os("WGPU_TRACE") {
292293
Some(path) => wgpu::Trace::Directory(path.into()),

examples/features/src/hello_synchronization/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async fn run() {
1616
label: None,
1717
required_features: wgpu::Features::empty(),
1818
required_limits: wgpu::Limits::downlevel_defaults(),
19+
experimental_features: wgpu::ExperimentalFeatures::disabled(),
1920
memory_hints: wgpu::MemoryHints::Performance,
2021
trace: wgpu::Trace::Off,
2122
})

examples/features/src/hello_triangle/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
3131
// Make sure we use the texture resolution limits from the adapter, so we can support images the size of the swapchain.
3232
required_limits: wgpu::Limits::downlevel_webgl2_defaults()
3333
.using_resolution(adapter.limits()),
34+
experimental_features: wgpu::ExperimentalFeatures::disabled(),
3435
memory_hints: wgpu::MemoryHints::MemoryUsage,
3536
trace: wgpu::Trace::Off,
3637
})

examples/features/src/hello_windows/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ async fn run(event_loop: EventLoop<()>, viewports: Vec<(Arc<Window>, wgpu::Color
7474
label: None,
7575
required_features: wgpu::Features::empty(),
7676
required_limits: wgpu::Limits::downlevel_defaults(),
77+
experimental_features: wgpu::ExperimentalFeatures::disabled(),
7778
memory_hints: wgpu::MemoryHints::MemoryUsage,
7879
trace: wgpu::Trace::Off,
7980
})

examples/features/src/hello_workgroups/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async fn run() {
3131
label: None,
3232
required_features: wgpu::Features::empty(),
3333
required_limits: wgpu::Limits::downlevel_defaults(),
34+
experimental_features: wgpu::ExperimentalFeatures::disabled(),
3435
memory_hints: wgpu::MemoryHints::MemoryUsage,
3536
trace: wgpu::Trace::Off,
3637
})

examples/features/src/render_to_texture/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async fn run(_path: Option<String>) {
2020
label: None,
2121
required_features: wgpu::Features::empty(),
2222
required_limits: wgpu::Limits::downlevel_defaults(),
23+
experimental_features: wgpu::ExperimentalFeatures::disabled(),
2324
memory_hints: wgpu::MemoryHints::MemoryUsage,
2425
trace: wgpu::Trace::Off,
2526
})

examples/features/src/repeated_compute/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ impl WgpuContext {
164164
label: None,
165165
required_features: wgpu::Features::empty(),
166166
required_limits: wgpu::Limits::downlevel_defaults(),
167+
experimental_features: wgpu::ExperimentalFeatures::disabled(),
167168
memory_hints: wgpu::MemoryHints::Performance,
168169
trace: wgpu::Trace::Off,
169170
})

0 commit comments

Comments
 (0)