-
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
Implement WGSLLanguageExtension
#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.
bitflags::bitflags! { | ||
/// WGSL language extensions. | ||
/// | ||
/// WGSL spec.: <https://www.w3.org/TR/WGSL/#language-extensions-sec> | ||
#[derive(Debug, Clone, PartialEq, PartialOrd, Ord, Eq, Hash)] | ||
pub struct WGSLLanguageFeatures: u32 { | ||
/// <https://www.w3.org/TR/WGSL/#language_extension-readonly_and_readwrite_storage_textures> | ||
const ReadOnlyAndReadWriteStorageTextures = 1 << 0; | ||
/// <https://www.w3.org/TR/WGSL/#language_extension-packed_4x8_integer_dot_product> | ||
const Packed4x8IntegerDotProduct = 1 << 1; | ||
/// <https://www.w3.org/TR/WGSL/#language_extension-unrestricted_pointer_parameters> | ||
const UnrestrictedPointerParameters = 1 << 2; | ||
/// <https://www.w3.org/TR/WGSL/#language_extension-pointer_composite_access> | ||
const PointerCompositeAccess = 1 << 3; | ||
} | ||
} | ||
|
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.
question: Is there a reason this shouldn't be in wgpu-types
? This would also have the benefit of not needing to add the bitflags
dep. to wgpu
.
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.
Not really, except that it is only used in wgpu.
"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.
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
b89fe77
to
ce36775
Compare
Signed-off-by: sagudev <[email protected]>
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.