-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Require token for experimental features #8163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ErichDonGubler
merged 1 commit into
gfx-rs:trunk
from
cwfitzgerald:cw/experimental-features
Aug 29, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| fn noop_adapter() -> wgpu::Adapter { | ||
| let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { | ||
| backends: wgpu::Backends::NOOP, | ||
| backend_options: wgpu::BackendOptions { | ||
| noop: wgpu::NoopBackendOptions { enable: true }, | ||
| ..Default::default() | ||
| }, | ||
| ..Default::default() | ||
| }); | ||
|
|
||
| pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions::default())) | ||
| .expect("noop backend adapter absent when it should be") | ||
| } | ||
|
|
||
| #[test] | ||
| fn request_no_experimental_features() { | ||
| let adapter = noop_adapter(); | ||
|
|
||
| let dq = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor { | ||
| // Not experimental | ||
| required_features: wgpu::Features::FLOAT32_FILTERABLE, | ||
| experimental_features: wgpu::ExperimentalFeatures::disabled(), | ||
| ..Default::default() | ||
| })); | ||
|
|
||
| assert!(dq.is_ok()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn request_experimental_features() { | ||
| let adapter = noop_adapter(); | ||
|
|
||
| let dq = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor { | ||
| // Experimental | ||
| required_features: wgpu::Features::EXPERIMENTAL_MESH_SHADER, | ||
| experimental_features: unsafe { wgpu::ExperimentalFeatures::enabled() }, | ||
| ..Default::default() | ||
| })); | ||
|
|
||
| assert!(dq.is_ok()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn request_experimental_features_when_not_enabled() { | ||
| let adapter = noop_adapter(); | ||
|
|
||
| let dq = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor { | ||
| // Experimental | ||
| required_features: wgpu::Features::EXPERIMENTAL_MESH_SHADER, | ||
| experimental_features: wgpu::ExperimentalFeatures::disabled(), | ||
| ..Default::default() | ||
| })); | ||
|
|
||
| assert!(dq.is_err()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn request_multiple_experimental_features_when_not_enabled() { | ||
| let adapter = noop_adapter(); | ||
|
|
||
| let dq = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor { | ||
| // Experimental | ||
| required_features: wgpu::Features::EXPERIMENTAL_MESH_SHADER | ||
| | wgpu::Features::EXPERIMENTAL_PASSTHROUGH_SHADERS, | ||
| experimental_features: wgpu::ExperimentalFeatures::disabled(), | ||
| ..Default::default() | ||
| })); | ||
|
|
||
| assert!(dq.is_err()); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /// Token of the user agreeing to access experimental features. | ||
| #[derive(Debug, Default, Copy, Clone)] | ||
| pub struct ExperimentalFeatures { | ||
| enabled: bool, | ||
| } | ||
|
|
||
| impl ExperimentalFeatures { | ||
| /// Uses of [`Features`] prefixed with "EXPERIMENTAL" are disallowed. | ||
| /// | ||
| /// [`Features`]: ../wgpu/struct.Features.html | ||
| pub const fn disabled() -> Self { | ||
| Self { enabled: false } | ||
| } | ||
|
|
||
| /// Uses of [`Features`] prefixed with "EXPERIMENTAL" may result | ||
| /// in undefined behavior when used incorrectly. The exact bounds | ||
| /// of these issues varies by the feature. These instances are | ||
| /// inherently bugs in our implementation that we will eventually fix. | ||
| /// | ||
| /// By giving access to still work-in-progress APIs, users can get | ||
| /// access to newer technology sooner, and we can work with users | ||
| /// to fix bugs quicker. | ||
| /// | ||
| /// Look inside our repo at the [`api-specs`] for more information | ||
| /// on various experimental apis. | ||
| /// | ||
| /// # Safety | ||
| /// | ||
| /// - You acknowledge that there may be UB-containing bugs in these | ||
| /// apis and those may be hit by calling otherwise safe code. | ||
| /// - You agree to report any such bugs to us, if you find them. | ||
| /// | ||
| /// [`Features`]: ../wgpu/struct.Features.html | ||
| /// [`api-specs`]: https://github.com/gfx-rs/wgpu/tree/trunk/docs/api-specs | ||
| pub const unsafe fn enabled() -> Self { | ||
| Self { enabled: true } | ||
| } | ||
|
|
||
| /// Returns true if the user has agreed to access experimental features. | ||
| pub const fn is_enabled(&self) -> bool { | ||
| self.enabled | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.