-
Notifications
You must be signed in to change notification settings - Fork 962
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
Add Instance::wgsl_language_features
#6814
base: trunk
Are you sure you want to change the base?
Conversation
ImplementedLanguageExtension
as WGSLLanguageExtension
WGSLLanguageExtension
cc @ErichDonGubler, who wrote #6437. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, some comments
8787ee3
to
e9ab502
Compare
rebased and squashed into two commits (one for naga changes, one for wgpu changes). |
e9ab502
to
b89fe77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM, mostly nit-level things and some maintainability concerns.0
const ALL: [ImplementedLanguageExtension; 0] = []; | ||
|
||
/// Returns slice of all variants of [`ImplementedLanguageExtension`] | ||
pub const fn all() -> &'static [Self] { | ||
&Self::ALL | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: It would be more future-proof to implement this in terms of strum::{EnumIter,IntoEnumIterator}
, and return an impl Iterator<Item = ImplementedLanguageExtension
instead.more maintenance-proof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh didn't know we already have strum as dep, will fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's only dev-dep and it's not present in FF, are we still okay to add it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it anyway in 0bc74e2 using VariantArray
. I will revert it if we do not want strum as dep.
"readonly_and_readwrite_storage_textures" => { | ||
Some(crate::WGSLLanguageFeatures::ReadOnlyAndReadWriteStorageTextures) | ||
} | ||
"packed_4x8_integer_dot_product" => { | ||
Some(crate::WGSLLanguageFeatures::Packed4x8IntegerDotProduct) | ||
} | ||
"unrestricted_pointer_parameters" => { | ||
Some(crate::WGSLLanguageFeatures::UnrestrictedPointerParameters) | ||
} | ||
"pointer_composite_access" => { | ||
Some(crate::WGSLLanguageFeatures::PointerCompositeAccess) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Matching on identifiers here duplicates logic that we already have LanguageExtension::from_ident
.
suggestion: We're also going to need to map from ImplementedLanguageExtension
to WGSLLanguageFeatures
anyway when using the wgpu_core
backend, so let's match
LanguageExtension::from_ident(wlf.as_str())
(probably using a separate method on WGSLLanguageFeatures
or an implementation of Into
) instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that here is webgpu impl, that does not necessary have naga available.
But we do use LanguageExtension::from_ident for parsing in core backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mm, I guess I don't see this as a blocking issue, then. Let's file a follow-up issue to deal with "properly" sharing this, if we can come up with a decent solution.
b89fe77
to
ce36775
Compare
c566f93
to
2900b24
Compare
…ension` Signed-off-by: sagudev <[email protected]> Co-Authored-By: Erich Gubler <[email protected]>
WGSLLanguageExtension
WgslLanguageExtension
WgslLanguageExtension
WgslLanguageFeatures
WgslLanguageFeatures
Instance.wgsl_language_features
Instance.wgsl_language_features
Instance::wgsl_language_features
Signed-off-by: sagudev <[email protected]> Co-Authored-By: Erich Gubler <[email protected]>
…antArray` Signed-off-by: sagudev <[email protected]>
2900b24
to
9e58b3d
Compare
/// A variant of [`LanguageExtension::Implemented`]. | ||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] | ||
pub(crate) enum ImplementedLanguageExtension {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
65 | /// A variant of [`LanguageExtension::Implemented`].
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
the problem is that we still only expose ImplementedLanguageExtension
outside of this module, hence rustdoc errors. We will either need to expose them all or change it's doc (I did the second option initially).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think exposing all *LanguageExtension
APIs is a fine course of action. However, I think I'd prefer we not rename them, if that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you will push PR to finish line, let me know if that's not the case.
Connections
#6350
Description
This is to allow browsers to implement https://www.w3.org/TR/webgpu/#gpuwgsllanguagefeatures, currently we do not implement any such extension (but I am working on pointer_composite_access, hence this PR).
Testing
There is none.
Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.